Repository navigation
feat(server): same-user tailnet devices link both ways - #171
Merged
Merged
Conversation
A requester asks an issuer to link it; the issuer resolves the requester's address itself (tailnet IP or https MagicDNS name), whoises it (same user, untagged, optional t3.codes/device capability), checks its descriptor, asks it to confirm the pending challenge, and only then mints a session and delivers it there. It links back before answering, so one request makes a mutual link. No inbound header or source address is trusted. A background scan probes same-user tailnet peers, syncs device hints with linked devices, and renews tailnet links a week before expiry. A link whose token is refused (401) is renewed and the call retried once. Sessions record the caller's environmentId (auth_sessions.peer_environment_id, fork migration 012), including pairing-code links, which now name themselves when registering. t3_environment_link links one of the user's tailnet devices directly; anything else still gets the card. tailnetDevices.list and updateSettings are served. Tailscale Serve now defaults on (tailnet only), except for dev servers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: unavailable · PR result: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
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.
One owner's T3 servers on a tailnet still needed a pairing code each way. Now they find each other and link both ways, and nobody can talk a server into handing over a token.
How a link is proven
No
Tailscale-User-*header or source address is trusted. Requests arriving through Serve come from loopback, so neither tells you anything.What's in it
peer/TailnetDevices.ts: the handshake on both sides, the scan, gossip and refresh.PeerMcpClient).peer/TailnetIdentity.ts: the seam over Doug A'sreadTailnetandwhoisTailnetAddress.locateTailnetTargetnever maps plain-http names, LAN or public addresses.012_TailnetDevices:auth_sessions.peer_environment_id,peer_environment_links.origin, and thetailnet_devicesandtailnet_device_settingstables. Every incoming peer session, including pairing-code ones, now records the caller's environmentId.t3_environment_linklinks one of my tailnet devices directly. Other targets still get the card.assertNotLinkedis unchanged.tailnetDevices.listandtailnetDevices.updateSettingsare served.setAccesslands in the next PR andopenDevicein the one after.docs/internals/remote.md: a short trust-model section.Proof (
TailnetDevices.test.ts, real HTTP servers per device and a stubbed tailnet)requireCapabilityfilters nodes. Auto-link off refuses.locateTailnetTargettable: MagicDNS (https only), v4 and v6 tailnet IPs, and rejects for everything else.PeerLinks.test: pairing-code links still work, and now record the caller's environmentId.PeerLinkRequests.test: a tailnet device links directly with no card.Merge risk: medium.
/api/tailnet-devices/requestmakes this server dial out. It's bounded to 4 concurrent handshakes, 8 URLs per request and short timeouts.ForkMigrations.test > keeps upstream's migration idsfails locally only because this machine'supstream/mainref is stale. CI fetches it fresh.Checks:
vp run check:changed feat/mesh-contracts-pr2passes: format, lint, knip, typecheck of 33 packages, and 12 test files. Peer, auth, MCP, WS, persistence and desktop settings suites pass locally.Stacked on #168.
🤖 Generated with Claude Code · Claude Opus 5.5 in T3 Code