diff --git a/quest/m1/README.md b/quest/m1/README.md
index f1b3b628953..9ba228f55de 100644
--- a/quest/m1/README.md
+++ b/quest/m1/README.md
@@ -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
diff --git a/quest/m1/tokio-transport-feature.md b/quest/m1/tokio-transport-feature.md
deleted file mode 100644
index 5c81e1fc615..00000000000
--- a/quest/m1/tokio-transport-feature.md
+++ /dev/null
@@ -1,37 +0,0 @@
-# [S] moq-tokio: no dead code without a transport
-
-## Goal
-
-`cargo clippy -p moq-tokio --no-default-features -- -D warnings` passes, and so
-does each single-feature build, so the configurations `just rs tokio-features`
-compiles are held to the same bar as the default one.
-
-## Plan
-
-The backend-less build compiles with 11 warnings, every one an item whose only
-callers sit behind a transport gate:
-
-- unused imports `Member` and `Shard` (rs/moq-tokio/src/listen.rs:150)
-- `Client::timeout` never read (client.rs:75)
-- `listen::Config::validate` (listen.rs:305)
-- `quic::Config::validate` (quic.rs:450), `MAX_IDLE_TIMEOUT` (:488),
- `validate_idle_timeout` (:494), `MAX_VARINT` (:503), `validate_windows`
- (:511)
-- `tls::Peers::contains_raw` (tls.rs:395), `tls::CustomRoots::load` (:657),
- `tls::Certificates::empty` (:1602)
-
-Gating each by hand would spell the six-way "has a transport" `any(...)` in
-several more places, which is what makes this its own change rather than a
-follow-on edit. Give the crate a private `_transport` feature, the way `_certs`
-already covers the serving side, enabled from `noq`, `quinn`, `quiche`, `iroh`,
-`websocket`, and `tcp`. Collapse onto it only the gates that spell exactly that
-set: `lib.rs:57` and `:91`, and `client.rs:110` and `:126`. The narrower gates
-stay as they are, because they mean something else: `client.rs:63` excludes
-`iroh` on purpose, and `server.rs:21` excludes `tcp`/`uds`. `server::Parts`
-already carries targeted `expect(dead_code)` attributes (server.rs:120-134)
-and needs nothing.
-
-Then swap `cargo check` for `clippy -- -D warnings` in `just rs tokio-features`
-(rs/justfile:401-428) so the bar holds once it is met. Leave the loop at :419
-alone: it deliberately expects `quinn`/`noq` without a crypto provider to fail
-the build, and asserts on the error text.
diff --git a/rs/justfile b/rs/justfile
index b9102ecf962..2d8e7f54d93 100644
--- a/rs/justfile
+++ b/rs/justfile
@@ -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'
diff --git a/rs/moq-tokio/Cargo.toml b/rs/moq-tokio/Cargo.toml
index 3bc4ce13028..01b9599da3f 100644
--- a/rs/moq-tokio/Cargo.toml
+++ b/rs/moq-tokio/Cargo.toml
@@ -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 = []
# Filesystem watcher for hot-reloading on-disk TLS certs, keys, and root CAs.
watch = ["dep:notify"]
# Capture qlog traces (`--*-quic-qlog
`). Off by default: quinn and noq pull in
@@ -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"]
diff --git a/rs/moq-tokio/src/client.rs b/rs/moq-tokio/src/client.rs
index b88ae495aa8..57a445bc45b 100644
--- a/rs/moq-tokio/src/client.rs
+++ b/rs/moq-tokio/src/client.rs
@@ -72,6 +72,7 @@ pub struct Client {
/// The URL from [`connect.url`](crate::connect::Config::url), dialed by [`Client::publish`] / [`Client::consume`].
connect: Option,
/// 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,
@@ -107,15 +108,7 @@ 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 {
Err(Error::NoBackend(
"no backend compiled; enable noq, quinn, quiche, iroh, websocket, tcp, or uds feature",
@@ -123,15 +116,7 @@ impl Client {
}
/// 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 {
let Config {
connect: config, quic, ..
diff --git a/rs/moq-tokio/src/lib.rs b/rs/moq-tokio/src/lib.rs
index a9b9805a545..9239c2885be 100644
--- a/rs/moq-tokio/src/lib.rs
+++ b/rs/moq-tokio/src/lib.rs
@@ -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;
@@ -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.
diff --git a/rs/moq-tokio/src/listen.rs b/rs/moq-tokio/src/listen.rs
index 0122414290c..b8a1aa11b1c 100644
--- a/rs/moq-tokio/src/listen.rs
+++ b/rs/moq-tokio/src/listen.rs
@@ -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`.
///
@@ -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),
@@ -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"]);
diff --git a/rs/moq-tokio/src/quic.rs b/rs/moq-tokio/src/quic.rs
index 6f221c5c271..952841edc5c 100644
--- a/rs/moq-tokio/src/quic.rs
+++ b/rs/moq-tokio/src/quic.rs
@@ -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.
@@ -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) -> crate::Result<()> {
match idle_timeout {
Some(timeout) if timeout > MAX_IDLE_TIMEOUT => Err(crate::Error::IdleTimeoutRange),
@@ -524,6 +527,7 @@ fn validate_idle_timeout(idle_timeout: Option) -> 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.
@@ -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),
@@ -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();
@@ -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 {
@@ -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 [
@@ -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 {
diff --git a/rs/moq-tokio/src/server.rs b/rs/moq-tokio/src/server.rs
index 351d2b811d5..90292cee5cb 100644
--- a/rs/moq-tokio/src/server.rs
+++ b/rs/moq-tokio/src/server.rs
@@ -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),
}
diff --git a/rs/moq-tokio/src/tls.rs b/rs/moq-tokio/src/tls.rs
index 862ea27ccfc..473b63e892e 100644
--- a/rs/moq-tokio/src/tls.rs
+++ b/rs/moq-tokio/src/tls.rs
@@ -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),
@@ -673,6 +674,7 @@ impl CustomRoots {
})
}
+ #[cfg(any(feature = "watch", feature = "quiche"))]
fn load(&self) -> Result>> {
read_roots(&self.paths)
}
@@ -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())),