Repository navigation
fix(picker,host): joiner reachability + Windows host LAN enumeration - #397
Merged
Merged
Conversation
Two cross-machine bugs uncovered when Joel's Windows peer hosted #cambriantech and a Mac without Tailscale tried to join: ## Bug A — joiner picker dialed unreachable Tailscale (DESTRUCTIVE) Symptom (live, 2026-05-02): Mac monitor self-healed and DEMOLISHED the working room gist because its picker chose Windows host's tailscale 100.x address. Mac had no Tailscale → TCP connect failed → "host unreachable" → self-heal-as-new-host triggered → gist deleted. Other peers happily talking to the host suddenly orphaned. Root cause: the post-#393 fallback (`pick_addr_nonlocal_first`) correctly skipped localhost but still picked tailscale even when the joiner had no tailscale interface. Picking an unroutable scope is worse than picking nothing — empty return falls through to gh-bearer-only routing (broadcasts still work); a doomed dial triggers the destructive self-heal chain. Fix: 1. New gistparse subcommand `pick_addr_excluding <scope>+` that filters multiple scopes at once. Returns empty if every entry is excluded. 2. New `_have_tailscale_locally()` bash helper that probes for a usable Tailscale (binary signed-in OR 100.x interface). 3. `peer_pick_address` restored Tailscale-pick path BUT gated on local presence — only picks tailscale entries when this peer can actually route to them. 4. Final fallback now calls `pick_addr_excluding localhost tailscale` since both have already been tried with proper reachability checks. Empty return = caller falls through to gh-bearer-only routing as designed. ## Bug B — Windows host emitted only [localhost, tailscale] Symptom: Windows host's `host.addresses[]` had no `lan` entry, so same-LAN Mac joiners couldn't reach it directly (had to fall back to Tailscale, which then triggered Bug A). Root cause: `host_address_set` used `ifconfig` to enumerate LAN IPs. Git Bash on Windows has no `ifconfig` — Windows uses `ipconfig`. The bash command silently returned nothing on Windows, so no `lan|...` lines were emitted. Fix: add `MINGW*/MSYS*/CYGWIN*` branch to `host_address_set` that parses `ipconfig` output (CRLF-stripped, "IPv4 Address. . :" lines split on `: `, last field). Same loopback/link-local/CGNAT filtering as the ifconfig path. ## Tests - `test/test_gistparse.py` (new, 10/10 passing): covers `pick_addr_excluding` happy paths, empty-returns, malformed input, and `pick_addr_nonlocal_first` backward-compat. - bash syntax clean. - Synthetic Windows ipconfig output → parser extracts 192.168.1.42 + 10.0.0.50 (real LANs) and correctly excludes 100.x (Tailscale CGNAT, handled by the separate Tailscale block). ## Out of scope (separate PR) - Self-heal guard: even with Bug A fixed, the self-heal in cmd_connect.sh:1050 still demolishes the gist when handshake fails for ANY reason. Future bug: a TCP timeout on a routable address class (e.g. host firewall blocking the port) still triggers the destructive chain. Worth a guard like "only self-heal if we picked an address we believed reachable AND it failed AFTER N attempts" — but bigger refactor, separate PR. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Fixes two cross-machine connectivity issues in the address selection + host address publication flow used during airc connect join, especially for Windows hosts and non-Tailscale joiners.
Changes:
- Adds
gistparse pick_addr_excludingto allow joiners to skip multiple unreachable address scopes. - Restores Tailscale address picking in
peer_pick_address, gated by a new local Tailscale presence probe. - Extends
host_address_setto enumerate LAN IPv4 addresses on Windows Git Bash viaipconfig.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
test/test_gistparse.py |
New unit tests covering pick_addr_excluding and backward-compat for pick_addr_nonlocal_first. |
lib/airc_core/gistparse.py |
Adds new pick_addr_excluding subcommand to filter out multiple scopes when choosing an address. |
airc |
Windows LAN IP enumeration via ipconfig; joiner-side Tailscale reachability gating + updated fallback picker. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+940
to
+948
| local ts_out; ts_out=$("$ts_bin" status 2>&1) || true | ||
| case "$ts_out" in | ||
| *"Logged out"*|*"NeedsLogin"*|*"stopped"*) ;; # daemon down / signed out | ||
| *) | ||
| # Anything else from `tailscale status` (including the IP | ||
| # listing or "Tailscale is running") means we can route. | ||
| return 0 | ||
| ;; | ||
| esac |
Comment on lines
+906
to
+917
| # Fallback: first entry whose scope we can REACH. We've already | ||
| # tried localhost (machine_id match), lan (subnet match), and | ||
| # tailscale (local-presence check) above. What remains in | ||
| # addresses[] is some scope we don't model — e.g. a future "wan" | ||
| # entry, or a bespoke routing tag — give that a chance instead of | ||
| # ignoring it. But excluding localhost and tailscale here ensures | ||
| # we don't dial them blindly: localhost would mean our own loopback | ||
| # (never the host), and tailscale was already gated above on local | ||
| # presence — picking it here would re-introduce the destructive | ||
| # self-heal chain. Empty return → caller falls through to | ||
| # gh-bearer-only routing (broadcast still works; direct pair | ||
| # skipped). |
| continue | ||
| addr = entry.get("addr", "") | ||
| port = entry.get("port", "") | ||
| if addr and port != "": |
Comment on lines
+57
to
+60
| # Tailscale was first in the list after exclusion; lan was second. | ||
| # First-after-exclusion wins, so this should be lan if lan came first. | ||
| # Order in input: [localhost, lan, tailscale] → after excluding | ||
| # localhost: [lan, tailscale] → first = lan. |
3 tasks
joelteply
added a commit
that referenced
this pull request
May 2, 2026
…(Bug C from #397) (#398) fix(self-heal): don't nuke host's gist when picker found no reachable scope Bug uncovered by the same 2026-05-02 incident as #397. The address-picker fix in #397 prevents the most common shape (joiner picks unreachable tailscale on a Mac without tailnet), but a second path remained: when peer_pick_address returns empty, the caller falls through to the invite-string ssh_target. That fallback dial fails the same way — no route — and triggers the destructive self-heal-as-new-host chain that DELETES the host's gist for every other peer on the substrate. Concrete failure shape (now defended against): - Mac without Tailscale joins room hosted by Windows host whose addresses[] is [localhost, lan, tailscale]. - Picker correctly excludes localhost (other machine) and tailscale (no local tailnet), and the LAN scope's subnet doesn't match (Mac is on a different /24). Result: empty pick. - ssh_target stays at the invite-string default (Windows host's advertised primary, often tailscale on Windows pre-#397 hosts). - TCP handshake fails. - Pre-fix: self-heal triggers, gh deletes the gist, Mac re-execs as new host. Three other peers still happily talking to the Windows host suddenly orphaned because the gist is gone. Fix: track the picker outcome in `_addr_picker_state` ("no_addrs", "picked", "no_match") and gate the self-heal block on it. Self-heal only fires when: 1. Original conditions: room context + gh CLI + handshake failed 2. NEW: picker either succeeded OR there were no addresses[] to pick from (legacy gists / no multi-address protocol). Picker- ran-but-found-no-match means THIS peer's network mismatch, not host-down — nuking would damage other peers. When skipped: surface explicit message ("published no scope this peer can reach. Skipping self-heal. Direct pair unavailable; gh-bearer broadcasts still work via gist") so users debugging "why didn't I auto-pair" know it's topology, not host failure. Per the global "evidence is for the debugger" rule. ## Tests - bash syntax clean. - Unit tests for peer_pick_address reachability (#397 already added test_gistparse.py covering the upstream picker behavior). The guard here is a control-flow gate; the existing integration suite's scenario_two_tab_localhost exercises the picked-address path. The no_match guard would only manifest in cross-machine + scope- mismatch scenarios that integration tests don't simulate today — worth adding once the test rig has multi-network simulation, but out of scope here. ## Cumulative effect with #397 #397 (Bug A): Joiner picker excludes scopes it can't route. Most common cross-machine bad-pair shapes never reach the self-heal path. This PR (Bug C): When picker correctly finds nothing reachable, the fall-through to invite-string ssh_target no longer nukes the gist on TCP failure. Defense in depth. #397 + this = "no peer can take down the substrate for others by joining + failing to reach the host." Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two cross-machine bugs uncovered when Joel's Windows peer hosted #cambriantech and a Mac without Tailscale tried to join. The Mac's monitor self-healed and demolished the working room gist because its picker chose a Tailscale address it couldn't reach.
host_address_setusedifconfigto enumerate LAN IPs, but Git Bash on Windows has noifconfig— Windows usesipconfig. Result: Windows hosts emitted only[localhost, tailscale]inhost.addresses[], blocking same-LAN joiners from connecting directly.Fix
Bug A — joiner reachability gating:
pick_addr_excluding <scope>+filters multiple scopes at once._have_tailscale_locally()helper probes for usable Tailscale (binary signed-in OR 100.x interface present).peer_pick_addressrestored Tailscale-pick path BUT gated on local presence.pick_addr_excluding localhost tailscale— empty return → gh-bearer-only routing as designed.Bug B — Windows ipconfig path:
host_address_setaddsMINGW*/MSYS*/CYGWIN*branch parsingipconfigoutput (CRLF-stripped,IPv4 Address. . :lines split on:, last field). Same loopback/link-local/CGNAT filtering as the ifconfig path.Tests
test/test_gistparse.py(new, 10/10 passing):pick_addr_excludinghappy paths, empty-returns, malformed input,pick_addr_nonlocal_firstbackward-compat.ipconfigoutput → parser correctly extracts real LANs (192.168.1.42,10.0.0.50) and excludes100.x(Tailscale CGNAT, handled separately).Test plan
host.addresses[]includeslan|<ip>|...entries (verifiable viagh api gists/<id>after host comes online)Out of scope (separate PR)
Self-heal guard in
cmd_connect.sh:1050— even with Bug A fixed, the self-heal still demolishes the gist when the handshake fails for ANY reason (e.g. TCP timeout on a routable address class because of firewall). Worth a guard like "only self-heal after N failed attempts on a believed-reachable address" — bigger refactor, separate PR.🤖 Generated with Claude Code