Repository navigation
Conversation
The uplink and the app session also run over QUIC on UDP 443, with the WebSocket's messages and a new framing: a control stream that starts with the target, a bulk stream each way for the tunnel's lane 1, and QUIC DATAGRAMs for hb and for live without sources, the two newest-wins classes. Tunnel traffic never goes as a datagram. Clients race QUIC 250 ms ahead of the WebSocket and remember the winner per network. Early data carries only the target and Noise message 1, and the service answers each message 1 in early data once. go/protocol/cloudwire/quic.go holds the names, the varint framing and the datagram rule; testdata/cloud-quic-vectors.json the bytes. The registry copy gains cloud_transports (srcfl/ftw-webapp, paired). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TestEveryFieldHasARow holds that every field of a wire type has a wire name, so a transport hint belongs to the service, not to cloudwire.Tun. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The box dials ftw-cloud-box/1 over QUIC first. If the QUIC handshake has not finished after 250 ms it dials the WebSocket too, takes the first to open and remembers the winner for the network, named by its local address towards the service; the next connection there starts with that one. Over QUIC the uplink's messages keep their bytes: hello binds to the TLS exporter inside QUIC, hb and a live without its table go as datagrams, bulk tun on a unidirectional stream, everything else on the control stream. A QUIC PING every 15 s stands in for the service's WebSocket ping and keeps the NAT's UDP mapping open; 45 s of silence ends the connection. The service's close codes read back as WebSocket closes. GET /api/cloud gains transport (quic or websocket). Tests name their own endpoint and get the WebSocket alone unless they ask for QUIC. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A reconnect resumes with the service's TLS ticket and sends the target as 0-RTT data, so the challenge comes back in the service's first flight: one round trip less before hello. A rejected early flight gets the target again on the connection quic-go hands over. The protocol's early-data rules are the ones the service now runs: each message 1 in early data answered once per ephemeral key, tickets that allow early data for a day, HTTP/3 waiting for the handshake. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s message 2 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…IC again Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t UDP At 5 % loss one lost QUIC handshake packet lost the race to the WebSocket and kept QUIC second on that network for a day. The losing QUIC dial now goes on for up to 3 s; if it opens, QUIC goes first next time. The uplink stays on the WebSocket that won. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 180f930b99
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if tc.ClientSessionCache != nil { | ||
| dial = tr.DialEarly | ||
| } | ||
| qc, err := dial(ctx, udp, tc, quicConfig()) |
There was a problem hiding this comment.
Preserve the hostname for QUIC certificate verification
For the production endpoint, addr is resolved to a *net.UDPAddr before this call while tlsConf.ServerName remains empty. quic.Transport.Dial therefore infers the TLS server name from the resolved numeric IP, so the certificate for cloud.ftw.energy fails hostname verification and every production QUIC attempt falls back to WebSocket. The tests miss this because the httptest certificate is valid for its loopback IP; set ServerName from the WebSocket endpoint's hostname before dialing, including when QUICAddr overrides the route.
Useful? React with 👍 / 👎.
The race's WebSocket and QUIC dials follow endpoint() to the shard that holds the home. The QUIC vectors take master's new roster fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- B1: a phone's session waits for the QUIC handshake. The protocol text now says the service acts on a phone's early message 1 only once the handshake is done, for the first copy too. - B2/S5: a QUIC uplink that ends before hello_ok, or that the path drops within QUICProvenAfter (60 s) of it, puts the WebSocket first on that network for a day, and no QUIC win moves QUIC back meanwhile. Closes from 1000 up and stateless resets do not count. The service offers only the ALPNs it serves. - S1: appwire's replay window is 1024 (16 words), since a bulk burst can overtake a control message by a few hundred. A datagram outside it is dropped; on a stream it ends the session. - S2: a late live whose srcRev is above the table held still gives its table and nothing else (View, Freshness case 17). - S7: cloud_transports come from the registry through gencontract. - The box keeps one TLS ticket cache per transport. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
quicdoor takes ftw-cloud-box/1 and ftw-cloud-app/1 beside h3 and hands each connection to the WebSocket's handler through wire.Conn: a control stream that starts with the target, a bulk stream each way for lane 1 tun, and DATAGRAMs for hb and a table-less live. wsclose tracks QUIC connections too, so the drain closes them with 4503. store.TunOut carries Bulk. Door.Close ends live sessions with 1001 on the way out. The go/protocol pin moves to srcfl/ftw#1653. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- S1: the Noise replay window is 1024 (16 words), as in srcfl/ftw, since a bulk burst can overtake a control message. CloudCarrier drops a replay only when it came as a datagram (WebSocketEvents.onDatagram); on a stream it ends the session. - B2/S5: a QUIC session that ends before its first message, or that the path drops within a minute of it, demotes QUIC on that network for a day, and no QUIC win moves it back meanwhile. Closes from 1000 up other than 1005 and 1006 do not count. CloudTransportMemory keeps only the last day's networks. - S2: CloudView takes the table of a late live whose srcRev is newer and keeps the newer values (Freshness case 17). - cloud-quic-vectors.json from srcfl/ftw#1653. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The replay window stays 1024 with #1649's note on lane 0 and paced bulk. The QUIC vectors take master's newest roster. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The replay window stays 1024 with main's note on paced bulk. The QUIC vectors come from srcfl/ftw#1653. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TestBulkTunTakesTheBulkStream asked that the lane 0 tun reach the service first. The box writes it first, but the two travel on two QUIC streams, which keep no order between them, and the fake service reads each on its own goroutine. CI saw [bulk, lane 0]: both on the right stream, in the other order. The test now pairs each tun with how it came and checks lane 0 on the control stream and bulk on the bulk stream. Passed 50 of 50 under -race. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
QUIC, steps 2 and 3: the uplink and the app session over QUIC on UDP 443, beside the WebSocket, with 0-RTT on reconnect. This PR has the protocol and the box's side, with
mastermerged in and the review's fixes (B1 in the text, B2 and S5 on the box, S1, S2, S7). The service is srcfl/ftw-cloud#22, the iPhone srcfl/ftw-app#74, and the registry name srcfl/ftw-webapp#91.Contract-pair: srcfl/ftw-webapp@claude/registry-cloud-transports
The protocol (
docs/protocol-cloud.md, "QUIC")ftw-cloud-box/1for the uplink,ftw-cloud-app/1for the app session,h3for the plain routes. The certificate is the same. TLS 1.3 inside QUIC carries the exporter, and the box bindshelloto it as over TCP./v1/box,/v1/app?home=). After that, each WebSocket message goes on the stream with its length as a QUIC varint in front.tunthat carries a lane 1 frame of the phone's session (snapshots, history) goes on one unidirectional stream each way. A lost bulk packet then never holds up a command, its answer or a tick.hb, andlivewithoutsources, go as QUIC DATAGRAMs. The freshness rules already show a lost one as a gap (hb.liveSeq), never as a live value. Alivethat carries its table goes on the stream, and a receiver that already holds a newerlivestill takes the late table when itssrcRevis above the one it holds, and nothing else: Freshness case 17, whichcloudwire.Viewruns.appwire.ReplayWindowis now 1024 (16 words), with feat(appuplink): send each reading through FTW Cloud as it lands #1649's note on paced bulk kept. A receiver drops a datagram outside the window; on a stream the same ends the session.challengefor a box, message 2 for a phone), or that the path drops within 60 s of it (cloudwire.QUICProvenAfter), demotes QUIC on that network for a day: the WebSocket goes first, and no QUIC win moves QUIC back meanwhile. Closes the service sends on purpose, from 1000 up, and stateless resets do not count.now.tun) go in it, so nocmdorapi.reqever can. A phone's session waits for the QUIC handshake, the first copy of an early flight too, so a flight the network dropped and replays later replaces nothing and spends nothing. A box sends only its target early, and itschallengemay come back before the handshake ends. Tickets allow early data for a day. See The uplink and the app session over QUIC, with 0-RTT a replay cannot use (QUIC steps 2–3) ftw-cloud#22'sTestADroppedEarlyFlightReplayedLaterChangesNothing.hbreached a phone before message 2. That was one failed reconnect in 30 under netem.go/protocol/cloudwire/quic.goholds the ALPNs, timings, varint framing and the datagram rule. The transport names come from the registry throughgencontract(S7:protocol.CloudTransports).testdata/cloud-quic-vectors.jsonholds the bytes, and the service and the iPhone replay them.The box (
go/internal/cloudlink)race.goracesdialQUICagainst today's WebSocket, both to the shardendpoint()names. Each network, named by the box's local address towards the service, remembers its winner for a day.quicFailedanddemotecarry out the rule above (TestAQUICSessionThatEndsBeforeHelloOKDemotesQUIC,TestWhatCountsAsQUICFailing).quic.gois the uplink over QUIC behind the WebSocket's method set (transport.go), soserve,readand the writers barely change:hband a table-lesslivego as datagrams;tungoes on the bulk stream;*websocket.CloseError, so the shard redirect's codes work over both.challengecomes back in the first flight. That is one round trip less beforehello. TLS over TCP and QUIC keep a ticket cache each.GET /api/cloudgainstransport:quicorwebsocket.Endpointget the WebSocket alone unless they setOptions.QUIC. So every existing test runs as before.Registry copy:
cloud_transports: [quic, websocket]from srcfl/ftw-webapp#91.Merge order: this PR first, then the service with its
go/protocolpin moved to the merge commit, then the iPhone. Nothing breaks if the service ships before the box: a box without QUIC uses the WebSocket, and the service keeps both.Numbers: today's WebSocket against QUIC
A real
ftwcloudd, a box running Core's owncloudlink,appuplinkand command handler, and a test phone in Go (go/protocolandquicdoor.Dial) that pairs with it and speaks the app protocol inside the tunnel. The WebSocket rows are today's path on both legs; the QUIC rows are QUIC on both. Everything runs in one Linux container whose loopback carries netem: 20 ms each way, so every leg has a 40 ms round trip, and the loss applies to each packet on both legs. The readable copy is on. 30 connects and 30 taps per row, 90 s of frames.The connect rows come from a run with the review's fixes in, where a phone's session waits for the QUIC handshake. The other rows come from the run before the fixes, which do not touch a session once it is open.
What it says: QUIC saves round trips where a connection starts, and it keeps loss on one stream from holding up the others. Cold, it is two round trips less: the TCP handshake and the WebSocket upgrade. A phone's reconnect now costs what a cold connect does, since its session waits for the handshake; 0-RTT still saves a box a round trip, whose
challengecomes back in the first flight. Under loss the tails shrink everywhere, and a network switch costs no new session. With no loss, a frame or a tap takes one round trip either way.The copy's
liveat 5 % loss is not a clean win. QUIC sends it as a datagram, never again, and lost 8 of the 90; the WebSocket lost none but brought its late ones up to 309 ms after. A lost one shows as a gap in the freshness rules (hb.liveSeq), never as a live value. Neither row measures the age of the newest value at the phone, which is what a person sees.now.tun), the box session's handshake andhellowith its subscription, to the snapshot.cmd.ack.live, from the box'swallMsto the phone. Over QUIC it goes as a datagram; the counts say how many of the 90 the box sent arrived.On the phone: FTWKit in the iOS simulator
LiveQUICTests(in srcfl/ftw-app#74) runs the app's own stack (AppModel,PairModel,CloudCarrier, the tunnel and the session) against a realftwclouddand a real Core box with the relay unreachable. It runs in an iPhone 17 simulator. The service and the box run in a container whose netem shapes only the phone's leg, 20 ms each way plus OrbStack's own few ms (ping 56–100 ms); the box reaches the cloud unshaped. The readable copy is off. Each row is one pairing, 30 taps and 6 returns from the background.The Mac's own
swift testgave the same at 40 ms: 305 against 180 ms from scan to stream, and 269 against 184 ms back from the background. In an earlier 5 % run the race gave one session to the WebSocket, because one lost QUIC packet made QUIC miss its 250 ms lead. A QUIC dial that loses now goes on to learn, so that one loss no longer keeps QUIC second for a day.Keeping an idle box linked
The box uplink stayed idle for 180 s with the readable copy off, at 40 ms, counted packet by packet on the loopback (IP bytes):
In the first two minutes, both ends also send path MTU probes of about 1.4 KB beside each keepalive. Over the 180 s window that came to 10 KB, a rate of 4.9 MB a day that stops once discovery ends. A PING every 15 s keeps a 30 s NAT mapping open.
Not checked
The rig is not in any repository: the box as a test binary in Core's
appuplink, a phone in Go overgo/protocolandquicdoor.Dial,run.sh, and netem in an Alpine container on OrbStack. Landing it as a check is a follow-up.Checks
go/protocol(go test ./...), andcloudlink,appuplink,appprotoin Core: pass after the merges. The window test compares 3,000 shuffled frames against a plain record and fails when the carry between words is removed.🤖 Generated with Claude Code