The best way to control Claude Code, Codex and more from any computer or phone
fix(server): omit Windows host-only adapters from LAN routes (#25217)
Co-authored-by: Dara Adedeji <76637177+SunkenInTime@users.noreply.github.com>
maria committed
Oct 31, 2026 at 08:42 UTC
15b58ffd31e7c330bc176f70a82dc5a44413550f
2 files changed
+74
-9
apps/server/src/environment/DirectEndpoints.test.ts
+63
-8
@@ -86,12 +86,12 @@ const vpnInterface = (address: string) => [
86
},
87
];
88
89
-const virtualInterface = (address: string) => [
89
+const virtualInterface = (address: string, mac = "02:42:ac:11:00:01") => [
90
{
91
address,
92
netmask: "255.255.0.0",
93
family: "IPv4" as const,
94
- mac: "02:42:ac:11:00:01",
94
+ mac,
95
internal: false,
96
cidr: `${address}/16`,
97
},
@@ -99,7 +99,14 @@ const virtualInterface = (address: string) => [
99
100
describe("resolveBoundEndpoints", () => {
101
it("lists every external IPv4 address for a wildcard bind, tagging the tailnet one", () => {
102
- expect(resolveBoundEndpoints({ host: "0.0.0.0", port: 3773, interfaces: INTERFACES })).toEqual([
102
+ expect(
103
+ resolveBoundEndpoints({
104
+ platform: "linux",
105
+ host: "0.0.0.0",
106
+ port: 3773,
107
+ interfaces: INTERFACES,
108
+ }),
109
+ ).toEqual([
110
{ kind: "lan", httpBaseUrl: "http://192.168.1.10:3773/" },
111
{ kind: "tailnet", httpBaseUrl: "http://100.101.102.103:3773/" },
112
]);
@@ -115,13 +122,46 @@ describe("resolveBoundEndpoints", () => {
122
bridge100: virtualInterface("192.168.64.1"),
123
vmbr0: virtualInterface("192.168.1.20"),
124
};
118
- expect(resolveBoundEndpoints({ host: "0.0.0.0", port: 3773, interfaces })).toEqual([
125
+ expect(
126
+ resolveBoundEndpoints({ platform: "linux", host: "0.0.0.0", port: 3773, interfaces }),
127
+ ).toEqual([
128
{ kind: "lan", httpBaseUrl: "http://192.168.1.10:3773/" },
129
{ kind: "tailnet", httpBaseUrl: "http://100.101.102.103:3773/" },
130
{ kind: "lan", httpBaseUrl: "http://192.168.1.20:3773/" },
131
]);
132
});
133
134
+ it("omits Windows host-only adapters without excluding guest NICs or explicit binds", () => {
135
+ const interfaces = {
136
+ ...INTERFACES,
137
+ "VirtualBox-Host-Only-Netzwerk": virtualInterface("192.168.56.1", "0A:00:27:00:01:01"),
138
+ "Ethernet 2": virtualInterface("192.168.150.1", "00:50:56:c0:00:01"),
139
+ "Renamed network": virtualInterface("192.168.151.1", "00:50:56:c0:00:08"),
140
+ guest1: virtualInterface("192.168.1.30", "08:00:27:5e:1a:22"),
141
+ guest2: virtualInterface("192.168.1.31", "00:50:56:2b:8c:01"),
142
+ guest3: virtualInterface("192.168.1.32", "00:0c:29:4f:8e:35"),
143
+ guest4: virtualInterface("192.168.1.33", "00:50:56:80:8c:01"),
144
+ };
145
+ const input = { host: "0.0.0.0", port: 3773, interfaces };
146
+ const retained = [
147
+ { kind: "lan", httpBaseUrl: "http://192.168.1.10:3773/" },
148
+ { kind: "tailnet", httpBaseUrl: "http://100.101.102.103:3773/" },
149
+ ...[30, 31, 32, 33].map((last) => ({
150
+ kind: "lan",
151
+ httpBaseUrl: `http://192.168.1.${last}:3773/`,
152
+ })),
153
+ ];
154
+ expect(resolveBoundEndpoints({ ...input, platform: "win32" })).toEqual(retained);
155
+ for (const platform of ["linux", "darwin"] as const) {
156
+ expect(resolveBoundEndpoints({ ...input, platform })).toHaveLength(retained.length + 3);
157
+ }
158
+ for (const host of ["192.168.56.1", "192.168.150.1", "192.168.151.1"]) {
159
+ expect(resolveBoundEndpoints({ ...input, platform: "win32", host })).toEqual([
160
+ { kind: "lan", httpBaseUrl: `http://${host}:3773/` },
161
+ ]);
162
+ }
163
+ });
164
+
165
it("tags only addresses on Tailscale's interface as tailnet, not other VPNs in its range", () => {
166
const interfaces = {
167
en0: INTERFACES.en0,
@@ -129,7 +169,9 @@ describe("resolveBoundEndpoints", () => {
169
CloudflareWARP: vpnInterface("100.96.0.1"),
170
utun7: vpnInterface("100.85.0.1"),
171
};
132
- expect(resolveBoundEndpoints({ host: "0.0.0.0", port: 3773, interfaces })).toEqual([
172
+ expect(
173
+ resolveBoundEndpoints({ platform: "linux", host: "0.0.0.0", port: 3773, interfaces }),
174
+ ).toEqual([
175
{ kind: "lan", httpBaseUrl: "http://192.168.1.10:3773/" },
176
{ kind: "tailnet", httpBaseUrl: "http://100.70.1.2:3773/" },
177
{ kind: "lan", httpBaseUrl: "http://100.96.0.1:3773/" },
@@ -139,19 +181,27 @@ describe("resolveBoundEndpoints", () => {
181
182
it("never reports a host name, which can resolve to another machine per client", () => {
183
for (const host of ["server.local", "devbox", "devbox.home.arpa"]) {
142
- expect(resolveBoundEndpoints({ host, port: 3773, interfaces: INTERFACES })).toEqual([]);
184
+ expect(
185
+ resolveBoundEndpoints({ platform: "linux", host, port: 3773, interfaces: INTERFACES }),
186
+ ).toEqual([]);
187
}
188
});
189
190
it("never reports a public address, which would carry the credential over plain HTTP", () => {
191
expect(
148
- resolveBoundEndpoints({ host: "203.0.113.20", port: 3773, interfaces: INTERFACES }),
192
+ resolveBoundEndpoints({
193
+ platform: "linux",
194
+ host: "203.0.113.20",
195
+ port: 3773,
196
+ interfaces: INTERFACES,
197
+ }),
198
).toEqual([]);
199
});
200
201
it("reports only the tailnet address on a cloud VM, whose private network no client shares", () => {
202
expect(
203
resolveBoundEndpoints({
204
+ platform: "linux",
205
host: "0.0.0.0",
206
port: 3773,
207
interfaces: INTERFACES,
@@ -162,7 +212,12 @@ describe("resolveBoundEndpoints", () => {
212
213
it("never reports an IPv4-mapped host, which can name the client's own loopback", () => {
214
expect(
165
- resolveBoundEndpoints({ host: "::ffff:127.0.0.1", port: 3773, interfaces: INTERFACES }),
215
+ resolveBoundEndpoints({
216
+ platform: "linux",
217
+ host: "::ffff:127.0.0.1",
218
+ port: 3773,
219
+ interfaces: INTERFACES,
220
+ }),
221
).toEqual([]);
222
});
223
});
apps/server/src/environment/DirectEndpoints.ts
+11
-1
@@ -14,6 +14,7 @@ import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
14
import * as NodeNet from "node:net";
15
import * as NodeOS from "node:os";
16
17
+import * as HostProcess from "@t3tools/shared/HostProcess";
18
import { isTailnetHost } from "@t3tools/shared/hostClassification";
19
20
import * as ServerConfig from "../config.ts";
@@ -49,7 +50,11 @@ const isTailscaleInterface = (
50
/^tailscale/i.test(name) ||
51
entries.some((entry) => entry.family === "IPv6" && isTailnetHost(entry.address));
52
53
+// Windows adapter names are mutable; Linux bridges can inherit these MACs.
54
+const WINDOWS_HOST_ADAPTER_MAC = /^(0a:00:27|00:50:56:c0:00):/i;
55
+
56
export function resolveBoundEndpoints(input: {
57
+ readonly platform: NodeJS.Platform;
58
readonly host: string | undefined;
59
readonly port: number;
60
readonly interfaces: NetworkInterfacesMap;
@@ -67,7 +72,10 @@ export function resolveBoundEndpoints(input: {
72
.flatMap(([name, entries]) => (VIRTUAL_INTERFACE.test(name) ? [] : (entries ?? [])))
73
.filter(
74
(entry) =>
70
- !entry.internal && entry.family === "IPv4" && isAdvertisableAddress(entry.address),
75
+ !entry.internal &&
76
+ entry.family === "IPv4" &&
77
+ isAdvertisableAddress(entry.address) &&
78
+ !(input.platform === "win32" && WINDOWS_HOST_ADAPTER_MAC.test(entry.mac)),
79
)
80
.map((entry) => entry.address)
81
: [input.host!].filter(isAdvertisableAddress);
@@ -111,6 +119,7 @@ export const make = Effect.gen(function* () {
119
const config = yield* ServerConfig.ServerConfig;
120
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
121
const httpClient = yield* HttpClient.HttpClient;
122
+ const platform = yield* HostProcess.Platform;
123
// Only the service default listens on every interface without being asked,
124
// so only it checks once whether it runs in a cloud. The check starts now so
125
// the first client does not wait for its timeout.
@@ -122,6 +131,7 @@ export const make = Effect.gen(function* () {
131
const resolve = Effect.gen(function* () {
132
const endpoints = [
133
...resolveBoundEndpoints({
134
+ platform,
135
host: config.host,
136
port: config.port,
137
interfaces: NodeOS.networkInterfaces(),