mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-29 19:59:32 +00:00
fix(node): avoid stale TLS pins when retargeting
This commit is contained in:
@@ -103,4 +103,34 @@ describe("registerNodeCli", () => {
|
||||
expect.objectContaining({ gatewayHost: "10.0.0.2", gatewayPort: 19001 }),
|
||||
);
|
||||
});
|
||||
|
||||
it("inherits saved TLS settings only when using the saved gateway endpoint", async () => {
|
||||
daemonMocks.loadNodeHostConfig.mockResolvedValue({
|
||||
version: 1,
|
||||
nodeId: "node-existing",
|
||||
gateway: {
|
||||
host: "10.0.0.2",
|
||||
port: 19001,
|
||||
tls: true,
|
||||
tlsFingerprint: "old-fingerprint",
|
||||
},
|
||||
});
|
||||
|
||||
await createProgram().parseAsync(["node", "run"], { from: "user" });
|
||||
expect(daemonMocks.runNodeHost).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({
|
||||
gatewayTls: true,
|
||||
gatewayTlsFingerprint: "old-fingerprint",
|
||||
}),
|
||||
);
|
||||
|
||||
await createProgram().parseAsync(["node", "run", "--host", "10.0.0.3"], { from: "user" });
|
||||
expect(daemonMocks.runNodeHost).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({
|
||||
gatewayHost: "10.0.0.3",
|
||||
gatewayTls: undefined,
|
||||
gatewayTlsFingerprint: undefined,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -64,15 +64,16 @@ export function registerNodeCli(program: Command) {
|
||||
defaultRuntime.exit(1);
|
||||
return;
|
||||
}
|
||||
const retargetedGateway = opts.host !== undefined || opts.port !== undefined;
|
||||
const tlsFingerprint =
|
||||
opts.tlsFingerprint ?? (retargetedGateway ? undefined : existing?.gateway?.tlsFingerprint);
|
||||
const inheritedTls = retargetedGateway ? undefined : existing?.gateway?.tls;
|
||||
await runNodeHost({
|
||||
gatewayHost: host,
|
||||
gatewayPort: port,
|
||||
gatewayTls:
|
||||
typeof opts.tls === "boolean"
|
||||
? opts.tls
|
||||
: Boolean(opts.tlsFingerprint ?? existing?.gateway?.tlsFingerprint) ||
|
||||
existing?.gateway?.tls,
|
||||
gatewayTlsFingerprint: opts.tlsFingerprint ?? existing?.gateway?.tlsFingerprint,
|
||||
typeof opts.tls === "boolean" ? opts.tls : Boolean(tlsFingerprint) || inheritedTls,
|
||||
gatewayTlsFingerprint: tlsFingerprint,
|
||||
nodeId: opts.nodeId,
|
||||
displayName: opts.displayName,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user