openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
29 lines (28 loc) • 1.37 kB
JavaScript
import { l as isValidIPv4 } from "./net-DTe7AQiu.js";
import { n as pickBestEffortPrimaryLanIPv4, t as inspectBestEffortPrimaryTailnetIPv4 } from "./network-discovery-display-DwCzf-iO.js";
import { r as normalizeControlUiBasePath } from "./control-ui-shared-Clry3kRy.js";
//#region src/gateway/control-ui-links.ts
/** Resolve the advertised HTTP and websocket URLs for the Control UI. */
function resolveControlUiLinks(params) {
const port = params.port;
const bind = params.bind ?? "loopback";
const customBindHost = params.customBindHost?.trim();
const { tailnetIPv4 } = inspectBestEffortPrimaryTailnetIPv4();
const host = (() => {
if (bind === "custom" && customBindHost && isValidIPv4(customBindHost)) return customBindHost;
if (bind === "tailnet" && tailnetIPv4) return tailnetIPv4 ?? "127.0.0.1";
if (bind === "lan") return pickBestEffortPrimaryLanIPv4() ?? "127.0.0.1";
return "127.0.0.1";
})();
const basePath = normalizeControlUiBasePath(params.basePath);
const uiPath = basePath ? `${basePath}/` : "/";
const wsPath = basePath ? basePath : "";
const httpScheme = params.tlsEnabled === true ? "https" : "http";
const wsScheme = params.tlsEnabled === true ? "wss" : "ws";
return {
httpUrl: `${httpScheme}://${host}:${port}${uiPath}`,
wsUrl: `${wsScheme}://${host}:${port}${wsPath}`
};
}
//#endregion
export { resolveControlUiLinks as t };