Repository navigation
Engine: implement draft 2 (WireGuard tunnel, pluggable carriers, awp tunnel) - #30
Open
kylemclaren wants to merge 5 commits into
Open
kylemclaren wants to merge 5 commits into
kylemclaren wants to merge 5 commits into
Conversation
A new tunnel package is the connection layer: Tailscale's wireguard-go keyed by the identity (Ed25519 converted to X25519), a gVisor TCP/IP stack in userspace with AWP on port 1, and a conn.Bind over four carriers (udp, unix, ws with a Cloudflare quick tunnel option, tailcat) that roams with the peer. Addresses are awp1 CBOR blobs of key, pre-shared key and endpoints; pre-shared keys become per pair once two peers have met. The node drops auth: hello carries grants and addr, and hello.key must be the tunnel's key. The schema moves to v1, the conformance runner dials through its own tunnel with hello-key scenarios, and `awp tunnel` is the helper SDKs in other languages run for the tunnel. The transport package, the plaintext binding and the draft 1 Python peer are gone.
…nitiation With a listener on two carriers, three problems showed up under conformance against a live daemon on tailcat and udp: - A slow connection carrier (tailcat's rate-limited DERP relay) blocked WireGuard's send path. Connection carriers now have a bounded send queue that drops like a full UDP socket. - The current path flipped to whichever carrier spoke last. It now moves to a less preferred kind (unix, udp, ws, tailcat in that order) only once the current one has been quiet for three seconds. - A handshake response went down every path, and forcing a handshake on every dial replayed WireGuard's coarse timestamp. Responses now go back on the path the initiation came from, and a dial rides the existing session first, forcing a new handshake only if that goes nowhere for three seconds. Tests: SPEC.md's addresses decode, the tunnel IP vector, repeated dials over two paths, and failover when the preferred path dies mid-stream.
Tunnel.Listen adds a carrier after Start. The helper's control socket
takes {"listen": spec}, answered once the carrier is up, and
{"rotate": true}, so an SDK can start the helper once and listen when
its user asks.
A forwarded stream starts with one line of the helper's own naming the peer's X25519 key, and a dial reply carries it too, so the SDK can pick the grants to present in its hello before the peer's hello arrives.
A restarted peer can find its Unix socket or UDP port still held for a moment by the process it replaces (an SDK's helper exits when its stdin closes). Listen retries for up to three seconds before failing.
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.
Stacked on #28 (the spec). Implements draft 2 across the reference implementation: engine, daemon, CLI, MCP, conformance runner, schema, plugin skill. No compatibility with draft 1 (protocol v0).
What changes
tunnelpackage (new, public): the connection layer.conn.Bindover four carriers.udp.unix.ws, with acloudflareoption that runscloudflaredfor a quick tunnel.tailcat, as a plain carrier: WireGuard datagrams length-prefixed on a tailcat stream.InitiationAwareEndpoint/PeerAwareEndpointhooks. Paths prefer direct over relayed and fail over when one goes quiet. Carriers never block WireGuard.awp1addresses (CBOR, deterministic). Pre-shared keys become per pair once two peers meet, soawp address --rotateshuts out strangers only.auth. Hello carriesgrantsandaddr, andhello.keymust be the tunnel's key or the connection getserr auth. Admission refusals use the newrefusedcode. Introductions hand on the mergedawp1address.schema/v1/,$id…/schema/v1/awp.schema.json). Every SPEC.md example validates, and every address in SPEC.md decodes.awp conformdials through a tunnel of its own. The newhello-keyandhello-own-keyscenarios replaceauth-bad-sig, and--listentakes a carrier.awp tunnel(new): the helper the Python and TypeScript SDKs run. It holds the SDK's key, prints the address, dials on request over a control socket, and forwards accepted streams. It rejects a hello naming another key before the SDK sees it.--listentakes carriers, andawp statusshows the address, its endpoints and pending carriers.awp connectright after a bye no longer returns the closing connection.transportpackage,AWP_ALLOW_PLAINTEXT/tcp:, and the draft 1 single-file Python peer with its interop scripts. The Python SDK carries cross-implementation conformance now.Also on #28: spec corrections found while implementing it (pair pre-shared keys,
hello.addrandintroduce.peer.addressas addresses, tailcat and connection carrier framing, the helper as built).Testing
go test -race ./...green. The Go node passes its own conformance suite in both modes.make carriersruns the live carriers, and both pass here. Tailcat goes through the public DERP relays. Cloudflare goes through a realtrycloudflare.comquick tunnel with no account. CI runs these in a non-blocking job.awp conformagainst A's live daemon passed 16 of 16 in about 4 seconds.Next: the SDK PRs (Go, Python, TypeScript) pin this branch's commit.