Skip to content

moq-native: advertise QUIC preferred_address in the server config#1512

Merged
kixelated merged 1 commit into
mainfrom
claude/awesome-diffie-642dd2
May 26, 2026
Merged

moq-native: advertise QUIC preferred_address in the server config#1512
kixelated merged 1 commit into
mainfrom
claude/awesome-diffie-642dd2

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

Summary

  • Adds preferred_v4: Option<SocketAddrV4> and preferred_v6: Option<SocketAddrV6> to moq_native::ServerConfig, exposed via CLI (--server-preferred-v{4,6}), env (MOQ_SERVER_PREFERRED_V{4,6}), and TOML ([server] preferred_v{4,6} = "...").
  • Plumbs both into quinn::ServerConfig::preferred_address_v{4,6} inside QuinnServer::new. Quinn handles CID allocation, reset-token generation, and transport-parameter packing.
  • Adds a cli_does_not_clobber_toml_preferred_addresses regression test in rs/moq-relay/src/config.rs to guard the TOML-to-CLI merge behavior documented in CLAUDE.md.

Why

The QUIC preferred_address transport parameter (RFC 9000 §9.6) lets a server advertise an alternate address that the client migrates to shortly after the handshake. This unlocks a clean BGP anycast deployment shape:

  • Every instance announces a shared anycast /24 (handshake target).
  • Each instance advertises its own per-host unicast IP as preferred_address.
  • New clients route via anycast to the nearest POP; steady-state connections pin to the unicast IP and survive BGP reconvergence.
  • An overloaded host can withdraw the anycast route from BGP without dropping its existing connections, because they are no longer using that address.

Supporting clients today: Chrome M131+ (on by default since November 2024, ~99% migration success per Google's measurements) and any native Quinn client (moq-cli, moq-ffi-based iOS/Android/Swift/Kotlin). Firefox via neqo has the implementation but I could not confirm the glue layer wires it through; Safari has no public confirmation.

Out of scope

  • Documentation for the deployment pattern (Vultr / OCI BYOIP / BIRD config) lives in a follow-up PR.
  • noq and quiche backends do not expose this API. If either field is set, those backends will silently ignore it. Same shape as the existing tls.root (mTLS) flag, which is also Quinn-only.
  • Client-side happy-eyeballs and Windows server dual-stack are separate concerns.

Test plan

  • just check passes (clippy, tests, docs, shear, sort, remark).
  • New regression test cli_does_not_clobber_toml_preferred_addresses passes.
  • Manual smoke (optional, reviewer may skip): run moq-relay --server-bind '[::]:4443' --server-preferred-v4 127.0.0.2:4444 against a loopback alias, connect with moq-cli, capture with tshark -d udp.port==4443,quic -V and confirm the handshake transport parameters contain the preferred address and the client sends a PATH_CHALLENGE to it.

(Written by Claude)

Expose preferred_v4 and preferred_v6 on ServerConfig and plumb them into
quinn::ServerConfig::preferred_address_v{4,6}. Lets deployments handshake
on an anycast IP and migrate clients to a per-host unicast IP, so existing
connections survive BGP reconvergence and an overloaded host can withdraw
the anycast route without dropping anyone. Only the Quinn backend honors
the parameter; supporting clients today are Chrome M131+ and native Quinn.

Both fields are Option-typed so the TOML to CLI merge in moq-relay does
not clobber a TOML-configured value with Default::default() when the flag
is absent. New regression test in rs/moq-relay/src/config.rs guards that.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 92a97c39-52d8-47ca-8ae5-c05abc00943c

📥 Commits

Reviewing files that changed from the base of the PR and between 1430897 and ef5568d.

📒 Files selected for processing (3)
  • rs/moq-native/src/quinn.rs
  • rs/moq-native/src/server.rs
  • rs/moq-relay/src/config.rs

Walkthrough

This PR adds support for configuring QUIC's preferred_address transport parameter (RFC 9000 §9.6). Two new optional fields—preferred_v4 and preferred_v6—are added to ServerConfig, accepting IPv4/IPv6 socket addresses via CLI flags and environment variables. The Quinn backend conditionally sets these addresses in the QUIC transport parameters during server initialization. A regression test ensures that TOML-configured addresses are not overwritten by the configuration merge process when environment variables are absent.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: adding support for advertising QUIC preferred_address in the server configuration.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the motivation, implementation details, scope, and test plan.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch claude/awesome-diffie-642dd2

Warning

Review ran into problems

🔥 Problems

Stopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a @coderabbit review after the pipeline has finished.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@kixelated kixelated merged commit 173618b into main May 26, 2026
1 check passed
@kixelated kixelated deleted the claude/awesome-diffie-642dd2 branch May 26, 2026 17:20
This was referenced May 26, 2026
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.

1 participant