generated from Dicken/dickendock
Commit 8: Plugin-System (Scanner erweitern, Geräte importieren, Icons)
This commit is contained in:
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user