Skip to content

spike(proxy): CONNECT-UDP (RFC 9298) capability in fleet-proxy, default off (#6109) - #6114

Merged
dezren39 merged 1 commit into
mainfrom
spike/connect-udp-6109
Nov 5, 2026
Merged

dezren39 merged 1 commit into
mainfrom
spike/connect-udp-6109

Conversation

@dezren39

@dezren39 dezren39 commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Spike for #6109. Capability only — no cutover. Drew's call (2026-11-05): spike CONNECT-UDP so the capability exists at minimum; enabling it anywhere needs his separate word. The #5924 verdict (Moonlight streaming = tailnet-direct) is unchanged.

Step-0 finding: who owns CONNECT in the path

The only HTTP CONNECT proxy server in the sandbox→laptop path is the Muse runtime's egress proxy (hatch-egress-proxy:3130, named by $HTTPS_PROXY) — not ours to modify. Our components are CONNECT clients: fleet-proxy's broker pools CONNECT tunnels through that runtime proxy (tunnel.rs module doc), and proxy-supervisor's relay CONNECTs through it too. So the spike lands in our fleet proxy component, pkgs/fleet/crates/fleet-proxy, built so fleet traffic could terminate at our own code later.

What this adds

  • crates/fleet-proxy/src/connect_udp.rs (new, behind the existing serve feature): an RFC 9298 CONNECT-UDP endpoint — CONNECT-UDP /.well-known/masque/udp/{host}/{port}/ + Capsule-Protocol: ?1, RFC 9297 capsule framing, context ID 0 (raw UDP payload), one connected UDP socket per session (only the target's packets relay back), 120 s idle close. Two behaviors pinned by tests because they decide whether a media target survives real life: a target's ICMP port-unreachable is treated as UDP weather, not session death (a restarting target finds the relay still standing), and unknown capsules are skipped per RFC 9297.
  • Config gate (fleet-config): [proxy] connect_udp (default false) and connect_udp_listen (default 127.0.0.1:3131, loopback). fleet proxy serve spawns the listener only when enabled; a bind failure logs and the broker carries on. With the flag off — every current config — the broker is byte-for-byte the old behavior.
  • examples/connect_udp_proof.rs: the burst-proof harness (below).
  • A minimal UdpProxyClient (+ split sender/receiver halves) exists to prove the server half; it is test tooling, not a product client.

No target allowlist, deliberately: the listener is loopback-only and off by default, the broker's own trust posture. A cutover that binds it wider owes an explicit target policy — stated in the module doc so the gap is a decision on record.

Carrier: HTTP/1.1 + capsules (TCP), and what that costs

The crate is hand-rolled std-only Rust with a hand-rolled HTTP/1.1 stack; HTTP/3 + QUIC DATAGRAM would mean importing a QUIC stack this component deliberately doesn't carry. So the spike carrier is RFC 9298 over HTTP/1.1: datagrams ride the TCP connection. That inherits TCP ordering/head-of-line blocking — on a lossy wire, loss becomes retransmit latency instead of drops. It is the wrong trade for media and the right trade for a capability proof. The media carrier (H3 + QUIC DATAGRAM, unreliable, no HoL) is follow-up work if cutover is ever called for.

Proof (acceptance gate)

cargo test -p fleet-config -p fleet-proxy-proto -p fleet-proxy: 14 + 42 + 10 passed — the full existing broker/tunnel/http suites are the TCP-CONNECT regression gate, plus new tests (varint/capsule codecs, split-feed parsing, refusal handshakes, windowed 300×1200 B relay burst, dead-target session survival). Connect-only variant (--no-default-features) also compiles.

Burst proof, cargo run -p fleet-proxy --example connect_udp_proof — 1200-byte datagrams at ~90/s for 30 s (2700 datagrams each way) to a loopback UDP echo, two runs, debug build:

run path loss RTT p50 p95 p99 max
1 direct UDP 0.000% 0.12 ms 0.42 ms 3.08 ms 7.48 ms
1 via proxy 0.000% 0.24 ms 1.72 ms 4.18 ms 16.94 ms
2 direct UDP 0.000% 0.13 ms 0.20 ms 1.19 ms 5.76 ms
2 via proxy 0.000% 0.21 ms 0.31 ms 0.77 ms 11.15 ms

Added latency at p50: +0.08…0.12 ms. Caveat, stated plainly: loopback is the flattering environment for a TCP carrier — no wire loss exists to convert into HoL stalls. These numbers prove the relay is correct and cheap; they do not prove the TCP carrier is media-grade on a real network. That proof belongs to the H3 follow-up, if any.

How a real client would use it later (the remaining cutover work)

  1. A client shim. Moonlight has no native CONNECT-UDP. Cutover needs a small forwarder on the client device: listen on the Moonlight UDP ports locally, wrap each datagram in a CONNECT-UDP session to the proxy, unwrap replies. (The crate's UdpProxyClient proves the protocol half; the shim is the product half.)
  2. Placement + reach. A proxy instance where the shim can reach it and it can reach the Sunshine host — e.g. fleet proxy serve on the laptop with [proxy] connect_udp = true, reached over the tailnet. Note this only becomes interesting if a future topology has a hop the tailnet can't do directly; today tailnet-direct already wins, which is why this is capability, not cutover.
  3. Target policy for any non-loopback bind (see above).
  4. Carrier upgrade to HTTP/3 + QUIC DATAGRAM if the stream is ever to ride it for real.

What is explicitly NOT done

Closes #6109 (the spike ask; cutover remains a separate, unstarted decision).


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 5, 2026 07:15
@coderabbitai

coderabbitai Bot commented Nov 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 40 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7e04af76-c39f-4657-86d0-f0ceabf6c070
Commits

Reviewing files that changed from the base of the PR and between c4783fb and a82d3ed.

Files selected for processing: 5

  • pkgs/fleet/crates/fleet-config/src/lib.rs
  • pkgs/fleet/crates/fleet-proxy/examples/connect_udp_proof.rs
  • pkgs/fleet/crates/fleet-proxy/src/connect_udp.rs
  • pkgs/fleet/crates/fleet-proxy/src/lib.rs
  • pkgs/fleet/crates/fleet-proxy/src/serve.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T07:16:39.901786Z a82d3ed PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

spike(proxy): CONNECT-UDP (RFC 9298) capability in fleet-proxy — capability only, no cutover

1 participant