Commit 8: Plugin-System (Scanner erweitern, Geräte importieren, Icons)

This commit is contained in:
2026-07-19 10:14:43 +02:00
parent 6a7eb3dfe5
commit 986de50963
20 changed files with 517 additions and 20 deletions

View File

@@ -17,6 +17,7 @@ export interface DiscoveredService {
description?: string;
suggestedDisplayName: string;
category?: string;
icon?: string;
}
/**
@@ -59,6 +60,7 @@ export async function scanDeviceServices(
description: software ? `${software.name} (automatisch erkannt)` : probe.title,
suggestedDisplayName: software?.name ?? probe.title ?? `${address}:${port}`,
category: software?.category,
icon: software?.icon,
});
}

View File

@@ -8,6 +8,8 @@ export interface SoftwareSignature {
name: string;
category: string;
matches: (input: SoftwareSignatureInput) => boolean;
/** Optional: Emoji oder Icon-URL, von Plugins bereitgestellt (siehe apps/backend/plugins). */
icon?: string;
}
function bodyContains(input: SoftwareSignatureInput, pattern: RegExp): boolean {
@@ -44,6 +46,21 @@ export const SOFTWARE_SIGNATURES: SoftwareSignature[] = [
{ name: "UniFi Network", category: "Netzwerk", matches: (i) => bodyContains(i, /unifi/i) },
];
export function detectSoftware(input: SoftwareSignatureInput): SoftwareSignature | null {
return SOFTWARE_SIGNATURES.find((signature) => signature.matches(input)) ?? null;
/**
* Zusätzliche Signaturen, die von Plugins zur Laufzeit registriert werden
* (siehe apps/backend/src/plugins/loader.ts). Eingebaute Signaturen haben
* Vorrang, falls beide zufällig auf denselben Dienst passen.
*/
const pluginSignatures: SoftwareSignature[] = [];
export function registerSoftwareSignature(signature: SoftwareSignature): void {
pluginSignatures.push(signature);
}
export function detectSoftware(input: SoftwareSignatureInput): SoftwareSignature | null {
return (
SOFTWARE_SIGNATURES.find((signature) => signature.matches(input)) ??
pluginSignatures.find((signature) => signature.matches(input)) ??
null
);
}