Repository navigation
fix(sync): stop advertising hotspot and tunnel addresses as LAN - #2461
Conversation
The brain enumerated every non-internal IPv4 address as a LAN candidate
except a fixed list of interface names. Windows hotspot adapters
("Local Area Connection* 2") and 198.18.0.0/15 VPN tunnels were therefore
saved, broadcast in Bonjour TXT and offered first to a phone, which dials
an address that cannot answer. VirtualBox and VMware host-only adapters on
Windows were missed when renamed.
Filter the localized hotspot suffix, RFC 2544 tunnels, and the VirtualBox /
VMware MAC prefixes (Windows only, since Linux bridges can inherit them).
Co-Authored-By: Claude Code <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 40 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
Devin Review found 1 potential issue.
3 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| if (isVpnTunnelAddress(entry.address)) continue; | ||
| if (process.platform === "win32" && WINDOWS_HOST_ADAPTER_MAC.test(entry.mac)) continue; |
There was a problem hiding this comment.
🟡 Filtered addresses survive sync upgrades
After an upgrade, ensureLocalDevice keeps the old LAN list or tailnet IP when filtering leaves that field empty. Bonjour and pairing QR codes still advertise those saved addresses.
Learn more
The interface scan now rejects addresses that earlier versions saved in the local device row. ensureLocalDevice restores the stored LAN list when the scan returns an empty list and restores the stored tailnet IP when the scan returns null. touchLocalDevice repeats those fallbacks, and upsertDeviceRecord treats an explicit null tailnet IP as an omitted value. publishLanDiscovery and buildPairingConnectInfo use the resulting device row, so another refresh does not remove the rejected address.
Example: A host on Wi-Fi has an utun proxy at 198.19.2.2 and no real Tailscale adapter. The old version saves the proxy IP as tailscaleIp. After upgrading, the fresh scan returns null for tailscaleIp, but the existing row still carries 198.19.2.2, and the next Bonjour publish includes it.
Recommended fix: Make a successful local interface scan authoritative for the local row's LAN and tailnet fields, including an empty LAN list or explicit null tailnet IP. Preserve the existing merge behavior for peer updates that omit network fields. Extend the registry test to seed an old address and verify that refreshing the local row removes it from the pairing candidates.
Was this helpful? React with 👍 or 👎 to provide feedback.
| const isLikelyTailscaleInterface = /tailscale|utun|tun/i.test(interfaceName); | ||
| for (const entry of entries ?? []) { | ||
| if (!entry || entry.internal || entry.family !== "IPv4") continue; | ||
| if (isVpnTunnelAddress(entry.address)) continue; |
There was a problem hiding this comment.
Saved tunnel addresses survive
After an upgrade, an address such as 198.19.2.2 previously saved from utun40 remains in tailscaleIp. The new filter skips it, but ensureLocalDevice and touchLocalDevice keep the saved value when the fresh value is null—even when a real LAN address exists. Bonjour and pairing candidates then offer that unusable address to phones again.
Remove excluded addresses from saved values too, and allow upsertDeviceRecord to clear tailscaleIp.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/ade-cli/src/services/sync/deviceRegistryService.ts
Line: 275
Comment:
**Saved tunnel addresses survive**
After an upgrade, an address such as `198.19.2.2` previously saved from `utun40` remains in `tailscaleIp`. The new filter skips it, but `ensureLocalDevice` and `touchLocalDevice` keep the saved value when the fresh value is null—even when a real LAN address exists. Bonjour and pairing candidates then offer that unusable address to phones again.
Remove excluded addresses from saved values too, and allow `upsertDeviceRecord` to clear `tailscaleIp`.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| // RFC 2544 tunnels (Tailscale userspace, Clash/Mihomo Wintun) are never a LAN. | ||
| utun40: [{ address: "198.19.2.2", family: "IPv4", internal: false, netmask: "255.255.0.0", mac: "00:00:00:00:00:09", cidr: "198.19.2.2/16" }], | ||
| "VirtualBox Host-Only Network": [{ address: "192.168.56.1", family: "IPv4", internal: false, netmask: "255.255.0.0", mac: "0a:00:27:00:00:0a", cidr: "192.168.56.1/24" }], | ||
| "VMware Network Adapter VMnet8": [{ address: "192.168.159.1", family: "IPv4", internal: false, netmask: "255.255.255.0", mac: "00:50:56:c0:00:08", cidr: "192.168.159.1/24" }], |
There was a problem hiding this comment.
VMware MAC check goes untested
The VMware fixture never exercises WINDOWS_HOST_ADAPTER_MAC: its name contains VMnet8, so the existing name filter skips it first. A broken VMware MAC pattern would still pass this test. Give this fixture an unrelated name, as the test already does for VirtualBox, so it checks the promised renamed-adapter behavior.
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/main/services/sync/deviceRegistryService.test.ts
Line: 40
Comment:
**VMware MAC check goes untested**
The VMware fixture never exercises `WINDOWS_HOST_ADAPTER_MAC`: its name contains `VMnet8`, so the existing name filter skips it first. A broken VMware MAC pattern would still pass this test. Give this fixture an unrelated name, as the test already does for VirtualBox, so it checks the promised renamed-adapter behavior.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Why
The brain enumerated every non-internal IPv4 address as a LAN candidate except a fixed list of interface names. Windows hotspot adapters (
Local Area Connection* 2, and the localized equivalents) and 198.18.0.0/15 VPN tunnels were therefore saved, broadcast in Bonjour TXT and offered first to a phone, which dials an address that cannot answer. VirtualBox and VMware host-only adapters on Windows were missed when renamed.Same defect classes as pingdotgg/t3code#25991 and #33441, verified against ADE's device registry.
What changed
readLocalNetworkMetadatanow skips:<name>* <n>hotspot / Wi-Fi Direct suffix;Real LAN adapters, Hyper-V External switches and Tailscale keep their current order and classification.
Evidence
apps/ade-cliandapps/desktop.Not checked
Not exercised against a live Windows hotspot or a Clash/Mihomo TUN on this host. Full CI matrix not run locally.
🤖 Generated with Claude Code
Clear excluded saved addresses before merging so existing installations receive the fix.
Fix with agent prompt
Summary
The PR filters hotspot adapters, VPN tunnel addresses, and Windows host-only MAC prefixes before choosing local addresses.
Reviews (1) · Last reviewed commit: "fix(sync): stop advertising hotspot and ..." · Reviewed by Greptile