Skip to content

fix(lan): reach a peer at the address it names; log why an add fails - #259

Merged
mindaugaskasp merged 1 commit into
mainfrom
fix/lan-reflected-discovery
Nov 17, 2026
Merged

mindaugaskasp merged 1 commit into
mainfrom
fix/lan-reflected-discovery

Conversation

@mindaugaskasp

Copy link
Copy Markdown
Owner

Reported: adding a PC failed at once with "Connection lost", in both directions, between a wired and a wireless machine on the same network. Discovery showed each machine to the other, and the Add dialog flashed for a moment before the error.

Likely cause: routers and mesh systems often put wired and wireless clients on separate subnets and relay mDNS between them. A relayed announcement arrives with the router's address as its source. DiffBro connected to the packet source, so both machines dialled the router and were refused straight away.

Fix:

  • Each interface announces its own address in the TXT record (addr=). A receiver connects there when it's a valid private address, and falls back to the source for older versions.
  • The private-only connect fence and the signed acknowledgements are unchanged, so a false addr gives an attacker nothing that spoofing the source didn't already.
  • Goodbyes go out per interface the same way.

Diagnostics (info level, under Help ▸ Show log):

  • each peer's chosen address, with the address it named and the packet source;
  • the error and address of a failed connection;
  • a close before the code step;
  • a reply carrying the wrong key;
  • every reason a holder refuses a request.

If the cause turns out to be something else, the next attempt's log will say what.

Verified:

  • npm run check passes.
  • The LAN e2e specs pass (11, 4 workers).
  • New unit tests for the codec, reachableAt and the diagnostics, each seen failing first.

Both machines need this version for the named address to be sent.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PJaGuL4V5ghYxXSGoyYU8n

…ce; log why an add fails

Adding someone failed at once with "Connection lost", in both directions,
between a wired and a wireless machine on the same network, while discovery
showed each to the other. A router that relays mDNS between its wired and
wireless subnets forwards the announcement with its own address as the
source. Peers were reached at that source, so both machines dialled the
router, which has nothing on that port.

- Each interface announces its own address in the TXT record (addr=). A
  receiver connects there when it is a valid private address, and falls
  back to the packet source for older versions. The private-only connect
  fence and the signed acknowledgements are unchanged, so a false addr gains
  nothing an attacker could not already do by spoofing the source.
- Goodbyes go out per interface the same way.
- Diagnostics, at info level: where each peer will be reached (named address
  and packet source), the error and address of a failed connection, a close
  before the code step, a reply with the wrong key, and every reason a holder
  turns a request away (not visible, busy, rate-limited, unreadable key, own
  key).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PJaGuL4V5ghYxXSGoyYU8n
@mindaugaskasp
mindaugaskasp merged commit 73cbb9f into main Nov 17, 2026
5 checks passed
@mindaugaskasp
mindaugaskasp deleted the fix/lan-reflected-discovery branch November 17, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant