Gateway: force loopback self-connections for local binds

This commit is contained in:
Tyler Yust
2026-02-20 13:08:26 -08:00
parent c378439246
commit 47f3979758
3 changed files with 28 additions and 34 deletions

View File

@@ -93,23 +93,23 @@ describe("resolveGatewayConnection", () => {
});
});
it("uses tailnet host when local bind is tailnet", () => {
it("uses loopback host when local bind is tailnet", () => {
loadConfig.mockReturnValue({ gateway: { mode: "local", bind: "tailnet" } });
resolveGatewayPort.mockReturnValue(18800);
pickPrimaryTailnetIPv4.mockReturnValue("100.64.0.1");
const result = resolveGatewayConnection({});
expect(result.url).toBe("ws://100.64.0.1:18800");
expect(result.url).toBe("ws://127.0.0.1:18800");
});
it("uses lan host when local bind is lan", () => {
it("uses loopback host when local bind is lan", () => {
loadConfig.mockReturnValue({ gateway: { mode: "local", bind: "lan" } });
resolveGatewayPort.mockReturnValue(18800);
pickPrimaryLanIPv4.mockReturnValue("192.168.1.42");
const result = resolveGatewayConnection({});
expect(result.url).toBe("ws://192.168.1.42:18800");
expect(result.url).toBe("ws://127.0.0.1:18800");
});
});