Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion quest/m1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,4 @@ quest here and merged main into dev.
- [LAN discovery app id](/quest/m1/lan-app.md) - every advertisement names an application as a DNS-SD subtype bound into the proofs, so unrelated apps on one network never meet
- [One LAN mesh](/quest/m1/lan-mesh.md) - moq-cli drives the relay's Cluster, LAN peers authenticate by mDNS credential, and the two binaries mesh with each other
- [Native Go context](/quest/m1/go-native-context.md) - the Go generator emits context.Context itself, retiring the hand-rolled cancellation token
- [Transport feature](/quest/m1/tokio-transport-feature.md) - moq-tokio has one `_transport` gate and its backend-less build passes `-D warnings`
- [Merge dev](/quest/m1/merge-dev.md) - dev lands on main with a closing keyword for every issue it fixed
37 changes: 0 additions & 37 deletions quest/m1/tokio-transport-feature.md

This file was deleted.

16 changes: 8 additions & 8 deletions rs/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -388,16 +388,16 @@ tokio-features:
#!/usr/bin/env bash
set -euo pipefail

cargo check --locked -p moq-tokio --no-default-features
cargo check --locked -p moq-tokio --all-features
cargo check --locked -p moq-tokio --no-default-features --features quiche
cargo check --locked -p moq-tokio --no-default-features --features quinn,aws-lc-rs
cargo check --locked -p moq-tokio --no-default-features --features quinn,ring
cargo check --locked -p moq-tokio --no-default-features --features noq,aws-lc-rs
cargo check --locked -p moq-tokio --no-default-features --features noq,ring
cargo clippy --locked -p moq-tokio --no-default-features -- -D warnings
cargo clippy --locked -p moq-tokio --all-features -- -D warnings
cargo clippy --locked -p moq-tokio --no-default-features --features quiche -- -D warnings
cargo clippy --locked -p moq-tokio --no-default-features --features quinn,aws-lc-rs -- -D warnings
cargo clippy --locked -p moq-tokio --no-default-features --features quinn,ring -- -D warnings
cargo clippy --locked -p moq-tokio --no-default-features --features noq,aws-lc-rs -- -D warnings
cargo clippy --locked -p moq-tokio --no-default-features --features noq,ring -- -D warnings

for feature in aws-lc-rs ring tcp uds websocket; do
cargo check --locked -p moq-tokio --no-default-features --features "$feature"
cargo clippy --locked -p moq-tokio --no-default-features --features "$feature" -- -D warnings
done

want='a rustls QUIC backend requires a crypto provider: enable either the `aws-lc-rs` or `ring` feature'
Expand Down
15 changes: 9 additions & 6 deletions rs/moq-tokio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@ categories = ["multimedia", "network-programming", "web-programming"]

[features]
default = ["noq", "aws-lc-rs", "websocket", "tcp", "uds"]
quinn = ["_certs", "dep:quinn", "dep:web-transport-quinn", "dep:reqwest", "watch", "dep:dns-lookup"]
noq = ["_certs", "dep:web-transport-noq", "dep:reqwest", "watch", "dep:dns-lookup"]
quiche = ["_certs", "dep:web-transport-quiche", "dep:reqwest", "dep:rustls-native-certs", "dep:dns-lookup", "watch"]
quinn = ["_transport", "_certs", "dep:quinn", "dep:web-transport-quinn", "dep:reqwest", "watch", "dep:dns-lookup"]
noq = ["_transport", "_certs", "dep:web-transport-noq", "dep:reqwest", "watch", "dep:dns-lookup"]
quiche = ["_transport", "_certs", "dep:web-transport-quiche", "dep:reqwest", "dep:rustls-native-certs", "dep:dns-lookup", "watch"]
# Server-side certificate handling: chains loaded from disk, self-signed generation,
# in-memory identities, and per-SNI selection. Not one to enable on its own, since
# nothing turns it into a listener: every QUIC backend needs it for its own TLS, and
# so does the plain-TLS `tls::Listen::server_config` an RTMPS or HTTPS listener builds,
# which is why the crypto-provider features below turn it on too.
_certs = ["dep:rcgen", "dep:rustls-webpki"]
# Private "any transport is compiled" marker. Not one to enable on its own: every
# backend that can move bytes turns it on, and `uds` reaches it through `tcp`.
_transport = []

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject _transport without an actual backend

Cargo exposes _transport to downstream crates despite the “private” naming convention, so default-features = false, features = ["_transport"] is a valid configuration. In that configuration Client::new selects the successful constructor and the crate exports Server, but no real transport is compiled; dialing only fails later, while a default server can be constructed with an empty listener set. Preserve the concrete-backend predicate for these behaviors or reject the marker-only combination at compile time so unsupported configurations fail immediately.

AGENTS.md reference: AGENTS.md:L44-L47

Useful? React with 👍 / 👎.

