export function isDualStackLoopbackGatewayListeners(
listeners: PortListener[],
port: number,
): boolean { if (listeners.length < 2) { returnfalse;
} const pids = new Set<number>(); const families = new Set<"ipv4" | "ipv6">(); for (const listener of listeners) { if (classifyPortListener(listener, port) !== "gateway") { returnfalse;
} const pid = listener.pid; if (typeof pid !== "number" || !Number.isFinite(pid)) { returnfalse;
}
pids.add(pid); if (typeof listener.address !== "string") { returnfalse;
} const parsedAddress = parseListenerAddress(listener.address); if (!parsedAddress || parsedAddress.port !== port) { returnfalse;
} const family = classifyLoopbackAddressFamily(parsedAddress.host); if (!family) { returnfalse;
}
families.add(family);
} return pids.size === 1 && families.has("ipv4") && families.has("ipv6");
}
export function buildPortHints(listeners: PortListener[], port: number): string[] { if (listeners.length === 0) { return [];
} const kinds = new Set(listeners.map((listener) => classifyPortListener(listener, port))); const hints: string[] = []; if (kinds.has("gateway")) {
hints.push(
`Gateway already running locally. Stop it (${formatCliCommand("openclaw gateway stop")}) or use a different port.`,
);
} if (kinds.has("ssh")) {
hints.push( "SSH tunnel already bound to this port. Close the tunnel or use a different local port in -L.",
);
} if (kinds.has("unknown")) {
hints.push("Another process is listening on this port.");
} if (listeners.length > 1 && !isDualStackLoopbackGatewayListeners(listeners, port)) {
hints.push( "Multiple listeners detected; ensure only one gateway/tunnel per port unless intentionally running isolated profiles.",
);
} return hints;
}
export function formatPortDiagnostics(diagnostics: PortUsage): string[] { if (diagnostics.status !== "busy") { return [`Port ${diagnostics.port} is free.`];
} const lines = [`Port ${diagnostics.port} is already in use.`]; for (const listener of diagnostics.listeners) {
lines.push(`- ${formatPortListener(listener)}`);
} for (const hint of diagnostics.hints) {
lines.push(`- ${hint}`);
} return lines;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(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.