import type { GatewayBonjourBeacon } from "../../infra/bonjour-discovery.js"; import {
buildGatewayDiscoveryTarget,
serializeGatewayDiscoveryBeacon,
} from "../../infra/gateway-discovery-targets.js"; import { normalizeOptionalString } from "../../shared/string-coerce.js";
export function inferSshTargetFromRemoteUrl(rawUrl?: string | null): string | null { if (typeof rawUrl !== "string") { returnnull;
} const trimmed = normalizeOptionalString(rawUrl) ?? ""; if (!trimmed) { returnnull;
}
let host: string | null = null; try {
host = new URL(trimmed).hostname || null;
} catch { returnnull;
} if (!host) { returnnull;
} const user = normalizeOptionalString(process.env.USER) ?? ""; return user ? `${user}@${host}` : host;
}
export function buildSshTarget(input: {
user?: string;
host?: string;
port?: number;
}): string | null { const host = normalizeOptionalString(input.host) ?? ""; if (!host) { returnnull;
} const user = normalizeOptionalString(input.user) ?? ""; const base = user ? `${user}@${host}` : host; const port = input.port ?? 22; if (port && port !== 22) { return `${base}:${port}`;
} return base;
}
export function pickAutoSshTargetFromDiscovery(params: {
discovery: GatewayBonjourBeacon[];
parseSshTarget: (target: string) => unknown;
sshUser?: string | null;
}): string | null { for (const beacon of params.discovery) { const sshTarget = buildGatewayDiscoveryTarget(beacon, {
sshUser: params.sshUser ?? undefined,
}).sshTarget; if (!sshTarget) { continue;
} if (params.parseSshTarget(sshTarget)) { return sshTarget;
}
} returnnull;
}
export { serializeGatewayDiscoveryBeacon };
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.11Bemerkung:
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.