fix: shorten bonjour gateway service type

This commit is contained in:
Peter Steinberger
2026-01-20 15:10:02 +00:00
parent d161f3ab0f
commit 1f7cb4b853
20 changed files with 55 additions and 55 deletions

View File

@@ -166,9 +166,9 @@ function parseDnsSdBrowse(stdout: string): string[] {
const instances = new Set<string>();
for (const raw of stdout.split("\n")) {
const line = raw.trim();
if (!line || !line.includes("_clawdbot-gateway._tcp")) continue;
if (!line || !line.includes("_clawdbot-gw._tcp")) continue;
if (!line.includes("Add")) continue;
const match = line.match(/_clawdbot-gateway\._tcp\.?\s+(.+)$/);
const match = line.match(/_clawdbot-gw\._tcp\.?\s+(.+)$/);
if (match?.[1]) {
instances.add(decodeDnsSdEscapes(match[1].trim()));
}
@@ -225,13 +225,13 @@ async function discoverViaDnsSd(
timeoutMs: number,
run: typeof runCommandWithTimeout,
): Promise<GatewayBonjourBeacon[]> {
const browse = await run(["dns-sd", "-B", "_clawdbot-gateway._tcp", domain], {
const browse = await run(["dns-sd", "-B", "_clawdbot-gw._tcp", domain], {
timeoutMs,
});
const instances = parseDnsSdBrowse(browse.stdout);
const results: GatewayBonjourBeacon[] = [];
for (const instance of instances) {
const resolved = await run(["dns-sd", "-L", instance, "_clawdbot-gateway._tcp", domain], {
const resolved = await run(["dns-sd", "-L", instance, "_clawdbot-gw._tcp", domain], {
timeoutMs,
});
const parsed = parseDnsSdResolve(resolved.stdout, instance);
@@ -268,7 +268,7 @@ async function discoverWideAreaViaTailnetDns(
// Keep scans bounded: this is a fallback and should not block long.
ips = ips.slice(0, 40);
const probeName = `_clawdbot-gateway._tcp.${domain.replace(/\.$/, "")}`;
const probeName = `_clawdbot-gw._tcp.${domain.replace(/\.$/, "")}`;
const concurrency = 6;
let nextIndex = 0;
@@ -312,7 +312,7 @@ async function discoverWideAreaViaTailnetDns(
if (budget <= 0) break;
const ptrName = ptr.trim().replace(/\.$/, "");
if (!ptrName) continue;
const instanceName = ptrName.replace(/\.?_clawdbot-gateway\._tcp\..*$/, "");
const instanceName = ptrName.replace(/\.?_clawdbot-gw\._tcp\..*$/, "");
const srv = await run(["dig", "+short", "+time=1", "+tries=1", nameserverArg, ptrName, "SRV"], {
timeoutMs: Math.max(1, Math.min(350, budget)),
@@ -371,9 +371,9 @@ function parseAvahiBrowse(stdout: string): GatewayBonjourBeacon[] {
for (const raw of stdout.split("\n")) {
const line = raw.trimEnd();
if (!line) continue;
if (line.startsWith("=") && line.includes("_clawdbot-gateway._tcp")) {
if (line.startsWith("=") && line.includes("_clawdbot-gw._tcp")) {
if (current) results.push(current);
const marker = " _clawdbot-gateway._tcp";
const marker = " _clawdbot-gw._tcp";
const idx = line.indexOf(marker);
const left = idx >= 0 ? line.slice(0, idx).trim() : line;
const parts = left.split(/\s+/);
@@ -429,7 +429,7 @@ async function discoverViaAvahi(
timeoutMs: number,
run: typeof runCommandWithTimeout,
): Promise<GatewayBonjourBeacon[]> {
const args = ["avahi-browse", "-rt", "_clawdbot-gateway._tcp"];
const args = ["avahi-browse", "-rt", "_clawdbot-gw._tcp"];
if (domain && domain !== "local.") {
// avahi-browse wants a plain domain (no trailing dot)
args.push("-d", domain.replace(/\.$/, ""));