# Filesystem watcher for hot-reloading on-disk TLS certs, keys, and root CAs.
watch = ["dep:notify"]
# Capture qlog traces (`--*-quic-qlog <DIR>`). Off by default: quinn and noq pull in
Expand All @@ -43,13 +46,13 @@ aws-lc-rs = [
"web-transport-noq?/aws-lc-rs",
"web-transport-quinn?/aws-lc-rs",
]
iroh = ["dep:web-transport-iroh", "dep:web-transport-proto", "dep:noq-proto"]
iroh = ["_transport", "dep:web-transport-iroh", "dep:web-transport-proto", "dep:noq-proto"]
# LAN peer discovery over mDNS (the `mdns` module).
mdns = ["dep:mdns-sd", "dep:hmac", "dep:sha2", "dep:subtle"]
jemalloc = ["dep:tikv-jemallocator", "dep:tikv-jemalloc-ctl"]
websocket = ["dep:qmux", "watch", "dep:dns-lookup"]
websocket = ["_transport", "dep:qmux", "watch", "dep:dns-lookup"]
# Plain-TCP qmux transport (`tcp://`), no TLS. Server-side and client-side.
tcp = ["dep:qmux", "dep:dns-lookup"]
tcp = ["_transport", "dep:qmux", "dep:dns-lookup"]
# Unix-domain-socket qmux transport (`unix://`), unix-only. Adds peer-credential
# inspection on accept. Pulls in `tcp` (shares qmux's stream transport).
uds = ["tcp", "qmux/uds"]
Expand Down
21 changes: 3 additions & 18 deletions rs/moq-tokio/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pub struct Client {
/// The URL from [`connect.url`](crate::connect::Config::url), dialed by [`Client::publish`] / [`Client::consume`].
connect: Option<Url>,
/// Deadline for one [`Client::connect`], from [`crate::connect::Config::timeout`]. Zero waits forever.
#[cfg(feature = "_transport")]
timeout: std::time::Duration,
pub(crate) reconnect: bool,
pub(crate) backoff: Backoff,
Expand Down Expand Up @@ -107,31 +108,15 @@ impl Client {
/// Build a client from its config.
///
/// Errors if no transport feature is compiled in.
#[cfg(not(any(
feature = "noq",
feature = "quinn",
feature = "quiche",
feature = "iroh",
feature = "websocket",
feature = "tcp",
feature = "uds"
)))]
#[cfg(not(feature = "_transport"))]
pub fn new(_config: Config) -> crate::Result<Self> {
Err(Error::NoBackend(
"no backend compiled; enable noq, quinn, quiche, iroh, websocket, tcp, or uds feature",
))
}

/// Build a client from its config, binding the QUIC socket up front.
#[cfg(any(
feature = "noq",
feature = "quinn",
feature = "quiche",
feature = "iroh",
feature = "websocket",
feature = "tcp",
feature = "uds"
))]
#[cfg(feature = "_transport")]
pub fn new(config: Config) -> crate::Result<Self> {
let Config {
connect: config, quic, ..
Expand Down
18 changes: 2 additions & 16 deletions rs/moq-tokio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,7 @@ pub mod quinn;
))]
mod resolve;
pub mod runtime;
#[cfg(any(
feature = "noq",
feature = "quinn",
feature = "quiche",
feature = "iroh",
feature = "websocket",
feature = "tcp"
))]
#[cfg(feature = "_transport")]
pub mod server;
#[doc(hidden)]
pub mod settings;
Expand Down Expand Up @@ -102,14 +95,7 @@ pub use deprecated::Deprecated;
pub use duration::Duration;
pub use error::{Error, Result};
pub use log::{Log, RedactedUrl};
#[cfg(any(
feature = "noq",
feature = "quinn",
feature = "quiche",
feature = "iroh",
feature = "websocket",
feature = "tcp"
))]
#[cfg(feature = "_transport")]
pub use server::{Listener, Request, Server, Transport};

