From 7720106624be010db65cdea23eb40576c3a875c5 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 20 Jan 2026 12:10:13 +0000 Subject: [PATCH] feat: add discovery role hints --- src/cli/gateway-cli/discover.ts | 6 ++++++ src/infra/bonjour-discovery.ts | 8 ++++++++ src/infra/widearea-dns.ts | 1 + 3 files changed, 15 insertions(+) diff --git a/src/cli/gateway-cli/discover.ts b/src/cli/gateway-cli/discover.ts index e624d5f40..854ccb484 100644 --- a/src/cli/gateway-cli/discover.ts +++ b/src/cli/gateway-cli/discover.ts @@ -82,6 +82,12 @@ export function renderBeaconLines(beacon: GatewayBonjourBeacon, rich: boolean): if (wsUrl) { lines.push(` ${colorize(rich, theme.muted, "ws")}: ${colorize(rich, theme.command, wsUrl)}`); } + if (beacon.role) { + lines.push(` ${colorize(rich, theme.muted, "role")}: ${beacon.role}`); + } + if (beacon.transport) { + lines.push(` ${colorize(rich, theme.muted, "transport")}: ${beacon.transport}`); + } if (beacon.gatewayTls) { const fingerprint = beacon.gatewayTlsFingerprintSha256 ? `sha256 ${beacon.gatewayTlsFingerprintSha256}` diff --git a/src/infra/bonjour-discovery.ts b/src/infra/bonjour-discovery.ts index a93ba2478..5bd120c99 100644 --- a/src/infra/bonjour-discovery.ts +++ b/src/infra/bonjour-discovery.ts @@ -14,6 +14,8 @@ export type GatewayBonjourBeacon = { gatewayTls?: boolean; gatewayTlsFingerprintSha256?: string; cliPath?: string; + role?: string; + transport?: string; txt?: Record; }; @@ -211,6 +213,8 @@ function parseDnsSdResolve(stdout: string, instanceName: string): GatewayBonjour beacon.gatewayTls = raw === "1" || raw === "true" || raw === "yes"; } if (txt.gatewayTlsSha256) beacon.gatewayTlsFingerprintSha256 = txt.gatewayTlsSha256; + if (txt.role) beacon.role = txt.role; + if (txt.transport) beacon.transport = txt.transport; if (!beacon.displayName) beacon.displayName = decodedInstanceName; return beacon; @@ -351,6 +355,8 @@ async function discoverWideAreaViaTailnetDns( beacon.gatewayTls = raw === "1" || raw === "true" || raw === "yes"; } if (txtMap.gatewayTlsSha256) beacon.gatewayTlsFingerprintSha256 = txtMap.gatewayTlsSha256; + if (txtMap.role) beacon.role = txtMap.role; + if (txtMap.transport) beacon.transport = txtMap.transport; results.push(beacon); } @@ -409,6 +415,8 @@ function parseAvahiBrowse(stdout: string): GatewayBonjourBeacon[] { current.gatewayTls = raw === "1" || raw === "true" || raw === "yes"; } if (txt.gatewayTlsSha256) current.gatewayTlsFingerprintSha256 = txt.gatewayTlsSha256; + if (txt.role) current.role = txt.role; + if (txt.transport) current.transport = txt.transport; } } diff --git a/src/infra/widearea-dns.ts b/src/infra/widearea-dns.ts index b6259402e..231578b4c 100644 --- a/src/infra/widearea-dns.ts +++ b/src/infra/widearea-dns.ts @@ -86,6 +86,7 @@ function renderZone(opts: WideAreaGatewayZoneOpts & { serial: number }): string const txt = [ `displayName=${opts.displayName.trim() || hostname}`, + `role=gateway`, `transport=gateway`, `gatewayPort=${opts.gatewayPort}`, ];