mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-10 01:23:54 +00:00
feat(node): add gateway context path support
This commit is contained in:
@@ -40,6 +40,7 @@ import { formatInvalidConfigPort, formatInvalidPortOption } from "../error-forma
|
||||
type NodeDaemonInstallOptions = {
|
||||
host?: string;
|
||||
port?: string | number;
|
||||
contextPath?: string;
|
||||
tls?: boolean;
|
||||
tlsFingerprint?: string;
|
||||
nodeId?: string;
|
||||
@@ -86,7 +87,12 @@ function resolveNodeDefaults(
|
||||
return { host, port: null };
|
||||
}
|
||||
const port = portOverride ?? config?.gateway?.port ?? 18789;
|
||||
return { host, port };
|
||||
const retargeted = opts.host !== undefined || opts.port !== undefined;
|
||||
const explicitContextPath = opts.contextPath !== undefined;
|
||||
const contextPath =
|
||||
normalizeOptionalString(opts.contextPath) ||
|
||||
(explicitContextPath || retargeted ? undefined : config?.gateway?.contextPath);
|
||||
return { host, port, contextPath };
|
||||
}
|
||||
|
||||
export async function runNodeDaemonInstall(opts: NodeDaemonInstallOptions) {
|
||||
@@ -96,7 +102,7 @@ export async function runNodeDaemonInstall(opts: NodeDaemonInstallOptions) {
|
||||
}
|
||||
|
||||
const config = await loadNodeHostConfig();
|
||||
const { host, port } = resolveNodeDefaults(opts, config);
|
||||
const { host, port, contextPath } = resolveNodeDefaults(opts, config);
|
||||
if (!Number.isFinite(port ?? Number.NaN) || (port ?? 0) <= 0 || (port ?? 0) > 65_535) {
|
||||
fail(
|
||||
opts.port !== undefined
|
||||
@@ -143,6 +149,7 @@ export async function runNodeDaemonInstall(opts: NodeDaemonInstallOptions) {
|
||||
env: process.env,
|
||||
host,
|
||||
port: port ?? 18789,
|
||||
contextPath,
|
||||
tls,
|
||||
tlsFingerprint: tlsFingerprint || undefined,
|
||||
nodeId: opts.nodeId,
|
||||
|
||||
@@ -50,6 +50,7 @@ export function registerNodeCli(program: Command) {
|
||||
.description("Run the headless node host (foreground)")
|
||||
.option("--host <host>", "Gateway host")
|
||||
.option("--port <port>", "Gateway port")
|
||||
.option("--context-path <path>", "Gateway WebSocket context path (e.g. /openclaw-gw)")
|
||||
.option("--tls", "Use TLS for the gateway connection")
|
||||
.option("--tls-fingerprint <sha256>", "Expected TLS certificate fingerprint (sha256)")
|
||||
.option("--node-id <id>", "Override node id (clears pairing token)")
|
||||
@@ -67,6 +68,7 @@ export function registerNodeCli(program: Command) {
|
||||
return;
|
||||
}
|
||||
const retargetedGateway = opts.host !== undefined || opts.port !== undefined;
|
||||
const explicitContextPath = opts.contextPath !== undefined;
|
||||
const tlsFingerprint =
|
||||
opts.tlsFingerprint ?? (retargetedGateway ? undefined : existing?.gateway?.tlsFingerprint);
|
||||
const inheritedTls = retargetedGateway ? undefined : existing?.gateway?.tls;
|
||||
@@ -76,6 +78,9 @@ export function registerNodeCli(program: Command) {
|
||||
gatewayTls:
|
||||
typeof opts.tls === "boolean" ? opts.tls : Boolean(tlsFingerprint) || inheritedTls,
|
||||
gatewayTlsFingerprint: tlsFingerprint,
|
||||
gatewayContextPath:
|
||||
normalizeOptionalString(opts.contextPath as string | undefined) ??
|
||||
(explicitContextPath || retargetedGateway ? undefined : existing?.gateway?.contextPath),
|
||||
nodeId: opts.nodeId,
|
||||
displayName: opts.displayName,
|
||||
});
|
||||
@@ -94,6 +99,7 @@ export function registerNodeCli(program: Command) {
|
||||
.description("Install the node host service (launchd/systemd/schtasks)")
|
||||
.option("--host <host>", "Gateway host")
|
||||
.option("--port <port>", "Gateway port")
|
||||
.option("--context-path <path>", "Gateway WebSocket context path (e.g. /openclaw-gw)")
|
||||
.option("--tls", "Use TLS for the gateway connection", false)
|
||||
.option("--tls-fingerprint <sha256>", "Expected TLS certificate fingerprint (sha256)")
|
||||
.option("--node-id <id>", "Override node id (clears pairing token)")
|
||||
|
||||
Reference in New Issue
Block a user