// Re-export these crates.
Expand Down
7 changes: 6 additions & 1 deletion rs/moq-tokio/src/listen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ impl Config {
/// Crate-private on purpose: [`crate::worker::Workers`] is the only thing that
/// forms a group here, and a member a caller could mint for itself would bind
/// outside one.
pub(crate) use moq_sock::shard::{Member, Shard};
#[cfg(feature = "_transport")]
pub(crate) use moq_sock::shard::Member;
#[cfg(any(feature = "noq", feature = "quinn"))]
pub(crate) use moq_sock::shard::Shard;

/// The `--server-*` flags from before the accept side was named `listen`.
///
Expand Down Expand Up @@ -326,6 +329,7 @@ impl Config {
///
/// Checked here rather than with Usage's `requires`, which can only name one arg
/// id, and the nonce reaches this config from a TOML file as well as the flag.
#[cfg(feature = "_transport")]
pub(crate) fn validate(&self) -> crate::Result<()> {
match (self.lb_id.is_some(), self.lb_nonce.is_some()) {
(false, true) => Err(crate::Error::LbNonceWithoutId),
Expand Down Expand Up @@ -416,6 +420,7 @@ mod tests {

/// A nonce with no server id is meaningless. Checked here rather than with a
/// Usage `requires`, which can only name one arg id and never sees a TOML file.
#[cfg(feature = "_transport")]
#[test]
fn lb_nonce_needs_an_id() {
let config = config_from(["test", "--listen-quic-lb-nonce", "8"]);
Expand Down
9 changes: 9 additions & 0 deletions rs/moq-tokio/src/quic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ impl Config {
}

/// Reject knobs this build can't honor. Called when the endpoint is built.
#[cfg(feature = "_transport")]
pub(crate) fn validate(&self) -> crate::Result<()> {
// Erroring beats silently ignoring the flag: the operator asked for traces and
// would otherwise go looking for files that were never going to appear.
Expand Down Expand Up @@ -509,12 +510,14 @@ impl Config {

/// QUIC carries `max_idle_timeout` as a varint of milliseconds, so anything past this
/// can't go on the wire.
#[cfg(feature = "_transport")]
const MAX_IDLE_TIMEOUT: Duration = Duration::from_millis((1 << 62) - 1);

/// Reject an idle timeout no QUIC connection can express.
///
/// Checked here rather than in each backend because the conversion the backends do is
/// infallible-by-panic, and this config reaches them from a TOML file or a C caller.
#[cfg(feature = "_transport")]
fn validate_idle_timeout(idle_timeout: Option<Duration>) -> crate::Result<()> {
match idle_timeout {
Some(timeout) if timeout > MAX_IDLE_TIMEOUT => Err(crate::Error::IdleTimeoutRange),
Expand All @@ -524,6 +527,7 @@ fn validate_idle_timeout(idle_timeout: Option<Duration>) -> crate::Result<()> {

/// The largest value a QUIC varint can carry, which bounds every flow-control
/// limit that goes on the wire as a transport parameter.
#[cfg(feature = "_transport")]
const MAX_VARINT: u64 = (1 << 62) - 1;

/// Reject a flow-control window no connection can honor.
Expand All @@ -532,6 +536,7 @@ const MAX_VARINT: u64 = (1 << 62) - 1;
/// the connection rather than tighten it. The receive windows additionally have to
/// fit a varint, since they are sent as transport parameters; the send window is
/// local bookkeeping and only has to be non-zero.
#[cfg(feature = "_transport")]
fn validate_windows(quic: &Config) -> crate::Result<()> {
for (name, window, wire) in [
("receive_window", quic.receive_window, true),
Expand Down Expand Up @@ -781,6 +786,7 @@ mod tests {

/// A build that can't capture must reject the flag rather than ignore it, so an
/// operator isn't left waiting on trace files that will never appear.
#[cfg(feature = "_transport")]
#[test]
fn qlog_requires_the_feature() {
let unset = Config::default().validate();
Expand All @@ -800,6 +806,7 @@ mod tests {

/// The backends convert this duration with an infallible-by-panic `expect`, and the
/// value arrives from a TOML file or a C caller, so validation has to catch it here.
#[cfg(feature = "_transport")]
#[test]
fn idle_timeout_beyond_the_varint_is_rejected() {
let over = Config {
Expand Down Expand Up @@ -844,6 +851,7 @@ mod tests {

/// A zero window credits nothing, so it would wedge the connection rather than
/// tighten it. Reject it here, where the message can name the knob.
#[cfg(feature = "_transport")]
#[test]
fn zero_windows_are_rejected() {
for (name, config) in [
Expand Down Expand Up @@ -876,6 +884,7 @@ mod tests {

/// The receive windows go on the wire as transport parameters, so they have to fit
/// a varint. The send window is local bookkeeping and does not.
#[cfg(feature = "_transport")]
#[test]
fn receive_windows_must_fit_a_varint() {
let over = Config {
Expand Down
4 changes: 4 additions & 0 deletions rs/moq-tokio/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ pub(crate) enum Parts {
/// The QUIC listener only, as one member of a `SO_REUSEPORT` group. Folding
/// the member in here is what stops a group member and a stream-only server
/// from being asked for at once.
#[cfg_attr(
not(any(feature = "noq", feature = "quinn", feature = "quiche")),
expect(dead_code, reason = "no QUIC backend is compiled in")
)]
Member(crate::listen::Member),
}

Expand Down
3 changes: 3 additions & 0 deletions rs/moq-tokio/src/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ impl Peers {
}

/// Whether a raw digest is allowed, for the verifier's hot path.
#[cfg(feature = "_certs")]
fn contains_raw(&self, fingerprint: &[u8]) -> bool {
match <[u8; 32]>::try_from(fingerprint) {
Ok(fingerprint) => self.read().contains(&fingerprint),
Expand Down Expand Up @@ -673,6 +674,7 @@ impl CustomRoots {
})
}

#[cfg(any(feature = "watch", feature = "quiche"))]
fn load(&self) -> Result<Vec<CertificateDer<'static>>> {
read_roots(&self.paths)
}
Expand Down Expand Up @@ -1649,6 +1651,7 @@ impl Certificates {
}

/// An empty set, used when no TLS-bearing backend is configured.
#[cfg(feature = "_transport")]
pub(crate) fn empty() -> Self {
Self {
info: Arc::new(RwLock::new(Info::default())),
Expand Down
Loading