From aa354207f6e5b51b28dc434e4112b79cec8922d3 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 15 Nov 2026 06:53:39 -0800 Subject: [PATCH 1/7] chore(quest): claim quest/m2/features-network.md Quest-Claim: e457a6dae49260ad From 9fcdf8be585424f14a9563e8c9866ff73a8d21bd Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 15 Nov 2026 07:25:01 -0800 Subject: [PATCH 2/7] feat(moq-tokio,moq-relay,qmux)!: always compile the network stack Every transport, LAN discovery, and the relay's io_uring runtime compile into every build, picked at runtime by URL scheme, flag, or config. Unix sockets gate on cfg(unix) and io_uring on Linux. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/nightly.yml | 5 +- .oss-scanner/Dockerfile | 5 +- .oss-scanner/threat_model.md | 2 +- Cargo.lock | 1 - bench/metadata.py | 4 +- bench/run.sh | 11 +- doc/bin/cli.md | 2 +- doc/bin/relay/config.md | 6 +- doc/lib/rs/index.md | 2 +- nix/Cargo.nix | 283 +--------- quest/m2/features-leaf-trims.md | 5 - quest/m2/features-network.md | 68 --- quest/m2/features-qlog.md | 6 - quest/m3/release/feature-flags.md | 3 +- rs/hang/Cargo.toml | 2 +- rs/justfile | 32 +- rs/moq-bench/Cargo.toml | 9 +- rs/moq-boy/Cargo.toml | 5 +- rs/moq-c/Cargo.toml | 2 +- rs/moq-cli/Cargo.toml | 14 +- rs/moq-cli/src/args.rs | 30 +- rs/moq-ffi/Cargo.toml | 2 +- rs/moq-gst/Cargo.toml | 2 +- rs/moq-hls/Cargo.toml | 2 +- rs/moq-relay/Cargo.toml | 44 +- rs/moq-relay/src/auth.rs | 2 +- rs/moq-relay/src/auth/caps.rs | 1 - rs/moq-relay/src/cluster.rs | 79 +-- rs/moq-relay/src/config.rs | 47 +- rs/moq-relay/src/handoff.rs | 5 +- rs/moq-relay/src/incoming.rs | 4 +- rs/moq-relay/src/internal.rs | 46 +- rs/moq-relay/src/lib.rs | 3 +- rs/moq-relay/src/listener.rs | 3 +- rs/moq-relay/src/listener/idle.rs | 1 - rs/moq-relay/src/relay.rs | 92 +--- rs/moq-relay/src/shutdown.rs | 1 - rs/moq-relay/src/stats.rs | 3 - rs/moq-relay/src/web.rs | 35 +- rs/moq-relay/tests/drills.rs | 1 - .../tests/integration/auth_lifetime.rs | 36 +- .../tests/integration/bitrate_caps.rs | 7 +- .../tests/integration/cluster_close.rs | 2 - .../tests/integration/cluster_fresh_port.rs | 6 +- .../tests/integration/cluster_idle.rs | 6 +- rs/moq-relay/tests/integration/embed.rs | 8 +- rs/moq-relay/tests/integration/handoff.rs | 10 +- rs/moq-relay/tests/integration/lan_mesh.rs | 2 - rs/moq-relay/tests/integration/logs.rs | 4 - rs/moq-relay/tests/integration/main.rs | 2 +- rs/moq-relay/tests/integration/peer_limits.rs | 3 +- .../tests/integration/public_rules.rs | 2 - rs/moq-relay/tests/integration/refusals.rs | 9 +- .../tests/integration/released_cli.rs | 10 +- .../tests/integration/runtime_uring.rs | 5 +- .../tests/integration/runtime_workers.rs | 5 +- .../tests/integration/session_revalidate.rs | 7 +- rs/moq-relay/tests/integration/smoke.rs | 22 +- rs/moq-relay/tests/integration/stack.rs | 2 +- .../tests/integration/tenant_matrix.rs | 4 +- rs/moq-relay/tests/integration/wire_stats.rs | 3 +- rs/moq-rtmp/Cargo.toml | 6 +- rs/moq-tokio/Cargo.toml | 99 +--- rs/moq-tokio/README.md | 3 +- rs/moq-tokio/benches/fanout.rs | 6 - rs/moq-tokio/src/abort.rs | 8 - rs/moq-tokio/src/client.rs | 146 +---- rs/moq-tokio/src/connect.rs | 6 +- rs/moq-tokio/src/connection.rs | 74 +-- rs/moq-tokio/src/error.rs | 42 +- rs/moq-tokio/src/lib.rs | 57 +- rs/moq-tokio/src/listen.rs | 37 +- rs/moq-tokio/src/quic.rs | 33 +- rs/moq-tokio/src/quic/backend.rs | 1 - rs/moq-tokio/src/quic/driver/connection.rs | 11 - rs/moq-tokio/src/quic/driver/endpoint.rs | 6 +- rs/moq-tokio/src/quic/driver/forward.rs | 1 - rs/moq-tokio/src/quic/driver/incoming.rs | 1 - rs/moq-tokio/src/quic/driver/mod.rs | 4 +- rs/moq-tokio/src/quic/driver/recv.rs | 4 - rs/moq-tokio/src/quic/driver/runtime/mod.rs | 1 - rs/moq-tokio/src/quic/driver/send.rs | 11 - rs/moq-tokio/src/quic/driver/tests.rs | 2 - rs/moq-tokio/src/quic/web/session.rs | 2 +- rs/moq-tokio/src/resolve.rs | 1 - rs/moq-tokio/src/runtime.rs | 5 - rs/moq-tokio/src/server.rs | 505 ++++-------------- rs/moq-tokio/src/sim.rs | 2 +- rs/moq-tokio/src/tcp.rs | 2 - rs/moq-tokio/src/tls.rs | 135 +---- rs/moq-tokio/src/websocket.rs | 9 +- rs/moq-tokio/src/worker/group.rs | 1 - rs/moq-tokio/src/worker/mod.rs | 2 - rs/moq-tokio/tests/integration/backend.rs | 32 +- rs/moq-tokio/tests/integration/close_code.rs | 2 - .../tests/integration/datagram_delivery.rs | 2 - rs/moq-tokio/tests/integration/fresh_port.rs | 6 +- rs/moq-tokio/tests/integration/migrate.rs | 2 - .../tests/integration/receive_credit.rs | 2 - rs/moq-tokio/tests/integration/reconnect.rs | 2 - .../tests/integration/reset_secret.rs | 2 - rs/moq-tokio/tests/integration/runtime.rs | 2 +- rs/moq-tokio/tests/integration/sim.rs | 2 - rs/moq-tokio/tests/integration/sim_client.rs | 2 - rs/moq-tokio/tests/integration/stream_code.rs | 2 - rs/moq-tokio/tests/integration/tokens.rs | 2 - rs/moq-tokio/tests/integration/worker.rs | 13 +- rs/moq-transcode/Cargo.toml | 2 +- rs/moq-uring/Cargo.toml | 2 +- rs/moq-uring/README.md | 2 +- rs/moq-webrtc/Cargo.toml | 2 +- rs/qmux/Cargo.toml | 33 +- rs/qmux/README.md | 6 +- rs/qmux/src/config.rs | 1 - rs/qmux/src/error.rs | 7 +- rs/qmux/src/lib.rs | 24 +- rs/qmux/src/protocol.rs | 7 - rs/qmux/src/session.rs | 4 +- rs/qmux/src/session/tests.rs | 2 - rs/qmux/src/transport.rs | 5 - rs/qmux/src/ws.rs | 8 - rs/qmux/tests/interop.rs | 2 - rs/workspace-hack/Cargo.toml | 2 - sh/dispatch.sh | 2 +- sh/gh/nightly.test.py | 6 +- sh/rs/select.sh | 3 - sh/rs/select.test.py | 15 +- sh/rs/tokio-features.sh | 53 -- 128 files changed, 402 insertions(+), 2107 deletions(-) delete mode 100644 quest/m2/features-network.md delete mode 100755 sh/rs/tokio-features.sh diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 16ad7af4154..980dcd5137b 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -374,9 +374,8 @@ jobs: strategy: fail-fast: false matrix: - # `rs uring` is a separate feature compile (off the default set), and - # CI_STRICT fails it below the 6.12 kernel floor. The embedding tests for - # io_uring live there; uring.yml also runs it on affected release PRs. + # `rs uring` runs the io_uring tests under CI_STRICT, which fails them below + # the 6.12 kernel floor; uring.yml also runs it on affected release PRs. # `test drain` stands up two relays and drains one under a live JS # viewer: diff-independent, since a break can arrive through the relay, # js/net, or the wire between them. diff --git a/.oss-scanner/Dockerfile b/.oss-scanner/Dockerfile index 5a2cb70fcfe..b18cb606fe2 100644 --- a/.oss-scanner/Dockerfile +++ b/.oss-scanner/Dockerfile @@ -25,10 +25,9 @@ RUN rustup show active-toolchain || rustup toolchain install \ ARG CRATES="kio hang moq-auth moq-crypto moq-hls moq-json moq-loc moq-msf moq-mux moq-net moq-pattern moq-quic moq-relay moq-rtmp moq-rtsp moq-sock moq-srt moq-stats moq-tokio moq-uring moq-webrtc moq-cli" # Path specs, because the lockfile also has published copies of some workspace crates. -# io-uring compiles the relay's io_uring QUIC workers (`--runtime-io-uring`), which the default features leave out. RUN cargo fetch --locked \ && specs=$(printf -- '-p path+file:///src/rs/%s ' $CRATES) \ - && cargo build --locked $specs --features moq-relay/io-uring --bins \ - && cargo test --locked --no-run $specs --features moq-relay/io-uring + && cargo build --locked $specs --bins \ + && cargo test --locked --no-run $specs ENV CARGO_NET_OFFLINE=true diff --git a/.oss-scanner/threat_model.md b/.oss-scanner/threat_model.md index 19b8c843787..61b4d377f15 100644 --- a/.oss-scanner/threat_model.md +++ b/.oss-scanner/threat_model.md @@ -45,7 +45,7 @@ Out of scope: `js/` and the other language bindings (`py/`, `swift/`, `kt/`, `go The image is offline, with every crate fetched and `CARGO_NET_OFFLINE` set. The debug build of the in-scope crates, their test binaries, and the `moq-relay` and `moq` binaries are already built in `/src/target/debug`. Debug builds keep overflow checks on. -- **Tests**: `cargo nextest run -p path+file:///src/rs/moq-net` (or any in-scope crate; the path spec is needed because the lockfile also has published copies of some crates). Use nextest as CI does: some tests install process-global state and fail under plain `cargo test`. Add `--features moq-relay/io-uring` for the relay and `moq-uring` so the io\_uring backend's tests run (they skip on a kernel without io\_uring support). Unit tests use the deterministic clock in `kio::clock` rather than wall time, so they are fast and reproducible. +- **Tests**: `cargo nextest run -p path+file:///src/rs/moq-net` (or any in-scope crate; the path spec is needed because the lockfile also has published copies of some crates). Use nextest as CI does: some tests install process-global state and fail under plain `cargo test`. The io\_uring backend's tests in the relay and `moq-uring` skip on a kernel without io\_uring support. Unit tests use the deterministic clock in `kio::clock` rather than wall time, so they are fast and reproducible. - **A relay to attack**: `./target/debug/moq-relay demo/relay/localhost.toml` listens on UDP and TCP `[::]:4443` with a self-signed certificate and anonymous access to every path. The binary is built with io\_uring support; pass `--runtime-io-uring` to serve QUIC from the io\_uring workers in `rs/moq-uring` and `rs/moq-relay/src/uring.rs` instead of tokio. For authorization testing, grant a narrow anonymous pattern with `[auth] public_subscribe` / `public_publish`, or run the reference auth server (`moq auth generate`, `moq auth sign`, `moq auth serve`, then `[auth] url`; see `doc/bin/cli.md`) and try to escape a signed token's root and patterns. `doc/bin/relay/` documents the config, auth, cluster, and HTTP endpoints. - **A client**: `./target/debug/moq --help` publishes, subscribes, fetches, and lists announcements against a relay. `curl http://localhost:4443/announced/` and `curl http://localhost:4443/fetch//` hit the HTTP endpoints. - **Fuzz harnesses**: `rs/moq-net/fuzz` and `rs/moq-quic/fuzz` hold cargo-fuzz targets for the wire codecs and the QUIC state machine. cargo-fuzz and a nightly toolchain are not in the image, but the targets show the parser entry points. diff --git a/Cargo.lock b/Cargo.lock index 50ce3a86a4b..a48eca5cd57 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10459,7 +10459,6 @@ dependencies = [ "tower-http 0.6.11", "tracing-core", "tracing-subscriber", - "tungstenite", "typenum", "url", "usage-argv", diff --git a/bench/metadata.py b/bench/metadata.py index 7a8d8ecbd16..9c319b4afb8 100644 --- a/bench/metadata.py +++ b/bench/metadata.py @@ -57,8 +57,8 @@ def command(*args): }, "profile": "profiling" if mode == "--profile" else "release", "features": { - "--runtime": "default + moq-relay/io-uring", - "--profile": "default + moq-relay/io-uring; heap adds moq-relay/jemalloc", + "--runtime": "default", + "--profile": "default; heap adds moq-relay/jemalloc", "--criterion": "see criterion-command.json", }.get(mode, "default"), "mode": mode, diff --git a/bench/run.sh b/bench/run.sh index d4c988cc024..95eaa988bf1 100755 --- a/bench/run.sh +++ b/bench/run.sh @@ -873,9 +873,14 @@ generate_certificate() { # The runtime matrix and profiling use identical feature selection and support checks. build_workers() { - local checkout=$1 target=$2 profile=$3 features=moq-relay/io-uring + local checkout=$1 target=$2 profile=$3 + local -a features=() + # A revision from before the relay always compiled io_uring on Linux names it as a feature. + if grep -q '^io-uring = ' "$checkout/rs/moq-relay/Cargo.toml"; then + features+=(moq-relay/io-uring) + fi if [[ ${4:-} == heap ]]; then - features+=,moq-relay/jemalloc + features+=(moq-relay/jemalloc) fi printf 'Building worker runtimes: %s (%s)\n' "$checkout" "$profile" ( @@ -883,7 +888,7 @@ build_workers() { cd / CARGO_TARGET_DIR=$target cargo --config "$checkout/.cargo/config.toml" build \ --manifest-path "$checkout/Cargo.toml" --locked --profile "$profile" \ - -p moq-relay -p moq-bench --features "$features" + -p moq-relay -p moq-bench --features "${features[*]}" ) } diff --git a/doc/bin/cli.md b/doc/bin/cli.md index 065d77330f0..3f6abf1bf12 100644 --- a/doc/bin/cli.md +++ b/doc/bin/cli.md @@ -220,7 +220,7 @@ Playback is behind the `play` feature, since it pulls in windowing and audio-device dependencies: ```bash -cargo install moq-cli --no-default-features --features "quic,websocket,play,openh264" +cargo install moq-cli --no-default-features --features play,openh264 ``` `moq play` skips disabled renditions. If none are enabled, it waits for a later catalog. Disabling the current rendition stops it and selects an enabled replacement. diff --git a/doc/bin/relay/config.md b/doc/bin/relay/config.md index 8330db7a7c6..69575315892 100644 --- a/doc/bin/relay/config.md +++ b/doc/bin/relay/config.md @@ -219,7 +219,7 @@ io_uring = false # Drive them with io_uring instead of tokio ``` Packets are steered by connection ID, so a client that migrates stays with its -worker. `workers` needs the `quic` feature. Every worker and the TLS stream +worker. Every worker and the TLS stream listener serve one shared identity, generated or file-backed, so a certificate rotation reaches them together and `/certificate.sha256` stays accurate. @@ -227,9 +227,9 @@ Pinning is off by default because every relay pins its workers to the same first cores, so two relays on one host, or one limited to fewer CPUs than the host has, would crowd onto them. Turn it on for a host the relay has to itself. -`io_uring` additionally needs Linux 6.12+ and the `io-uring` cargo feature; it +`io_uring` additionally needs Linux 6.12+; it shares the same reloadable TLS identity and serves every configured version -like the shared runtime. A setting the build or host cannot deliver refuses to +like the shared runtime. A setting the host cannot deliver refuses to start rather than being ignored. Linux 6.14 up to the 7.3 fix (backported to stable kernels) charges io\_uring rings to `RLIMIT_MEMLOCK`: if io\_uring workers fail to start naming it, raise it (`LimitMEMLOCK=` under systemd). diff --git a/doc/lib/rs/index.md b/doc/lib/rs/index.md index 4900e9f3455..2f6006415de 100644 --- a/doc/lib/rs/index.md +++ b/doc/lib/rs/index.md @@ -25,7 +25,7 @@ missing required CPU feature before starting transport cryptography. | --- | --- | | [moq-net](/lib/rs/moq-net) | The pub/sub layer: sessions, origins, broadcasts, tracks, groups, frames. Transport-agnostic. | | [moq-pattern](https://docs.rs/moq-pattern) | Path patterns such as `room/**`. Re-exported by moq-net and moq-auth. | -| [moq-tokio](https://docs.rs/moq-tokio) | Connects and listens over QUIC, WebTransport, WebSocket, TCP, or Unix sockets, from config or CLI flags, and runs MoQ over a qmux session established elsewhere (`qmux` feature). With default features off, `driver` builds a Tokio QUIC stack, with rind cryptography, without MoQ. | +| [moq-tokio](https://docs.rs/moq-tokio) | Connects and listens over QUIC, WebTransport, WebSocket, TCP, or Unix sockets, from config or CLI flags, and runs MoQ over a qmux session established elsewhere. Its `quic::driver` is a Tokio QUIC stack, with rind cryptography, for applications without MoQ. | | [qmux](https://docs.rs/qmux) | QUIC streams, datagrams, and flow control over TCP, TLS, WebSocket, and Unix sockets, on moq-quic's state machine. | | [moq-sock](https://docs.rs/moq-sock) | Socket binding and CPU pinning for thread-per-core listeners. | | [moq-uring](https://docs.rs/moq-uring) | Experimental Linux io\_uring server for moq-lite. | diff --git a/nix/Cargo.nix b/nix/Cargo.nix index b6f54547036..a1afd2d01a6 100644 --- a/nix/Cargo.nix +++ b/nix/Cargo.nix @@ -12215,11 +12215,6 @@ rec { { name = "moq-tokio"; packageId = "moq-tokio"; - usesDefaultFeatures = false; - features = [ - "quic" - "websocket" - ]; } { name = "tokio"; @@ -17814,7 +17809,6 @@ rec { name = "moq-tokio"; packageId = "moq-tokio"; usesDefaultFeatures = false; - features = [ "net" ]; } { name = "procfs"; @@ -17875,22 +17869,7 @@ rec { packageId = "workspace-hack"; } ]; - features = { - "default" = [ - "quic" - "websocket" - "tcp" - ]; - "quic" = [ "moq-tokio/quic" ]; - "tcp" = [ "moq-tokio/tcp" ]; - "websocket" = [ "moq-tokio/websocket" ]; - }; - resolvedDefaultFeatures = [ - "default" - "quic" - "tcp" - "websocket" - ]; + }; "moq-boy" = rec { crateName = "moq-boy"; @@ -17956,7 +17935,6 @@ rec { name = "moq-tokio"; packageId = "moq-tokio"; usesDefaultFeatures = false; - features = [ "net" ]; } { name = "moq-video"; @@ -18006,21 +17984,12 @@ rec { } ]; features = { - "default" = [ - "quic" - "websocket" - ]; "jemalloc" = [ "moq-tokio/jemalloc" ]; "openh264" = [ "moq-video/openh264" ]; - "quic" = [ "moq-tokio/quic" ]; - "websocket" = [ "moq-tokio/websocket" ]; }; resolvedDefaultFeatures = [ - "default" "jemalloc" "openh264" - "quic" - "websocket" ]; }; "moq-c" = rec { @@ -18079,12 +18048,6 @@ rec { name = "moq-tokio"; packageId = "moq-tokio"; usesDefaultFeatures = false; - features = [ - "quic" - "websocket" - "tcp" - "uds" - ]; } { name = "moq-video"; @@ -18288,11 +18251,6 @@ rec { name = "moq-tokio"; packageId = "moq-tokio"; usesDefaultFeatures = false; - features = [ - "tcp" - "uds" - "watch" - ]; } { name = "moq-transcode"; @@ -18476,11 +18434,7 @@ rec { "moq-video/capture" "moq-audio/capture" ]; - "cluster-lan" = [ "moq-relay/cluster-lan" ]; "default" = [ - "cluster-lan" - "quic" - "websocket" "nvidia" "vaapi" "s3" @@ -18516,7 +18470,6 @@ rec { ]; "pulseaudio" = [ "moq-audio?/pulseaudio" ]; "qlog" = [ "moq-tokio/qlog" ]; - "quic" = [ "moq-tokio/quic" ]; "s3" = [ "object_store/aws-base" "object_store/reqwest" @@ -18535,12 +18488,10 @@ rec { "moq-transcode?/vaapi" ]; "vpx" = [ "moq-video?/vpx" ]; - "websocket" = [ "moq-tokio/websocket" ]; }; resolvedDefaultFeatures = [ "azure" "capture" - "cluster-lan" "default" "gcs" "jemalloc" @@ -18550,13 +18501,11 @@ rec { "play" "pulseaudio" "qlog" - "quic" "s3" "transcode" "v4l2" "vaapi" "vpx" - "websocket" ]; }; "moq-congestion" = rec { @@ -18836,6 +18785,7 @@ rec { { name = "moq-tokio"; packageId = "moq-tokio"; + usesDefaultFeatures = false; } { name = "moq-video"; @@ -18997,6 +18947,7 @@ rec { { name = "moq-tokio"; packageId = "moq-tokio"; + usesDefaultFeatures = false; } { name = "tokio"; @@ -19202,11 +19153,6 @@ rec { { name = "moq-tokio"; packageId = "moq-tokio"; - usesDefaultFeatures = false; - features = [ - "tcp" - "quic" - ]; } { name = "mp4-atom"; @@ -20377,7 +20323,6 @@ rec { { name = "hyper"; packageId = "hyper"; - optional = true; } { name = "hyper-util"; @@ -20437,17 +20382,13 @@ rec { name = "moq-tokio"; packageId = "moq-tokio"; usesDefaultFeatures = false; - features = [ - "watch" - "tcp" - ]; } { name = "moq-uring"; packageId = "moq-uring"; - optional = true; usesDefaultFeatures = false; target = { target, features }: ("linux" == target."os" or null); + features = [ "quic" ]; } { name = "prometheus-client"; @@ -20456,9 +20397,7 @@ rec { { name = "qmux"; packageId = "qmux 0.7.0"; - optional = true; usesDefaultFeatures = false; - features = [ "ws" ]; } { name = "rand"; @@ -20530,7 +20469,6 @@ rec { { name = "tokio-tungstenite"; packageId = "tokio-tungstenite"; - optional = true; usesDefaultFeatures = false; features = [ "connect" @@ -20565,7 +20503,6 @@ rec { { name = "web-transport-proto"; packageId = "web-transport-proto"; - optional = true; target = { target, features }: ("linux" == target."os" or null); } ]; @@ -20625,12 +20562,6 @@ rec { name = "pem"; packageId = "pem 4.0.0"; } - { - name = "qmux"; - packageId = "qmux 0.7.0"; - usesDefaultFeatures = false; - features = [ "tcp" ]; - } { name = "rcgen"; packageId = "rcgen"; @@ -20678,52 +20609,17 @@ rec { } ]; features = { - "_uring" = [ - "dep:moq-uring" - "dep:web-transport-proto" - ]; - "cluster-lan" = [ "moq-tokio/mdns" ]; - "default" = [ - "cluster-lan" - "quic" - "websocket" - "uds" - ]; - "io-uring" = [ - "_uring" - "moq-tokio/driver" - "moq-uring/quic" - ]; "jemalloc" = [ "moq-tokio/jemalloc" ]; "qlog" = [ "moq-tokio/qlog" - "moq-uring?/qlog" - ]; - "quic" = [ - "_quic" - "moq-tokio/quic" + "moq-uring/qlog" ]; "test-support" = [ "moq-tokio/sim" ]; - "uds" = [ "moq-tokio/uds" ]; - "websocket" = [ - "moq-tokio/websocket" - "dep:qmux" - "dep:hyper" - "dep:tokio-tungstenite" - ]; }; resolvedDefaultFeatures = [ - "_quic" - "_uring" - "cluster-lan" - "default" - "io-uring" "jemalloc" "qlog" - "quic" "test-support" - "uds" - "websocket" ]; }; "moq-rtmp" = rec { @@ -20844,8 +20740,6 @@ rec { { name = "moq-tokio"; packageId = "moq-tokio"; - usesDefaultFeatures = false; - features = [ "net" ]; } { name = "rind-rustls"; @@ -21431,7 +21325,6 @@ rec { { name = "dns-lookup"; packageId = "dns-lookup"; - optional = true; } { name = "futures"; @@ -21444,12 +21337,10 @@ rec { { name = "http"; packageId = "http"; - optional = true; } { name = "httparse"; packageId = "httparse"; - optional = true; } { name = "humantime"; @@ -21480,13 +21371,11 @@ rec { { name = "mdns-sd"; packageId = "mdns-sd"; - optional = true; features = [ "async" ]; } { name = "moq-congestion"; packageId = "moq-congestion"; - optional = true; } { name = "moq-crypto"; @@ -21497,12 +21386,11 @@ rec { { name = "moq-net"; packageId = "moq-net"; - optional = true; + features = [ "async" ]; } { name = "moq-quic"; packageId = "moq-quic"; - optional = true; usesDefaultFeatures = false; } { @@ -21512,18 +21400,11 @@ rec { { name = "notify"; packageId = "notify"; - optional = true; } { name = "qmux"; packageId = "qmux 0.7.0"; - optional = true; usesDefaultFeatures = false; - features = [ - "wss" - "tls" - "tcp" - ]; } { name = "rand"; @@ -21532,13 +21413,11 @@ rec { { name = "rcgen"; packageId = "rcgen"; - optional = true; usesDefaultFeatures = false; } { name = "reqwest"; packageId = "reqwest"; - optional = true; usesDefaultFeatures = false; } { @@ -21549,12 +21428,10 @@ rec { { name = "rind-rcgen"; packageId = "rind-rcgen"; - optional = true; } { name = "rustc-hash"; packageId = "rustc-hash 2.1.3"; - optional = true; } { name = "rustls"; @@ -21572,7 +21449,6 @@ rec { { name = "rustls-webpki"; packageId = "rustls-webpki"; - optional = true; usesDefaultFeatures = false; features = [ "std" ]; } @@ -21616,13 +21492,11 @@ rec { { name = "tokio-rustls"; packageId = "tokio-rustls"; - optional = true; usesDefaultFeatures = false; } { name = "tokio-tungstenite"; packageId = "tokio-tungstenite"; - optional = true; usesDefaultFeatures = false; features = [ "handshake" ]; } @@ -21657,7 +21531,6 @@ rec { { name = "web-transport-proto"; packageId = "web-transport-proto"; - optional = true; } { name = "webpki-roots"; @@ -21767,91 +21640,20 @@ rec { } ]; features = { - "_certs" = [ - "dep:rcgen" - "dep:rind-rcgen" - "dep:rustls-webpki" - ]; - "_transport" = [ - "net" - "dep:moq-quic" - ]; - "default" = [ - "net" - "quic" - "websocket" - "tcp" - "uds" - ]; - "driver" = [ - "_certs" - "dep:moq-congestion" - "dep:moq-quic" - "dep:rustc-hash" - ]; "jemalloc" = [ "dep:tikv-jemallocator" "dep:tikv-jemalloc-ctl" ]; - "mdns" = [ "dep:mdns-sd" ]; - "net" = [ - "dep:moq-net" - "moq-net/async" - "_certs" - ]; - "qlog" = [ "moq-quic?/qlog" ]; - "qmux" = [ - "_transport" - "dep:qmux" - ]; - "quic" = [ - "_transport" - "driver" - "dep:http" - "dep:web-transport-proto" - "dep:reqwest" - "watch" - "dep:dns-lookup" - ]; + "qlog" = [ "moq-quic/qlog" ]; "sim" = [ "kio/sim" - "moq-quic?/sim" - ]; - "tcp" = [ - "qmux" - "dep:dns-lookup" - "dep:tokio-rustls" - ]; - "uds" = [ - "tcp" - "qmux/uds" - ]; - "watch" = [ "dep:notify" ]; - "websocket" = [ - "qmux" - "watch" - "dep:dns-lookup" - "dep:httparse" - "dep:tokio-rustls" - "dep:tokio-tungstenite" + "moq-quic/sim" ]; }; resolvedDefaultFeatures = [ - "_certs" - "_transport" - "default" - "driver" "jemalloc" - "mdns" - "net" "qlog" - "qmux" - "quic" "sim" - "tcp" - "uds" - "watch" - "websocket" ]; }; "moq-transcode" = rec { @@ -21943,11 +21745,6 @@ rec { { name = "moq-tokio"; packageId = "moq-tokio"; - usesDefaultFeatures = false; - features = [ - "quic" - "websocket" - ]; } { name = "moq-video"; @@ -22165,9 +21962,7 @@ rec { { name = "moq-tokio"; packageId = "moq-tokio"; - usesDefaultFeatures = false; target = { target, features }: ("linux" == target."os" or null); - features = [ "quic" ]; } { name = "moq-uring"; @@ -22950,10 +22745,6 @@ rec { name = "moq-tokio"; packageId = "moq-tokio"; usesDefaultFeatures = false; - features = [ - "net" - "tcp" - ]; } { name = "pcap-file"; @@ -39537,7 +39328,6 @@ rec { { name = "futures"; packageId = "futures"; - optional = true; } { name = "kio"; @@ -39568,13 +39358,11 @@ rec { { name = "rustls"; packageId = "rustls"; - optional = true; usesDefaultFeatures = false; } { name = "rustls-native-certs"; packageId = "rustls-native-certs"; - optional = true; } { name = "thiserror"; @@ -39583,21 +39371,21 @@ rec { { name = "tokio"; packageId = "tokio"; + features = [ "net" ]; } { name = "tokio-rustls"; packageId = "tokio-rustls"; - optional = true; usesDefaultFeatures = false; } { name = "tokio-tungstenite"; packageId = "tokio-tungstenite"; - optional = true; usesDefaultFeatures = false; features = [ "connect" "handshake" + "rustls-tls-native-roots" ]; } { @@ -39669,43 +39457,12 @@ rec { } ]; features = { - "default" = [ - "tls" - "wss" - ]; "fuzz" = [ - "tcp" - "ws" "kio/sim" "tokio/io-util" ]; - "tcp" = [ "tokio/net" ]; - "tls" = [ - "tcp" - "dep:tokio-rustls" - "dep:rustls" - ]; - "uds" = [ "tokio/net" ]; - "ws" = [ - "dep:tokio-tungstenite" - "dep:futures" - ]; - "wss" = [ - "ws" - "dep:rustls-native-certs" - "dep:rustls" - "tokio-tungstenite/rustls-tls-native-roots" - ]; }; - resolvedDefaultFeatures = [ - "default" - "fuzz" - "tcp" - "tls" - "uds" - "ws" - "wss" - ]; + resolvedDefaultFeatures = [ "fuzz" ]; }; "qmux-fuzz" = rec { crateName = "qmux-fuzz"; @@ -59679,15 +59436,6 @@ rec { "local-time" ]; } - { - name = "tungstenite"; - packageId = "tungstenite"; - usesDefaultFeatures = false; - features = [ - "__rustls-tls" - "handshake" - ]; - } { name = "typenum"; packageId = "typenum"; @@ -61121,15 +60869,6 @@ rec { "local-time" ]; } - { - name = "tungstenite"; - packageId = "tungstenite"; - usesDefaultFeatures = false; - features = [ - "__rustls-tls" - "handshake" - ]; - } { name = "typenum"; packageId = "typenum"; diff --git a/quest/m2/features-leaf-trims.md b/quest/m2/features-leaf-trims.md index c49040c79cf..66c2d34a9e2 100644 --- a/quest/m2/features-leaf-trims.md +++ b/quest/m2/features-leaf-trims.md @@ -47,8 +47,3 @@ mention these features, and `rs/justfile`: the `audio-devices` recipe's `--features aec,pulseaudio` becomes `capture,playback,pulseaudio`, and the CodSpeed bench recipe drops `moq-audio/bus`. moq-audio's `bus` bench drops its `required-features = ["bus"]`. - -## Related - -- [Always compile the network stack](/quest/m2/features-network.md) - the same - rule applied to the transport crates diff --git a/quest/m2/features-network.md b/quest/m2/features-network.md deleted file mode 100644 index b4a7ac4c752..00000000000 --- a/quest/m2/features-network.md +++ /dev/null @@ -1,68 +0,0 @@ -# [L] Always compile the network stack - -## Goal - -The transports, LAN discovery, STUN, and the io_uring runtime compile into -every build of the crates that offer them, picked at runtime by URL scheme, -flag, or config instead of by Cargo feature. These features go away: - -- moq-tokio: `net`, `driver`, `quic`, `websocket`, `tcp`, `uds`, `qmux`, - `watch`, `mdns`, and the private `_transport` and `_certs`. It keeps - `jemalloc` (a C build) and `sim` (test-only), and `qlog` until - [Always compile qlog](/quest/m2/features-qlog.md) decides it. -- moq-relay: `quic`, `_quic`, `websocket`, `uds`, `cluster-lan`, `stun`, - `io-uring`, and `_uring`. -- moq-cli: `quic`, `websocket`, and `cluster-lan`. -- moq-bench and moq-boy: `quic`, `websocket`, and `tcp`. -- qmux: `tcp`, `tls`, `uds`, `ws`, and `wss`. - -Unix sockets compile on `cfg(unix)` and io_uring on `cfg(target_os = -"linux")`, as platform gates rather than features. - -## Plan - -Found by the [Cargo feature review](/quest/m3/release/feature-flags.md) (first -pass, 2026-11-14). The `# Features` rules in `rs/AGENTS.md` keep a feature only -for a vendor integration or a system dependency. None of these is either: every -crate they gate is pure Rust. Measured with `cargo tree -e normal`, moq-relay's -default `quic`, `websocket`, `uds`, and `cluster-lan` add 10 of its 278 -crates (mdns-sd, if-addrs, flume, socket-pktinfo, web-transport-proto, sfv, and -four small helpers); moq-tokio's `websocket`, `tcp`, and `uds` add 12 over -`quic` alone. Against that, `quic`, `websocket`, `tcp`, and `uds` hold about -660 `cfg` sites in moq-tokio and 160 in moq-relay, plus the "every subset -compiles" matrix in `just rs features` (`rs/justfile`) and private markers -(`_quic`, which only `quic` enables, and `_transport`) that exist only to make -those subsets compile. No shipped consumer turns them off: the release binaries, -Nix, moq-ffi, moq-gst, and moq-c all build every transport. - -moq-tokio's `driver` without `net` (the QUIC driver without moq-net) has no -consumer: every enabler also turns on a transport, which turns on `net`. moq-net -becomes an unconditional dependency. - -Keep each runtime refusal that names a missing feature only where a platform can -still lack it (io_uring off Linux, Unix sockets off Unix), and reword it to name -the platform. `config.rs`'s "needs moq-relay built with the `quic` feature" -checks go away, with the tests that assert them, such as -`workers_require_a_quic_backend` in `rs/moq-relay/src/relay.rs`. - -Breaking for anyone who names a removed feature in a manifest: Cargo errors on -an unknown feature. The PR's Impact section says to delete those names from -`features = [...]` and `--features`; nothing replaces them. - -Decided 2026-11-14 (maintainer, /quest-complete): ✅ keep this quest in m2 -(rejected: drop it), and ✅ compile moq-relay's io_uring runtime into every -Linux build (rejected: keep `io-uring` as an opt-in feature). It is pure Rust -(the `io-uring` crate, no liburing), already selected at runtime by -`--runtime-io-uring`, and moq-relay already carries most of what `_uring` -adds. - -Update `doc/bin/relay` and `doc/bin/cli.md` wherever they tell a source -builder to pass one of these features, `bench/run.sh`'s and -`.oss-scanner/Dockerfile`'s `--features moq-relay/io-uring`, and the -`rs/justfile` recipes that name a removed feature: `features` (moq-cli's -`websocket`), `uring`, and `uring-check` (moq-relay's `io-uring`). - -## Related - -- [Cost audit](/quest/m3/audit-cost.md) - owns per-crate build cost, which this - trades a little of for a smaller test matrix diff --git a/quest/m2/features-qlog.md b/quest/m2/features-qlog.md index d2dae3886c6..3464ef9c79d 100644 --- a/quest/m2/features-qlog.md +++ b/quest/m2/features-qlog.md @@ -35,9 +35,3 @@ doc on `MoqQuicConfig::qlog`. `doc/bin/relay/config.md` drops "Needs the `qlog` build feature", `doc/bin/obs.md` drops its `-DMOQ_FFI_QLOG=ON` source build for traces, and the `rs/justfile` uring recipes drop `moq-relay/qlog` from their clippy run and `--features qlog` from moq-uring's nextest run. - -## Related - -- [Always compile the network stack](/quest/m2/features-network.md) - removes - the other moq-tokio and moq-relay features; expect conflicts in the same - manifests diff --git a/quest/m3/release/feature-flags.md b/quest/m3/release/feature-flags.md index 593eb3e14ac..30cd595dadb 100644 --- a/quest/m3/release/feature-flags.md +++ b/quest/m3/release/feature-flags.md @@ -40,7 +40,8 @@ judged, so this pass reads only the difference: it, inside the shipped binary rather than the crate alone: most features that look heavy on their crate add one or two crates to moq-relay or moq-cli. Diff this pass's inventory against the first pass's to find what m2 added. -- Filed: [network stack](/quest/m2/features-network.md), +- Filed: network stack (landed in + [moq-dev/moq#8852](https://github.com/moq-dev/moq/pull/8852)), [qlog](/quest/m2/features-qlog.md), and [media and gateway trims](/quest/m2/features-leaf-trims.md). Check each landed or was dropped. - Kept, with the reason a new feature has to match: diff --git a/rs/hang/Cargo.toml b/rs/hang/Cargo.toml index 219b305193e..a495cd02d86 100644 --- a/rs/hang/Cargo.toml +++ b/rs/hang/Cargo.toml @@ -41,7 +41,7 @@ anyhow = { workspace = true } # Compile the async API used by the tests. hang = { path = ".", features = ["async"] } moq-mux = { path = "../moq-mux", features = ["async"] } -moq-tokio = { path = "../moq-tokio", default-features = false, features = ["quic", "websocket"] } +moq-tokio = { path = "../moq-tokio" } tokio = { workspace = true, features = ["macros", "fs"] } tracing = { workspace = true } url = { workspace = true } diff --git a/rs/justfile b/rs/justfile index 622f9809e6a..74b22e9bbac 100644 --- a/rs/justfile +++ b/rs/justfile @@ -103,11 +103,6 @@ fix-changed $LIST: test-changed $LIST: sh/rs/select.sh test "$LIST" -# Compile moq-tokio at its feature extremes; --all also isolates crypto and transport modes. -[positional-arguments] -tokio-features *args: - sh/rs/tokio-features.sh "$@" - # Runs the `#[cfg(windows)]` code past the compiler, which the Linux gate # skips; platform.yml runs it on a Windows runner, scoped like `check-changed` # so a release PR compiles only the affected crates. Default @@ -137,26 +132,18 @@ uring-changed base="": bash sh/changed.sh "$1" > "$changed" bash sh/rs/select.sh uring "$changed" -# Compile and test the io_uring relay path, which is off the default feature set. +# Test the io_uring relay path on a kernel that supports it. # Linux-only; CI_STRICT requires a supported kernel instead of skipping tests. [positional-arguments] uring *args: - just rs uring-check "$@" - bash sh/rs/nextest.sh cargo nextest run --locked -p moq-uring -p moq-relay --features moq-relay/io-uring --tests "$@" + bash sh/rs/nextest.sh cargo nextest run --locked -p moq-uring -p moq-relay --tests "$@" # Signal ownership and scoped tracing must also survive sharing one process. cargo test --locked -p moq-relay --test integration # Needs a second IPv6 address on lo, which the io_uring CI lanes add. bash sh/rs/nextest.sh cargo nextest run --locked -p moq-uring --test integration --run-ignored only -E 'test(=local_addr::a_v6_wildcard_answers_from_the_address_reached)' "$@" - bash sh/local.sh cargo clippy --locked -p moq-uring -p moq-relay --features moq-relay/io-uring,moq-relay/qlog --all-targets "$@" -- -D warnings + bash sh/local.sh cargo clippy --locked -p moq-uring -p moq-relay --features moq-relay/qlog --all-targets "$@" -- -D warnings bash sh/rs/nextest.sh cargo nextest run --locked -p moq-uring --features qlog --tests "$@" -# Compile the io_uring relay path, off the default feature set. -[positional-arguments] -uring-check *args: - bash sh/local.sh cargo clippy --locked -p moq-uring -p moq-relay --features moq-relay/io-uring --all-targets "$@" -- -D warnings - # Without the default `quic`, so moq-tokio's `driver` is off: the relay's io_uring path must not lean on it. - bash sh/local.sh cargo clippy --locked -p moq-relay --no-default-features --features io-uring --all-targets "$@" -- -D warnings - # The Apple-gated code in moq-video, moq-audio, and moq-sock, which # platform.yml compiles on a Mac runner alongside `windows`. @@ -272,16 +259,11 @@ features: run just rs coroutines run just rs quic-features --all run just rs crypto-key - run just rs tokio-features --all run just rs media-features --all run bash sh/local.sh cargo check --locked --workspace {{ no_fuzz }} --all-targets --no-default-features - run bash sh/local.sh cargo check --locked -p moq-relay --no-default-features - run just rs test -p moq-relay --no-default-features run bash sh/local.sh cargo check --locked -p moq-cli --no-default-features - run just rs test -p moq-cli --no-default-features --features capture,websocket -E 'test(capture_window)' - run just rs test -p moq-cli --no-default-features --features capture,pipewire,websocket -E 'test(capture_window)' - run bash sh/local.sh cargo check --locked -p moq-bench --no-default-features - run bash sh/local.sh cargo check --locked -p moq-boy --no-default-features + run just rs test -p moq-cli --no-default-features --features capture -E 'test(capture_window)' + run just rs test -p moq-cli --no-default-features --features capture,pipewire -E 'test(capture_window)' # Alone, since the workspace's `kio/sim` dev-dependencies would unify `kio/async` back in. run bash sh/local.sh cargo check --locked --manifest-path rs/moq-auth/Cargo.toml --lib --all-features run bash sh/local.sh cargo check --locked -p moq-hls -p moq-rtmp -p moq-webrtc --no-default-features --all-targets @@ -471,8 +453,8 @@ render-sw: # Run the ignored mDNS tests, which multicast on the host's network interfaces. multicast: - just rs test -p moq-tokio --features mdns --lib --run-ignored only -E 'test(=mdns::tests::same_app_peers_find_each_other) | test(/^mdns::tests::daemon_/)' - just rs test -p moq-relay --features cluster-lan --run-ignored only -E 'test(/^lan_mesh::/)' + just rs test -p moq-tokio --lib --run-ignored only -E 'test(=mdns::tests::same_app_peers_find_each_other) | test(/^mdns::tests::daemon_/)' + just rs test -p moq-relay --run-ignored only -E 'test(/^lan_mesh::/)' # Run the long TS recovery arms; a failing arm keeps its export and ledgers under $HARNESS_RUNS. ts-recovery: diff --git a/rs/moq-bench/Cargo.toml b/rs/moq-bench/Cargo.toml index 6b4e645043a..7c941683aec 100644 --- a/rs/moq-bench/Cargo.toml +++ b/rs/moq-bench/Cargo.toml @@ -18,20 +18,13 @@ name = "moq-bench" path = "src/main.rs" doc = false -[features] -default = ["quic", "websocket", "tcp"] -quic = ["moq-tokio/quic"] -# Qmux over TCP: `tcp://`, and `tls://`. -tcp = ["moq-tokio/tcp"] -websocket = ["moq-tokio/websocket"] - [dependencies] anyhow = { workspace = true, features = ["backtrace"] } bytes = { workspace = true } humantime = { workspace = true } kio = { workspace = true, features = ["runtime"] } moq-net = { workspace = true } -moq-tokio = { workspace = true, default-features = false, features = ["net"] } +moq-tokio = { workspace = true } rand = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } diff --git a/rs/moq-boy/Cargo.toml b/rs/moq-boy/Cargo.toml index 06456115871..cdc293bc0cb 100644 --- a/rs/moq-boy/Cargo.toml +++ b/rs/moq-boy/Cargo.toml @@ -18,7 +18,6 @@ path = "src/main.rs" required-features = ["openh264"] [features] -default = ["quic", "websocket"] jemalloc = ["moq-tokio/jemalloc"] # The software H.264 encoder. moq-boy needs it at runtime (a 160x144 frame is # below every hardware encoder's minimum), but it is vendored C++, so it stays @@ -26,8 +25,6 @@ jemalloc = ["moq-tokio/jemalloc"] # on would turn it on for every workspace build through feature unification. # The nix package turns it on. openh264 = ["moq-video/openh264"] -quic = ["moq-tokio/quic"] -websocket = ["moq-tokio/websocket"] [dependencies] anyhow = { workspace = true, features = ["backtrace"] } @@ -39,7 +36,7 @@ moq-audio = { workspace = true } moq-json = { workspace = true, features = ["async"] } moq-mux = { workspace = true } moq-net = { workspace = true } -moq-tokio = { workspace = true, default-features = false, features = ["net"] } +moq-tokio = { workspace = true } # Select the Linux NVIDIA and VAAPI codecs explicitly; software H.264 is the # `openh264` feature. moq-video = { workspace = true, features = ["nvidia", "vaapi"] } diff --git a/rs/moq-c/Cargo.toml b/rs/moq-c/Cargo.toml index ae81527e410..879d3308162 100644 --- a/rs/moq-c/Cargo.toml +++ b/rs/moq-c/Cargo.toml @@ -31,7 +31,7 @@ moq-audio = { workspace = true, features = ["aac"] } moq-json = { workspace = true, features = ["async"] } moq-mux = { workspace = true, features = ["async"] } moq-net = { workspace = true } -moq-tokio = { workspace = true, features = ["quic", "websocket", "tcp", "uds"] } +moq-tokio = { workspace = true } # Select the NVIDIA and VAAPI hardware codecs explicitly because workspace # defaults are off. The hardware backends dlopen their driver, so neither needs # anything on the build host. The software fallback is `openh264`. diff --git a/rs/moq-cli/Cargo.toml b/rs/moq-cli/Cargo.toml index faaace8a745..f347b5ffda6 100644 --- a/rs/moq-cli/Cargo.toml +++ b/rs/moq-cli/Cargo.toml @@ -38,16 +38,12 @@ path = "src/main.rs" doc = false [features] -default = ["cluster-lan", "quic", "websocket", "nvidia", "vaapi", "s3", "gcs", "azure"] -# LAN discovery and meshing (`--cluster-lan`). -cluster-lan = ["moq-relay/cluster-lan"] +default = ["nvidia", "vaapi", "s3", "gcs", "azure"] jemalloc = ["moq-tokio/jemalloc"] -quic = ["moq-tokio/quic"] # qlog trace capture (`--client-quic-qlog `). Off by default: it compiles the # qlog machinery into the enabled backends and is only wanted for debugging or # congestion-control testing. qlog = ["moq-tokio/qlog"] -websocket = ["moq-tokio/websocket"] # The cloud object stores `export archive` and `import archive` reach (`s3://`, # `gs://`, `az://`), signing through rind and connecting through reqwest. Local # `file://` URLs need none of them. @@ -76,7 +72,7 @@ play = ["dep:moq-video", "moq-video/render", "dep:moq-audio", "moq-audio/playbac # the matching moq-video feature, so it only bites when something else pulls in # moq-video: `capture`, `transcode`, or `play`. For a build with no CUDA # dependencies, drop it: -# cargo build -p moq-cli --no-default-features --features "quic,websocket,capture" +# cargo build -p moq-cli --no-default-features --features capture nvidia = ["moq-video?/nvidia", "moq-transcode?/nvidia"] # The vendored OpenH264 software H.264 fallback (C++), opt-in like the moq-video # feature it turns on. Only bites when `capture`, `transcode`, or `play` pulls in @@ -126,14 +122,12 @@ moq-hls = { workspace = true, features = ["server"] } moq-json = { workspace = true, features = ["async"] } moq-mux = { workspace = true, features = ["async"] } moq-net = { workspace = true } -# Cluster, LAN mesh, and inbound `/.cluster` auth. default-features off so the -# CLI's own feature set (quic, cluster-lan) is what selects them. +# Cluster, LAN mesh, and inbound `/.cluster` auth. moq-relay = { workspace = true } moq-rtmp = { workspace = true } moq-rtsp = { workspace = true } moq-srt = { workspace = true } -# Raw qmux listeners are part of the CLI surface. `uds` compiles only on Unix. -moq-tokio = { workspace = true, default-features = false, features = ["tcp", "uds", "watch"] } +moq-tokio = { workspace = true } moq-transcode = { workspace = true, optional = true } moq-video = { workspace = true, optional = true } moq-webrtc = { workspace = true } diff --git a/rs/moq-cli/src/args.rs b/rs/moq-cli/src/args.rs index 0b86611b18d..41aab58a0c5 100644 --- a/rs/moq-cli/src/args.rs +++ b/rs/moq-cli/src/args.rs @@ -550,10 +550,7 @@ impl MoqSide { /// Whether `--cluster-lan` asked this process to mesh over the LAN. pub fn lan(&self) -> bool { - #[cfg(feature = "cluster-lan")] - return self.cluster.lan.enabled; - #[cfg(not(feature = "cluster-lan"))] - false + self.cluster.lan.enabled } /// The server to bind, which the LAN mesh shares with ordinary clients. @@ -596,19 +593,15 @@ impl MoqSide { ); // The `--connect` client and the cluster's WAN dials each bind // `--connect-bind` for QUIC, so a fixed port would collide halfway through startup. - #[cfg(feature = "quic")] anyhow::ensure!( !(self.client.url.is_some() && self.cluster_dials() && self.client.bind.is_some_and(|bind| bind.port() != 0)), "--connect-bind with a fixed port cannot serve both --connect and --cluster-connect / --cluster-api-url, which each bind it: use port 0, or drop --connect (unset MOQ_CONNECT if it supplies the URL)" ); - #[cfg(feature = "cluster-lan")] - { - self.cluster.lan.validate()?; - if self.lan() { - moq_relay::cluster::Cluster::validate_lan_versions(&self.client, &self.server_config())?; - } + self.cluster.lan.validate()?; + if self.lan() { + moq_relay::cluster::Cluster::validate_lan_versions(&self.client, &self.server_config())?; } // A listener for ordinary clients admits nobody without a decision; a mesh // listener alone admits its peers by their LAN credential. @@ -2735,7 +2728,6 @@ mod tests { } } - #[cfg(feature = "cluster-lan")] { let cli = Invocation::try_parse_from(["moq", "--cluster-lan", "auth", "generate"]).unwrap(); let err = cli.reject("auth").unwrap_err().to_string(); @@ -2853,7 +2845,7 @@ mod tests { /// `--connect` and a WAN cluster peer each bind `--connect-bind` for QUIC, so a /// fixed port is refused before anything binds; port 0 or either side alone is - /// fine, and a build without QUIC binds nothing to collide. + /// fine. #[test] fn a_fixed_connect_bind_serves_one_dialer() { let parse = |flags: &[&str]| { @@ -2870,12 +2862,8 @@ mod tests { ] .concat(); let result = parse(&both).moq.validate(); - if cfg!(feature = "quic") { - let err = result.unwrap_err().to_string(); - assert!(err.contains("--connect-bind") && err.contains(peer[0]), "{err}"); - } else { - result.expect("without QUIC nothing binds the fixed port"); - } + let err = result.unwrap_err().to_string(); + assert!(err.contains("--connect-bind") && err.contains(peer[0]), "{err}"); let ephemeral = [ &["--connect", "https://relay.example", "--connect-bind", "127.0.0.1:0"][..], @@ -2917,7 +2905,6 @@ mod tests { /// `--cluster-lan` is a MoQ side on its own, and it supplies the listener the /// user would otherwise have to spell out. - #[cfg(feature = "cluster-lan")] #[test] fn cluster_lan_is_a_moq_side_and_fills_in_a_listener() { let cli = Invocation::try_parse_from(["moq", "--cluster-lan", "import", "ts"]).expect("parse"); @@ -2961,7 +2948,6 @@ mod tests { /// The secret is only read by the mesh, so configuring one without it is an /// error rather than a silently ignored flag. - #[cfg(feature = "cluster-lan")] #[test] fn cluster_lan_secret_requires_the_mesh() { for lan in [None, Some("--cluster-lan=false")] { @@ -3000,7 +2986,6 @@ mod tests { /// The app is only read by the mesh, so configuring one without it is an /// error rather than a silently ignored flag. The default is `default`. - #[cfg(feature = "cluster-lan")] #[test] fn cluster_lan_app_requires_the_mesh_and_defaults() { for lan in [None, Some("--cluster-lan=false")] { @@ -3041,7 +3026,6 @@ mod tests { /// A mesh dial authenticates through its request path, which legacy moq-lite /// versions do not carry. - #[cfg(feature = "cluster-lan")] #[test] fn cluster_lan_requires_a_path_capable_version() { for (flag, reported) in [ diff --git a/rs/moq-ffi/Cargo.toml b/rs/moq-ffi/Cargo.toml index 5be4398e067..7eade20012d 100644 --- a/rs/moq-ffi/Cargo.toml +++ b/rs/moq-ffi/Cargo.toml @@ -45,7 +45,7 @@ moq-audio = { workspace = true, optional = true, features = ["aac"] } moq-json = { workspace = true, features = ["async"] } moq-mux = { workspace = true, features = ["async"] } moq-net = { workspace = true } -moq-tokio = { workspace = true, default-features = true } +moq-tokio = { workspace = true } # `nvidia` and `vaapi` back on, matching rs/moq-c: the workspace turns # moq-video's defaults off for `capture` (device code the bindings don't # expose), and the codecs are collateral rather than the goal. Nothing is paid for them off Linux, since diff --git a/rs/moq-gst/Cargo.toml b/rs/moq-gst/Cargo.toml index 051fb298fb3..18c057c218d 100644 --- a/rs/moq-gst/Cargo.toml +++ b/rs/moq-gst/Cargo.toml @@ -26,7 +26,7 @@ hang = { workspace = true } kio = { workspace = true, features = ["runtime"] } moq-mux = { workspace = true, features = ["async"] } moq-net = { workspace = true } -moq-tokio = { workspace = true, default-features = true } +moq-tokio = { workspace = true } tokio = { workspace = true, features = ["full"] } tracing = { workspace = true } tracing-subscriber = { workspace = true } diff --git a/rs/moq-hls/Cargo.toml b/rs/moq-hls/Cargo.toml index 0986744447b..c8f8a921059 100644 --- a/rs/moq-hls/Cargo.toml +++ b/rs/moq-hls/Cargo.toml @@ -49,7 +49,7 @@ moq-archive = { path = "../moq-archive" } # Compile the gateways for the tests, with or without the `server` feature. moq-hls = { path = ".", default-features = false, features = ["async"] } moq-json = { path = "../moq-json" } -moq-tokio = { path = "../moq-tokio", default-features = false, features = ["tcp", "quic"] } +moq-tokio = { path = "../moq-tokio" } mp4-atom = { workspace = true } object_store = { workspace = true } tempfile = { workspace = true } diff --git a/rs/moq-relay/Cargo.toml b/rs/moq-relay/Cargo.toml index 9eb0596ab7d..d56d41fee21 100644 --- a/rs/moq-relay/Cargo.toml +++ b/rs/moq-relay/Cargo.toml @@ -35,33 +35,15 @@ path = "src/main.rs" doc = false [features] -# A programmatic relay fixture with generated TLS and ephemeral ports, and -# `cluster::Options::network`, which routes peer dials over in-memory links, and with -# `quic`, `cluster::Options::sim`, which binds them on a simulated QUIC host. +# A programmatic relay fixture with generated TLS and ephemeral ports, +# `cluster::Options::network`, which routes peer dials over in-memory links, and +# `cluster::Options::sim`, which binds them on a simulated QUIC host. test-support = ["moq-tokio/sim"] -default = ["cluster-lan", "quic", "websocket", "uds"] -# Discover cluster peers on the LAN with mDNS (`--cluster-lan`). -cluster-lan = ["moq-tokio/mdns"] jemalloc = ["moq-tokio/jemalloc"] -quic = ["_quic", "moq-tokio/quic"] -# The tokio QUIC listener, and the thread-per-core worker group behind -# `runtime.workers`. Not one to enable on its own: it names no backend, so -# moq-tokio would have nothing to bind a socket with. -_quic = [] # qlog trace capture (`--quic-qlog `). Off by default: it compiles the -# qlog machinery into the enabled backends and is only wanted for debugging or -# congestion-control testing. Covers the io_uring workers too, so one feature -# means one thing whichever runtime is serving. -qlog = ["moq-tokio/qlog", "moq-uring?/qlog"] -websocket = ["moq-tokio/websocket", "dep:qmux", "dep:hyper", "dep:tokio-tungstenite"] -# Unix-domain-socket stream listener (`--server-unix-bind`), unix-only. In the -# default set; drop via --no-default-features on platforms without Unix sockets. -uds = ["moq-tokio/uds"] -# Serve QUIC from io_uring workers (`--runtime-io-uring`), Linux-only. -# This is off by default: the relay is useful without io_uring. -io-uring = ["_uring", "moq-tokio/driver", "moq-uring/quic"] -# The listener machinery shared by the feature above. -_uring = ["dep:moq-uring", "dep:web-transport-proto"] +# qlog machinery into both QUIC runtimes and is only wanted for debugging or +# congestion-control testing. +qlog = ["moq-tokio/qlog", "moq-uring/qlog"] [dependencies] anyhow = { workspace = true, features = ["backtrace"] } @@ -76,7 +58,7 @@ http-body = { workspace = true } # reqwest-middleware 0.4, while this line matches reqwest 0.13 below. http-cache-reqwest = { version = "1.0.0-alpha.6", features = ["manager-moka", "reqwest-middleware", "url-standard"], default-features = false } # Reclaims the socket under a WebSocket upgrade. -hyper = { workspace = true, optional = true } +hyper = { workspace = true } # `server-auto` reclaims the socket from under the auto builder `axum_server` serves with. hyper-util = { workspace = true, features = ["server-auto"] } kio = { workspace = true, features = ["runtime", "serde"] } @@ -86,10 +68,10 @@ moq-net = { workspace = true } # The flow-control limits both QUIC runtimes take, for widening a peer's connection. moq-quic = { workspace = true } moq-stats = { workspace = true, features = ["async"] } -moq-tokio = { workspace = true, default-features = false, features = ["watch", "tcp"] } +moq-tokio = { workspace = true } # The /metrics text encoder; the protobuf features stay off. prometheus-client = "0.25.2" -qmux = { workspace = true, features = ["ws"], optional = true } +qmux = { workspace = true } rand = { workspace = true } reqwest = { workspace = true, features = ["rustls-no-provider"] } reqwest-middleware = "0.5" @@ -103,7 +85,7 @@ thiserror = { workspace = true } tokio = { workspace = true, features = ["full"] } tokio-rustls = { workspace = true } # The upgrade's accept key; qmux runs the frames after it. -tokio-tungstenite = { workspace = true, features = ["connect", "handshake"], optional = true } +tokio-tungstenite = { workspace = true, features = ["connect", "handshake"] } toml = { workspace = true } tower-service = "0.3" tracing = { workspace = true } @@ -115,9 +97,10 @@ usage-rs = { workspace = true, features = ["completions", "config"] } libc = { workspace = true } # The reuseport group and descriptor passing a handoff carries the sockets with. moq-sock = { workspace = true } -moq-uring = { workspace = true, optional = true } +# Serves QUIC from io_uring workers (`--runtime-io-uring`). +moq-uring = { workspace = true, features = ["quic"] } # The WebTransport CONNECT response the io_uring listener answers with. -web-transport-proto = { workspace = true, optional = true } +web-transport-proto = { workspace = true } [target.'cfg(unix)'.dependencies] sd-notify = { workspace = true } @@ -134,7 +117,6 @@ moq-congestion = { path = "../moq-congestion" } moq-net = { path = "../moq-net", features = ["fuzz"] } moq-shaper = { path = "../moq-shaper", features = ["test"] } pem = { workspace = true } -qmux = { workspace = true, features = ["tcp"] } rcgen = { workspace = true, features = ["pem"] } rind-rcgen = { workspace = true } rind-rustls = { workspace = true } diff --git a/rs/moq-relay/src/auth.rs b/rs/moq-relay/src/auth.rs index b8e469946a5..3af10326673 100644 --- a/rs/moq-relay/src/auth.rs +++ b/rs/moq-relay/src/auth.rs @@ -1263,7 +1263,7 @@ pub fn request_for(auth: &Auth, request: &moq_tokio::server::Request) -> Request } /// Build an auth request from the path, credential, role, and implementation carried in SETUP. -#[cfg(any(feature = "test-support", all(target_os = "linux", feature = "_uring")))] +#[cfg(any(feature = "test-support", target_os = "linux"))] pub(crate) fn request_for_setup( auth: &Auth, setup: &moq_net::server::Handshake, diff --git a/rs/moq-relay/src/auth/caps.rs b/rs/moq-relay/src/auth/caps.rs index 0c8d11329e8..0c3fe335f65 100644 --- a/rs/moq-relay/src/auth/caps.rs +++ b/rs/moq-relay/src/auth/caps.rs @@ -88,7 +88,6 @@ pub struct Pacer(Arc); impl Pacer { /// Pace a live connection by calling `apply` with each new set of caps. - #[cfg(any(test, feature = "quic", all(target_os = "linux", feature = "_uring")))] pub(crate) fn new(apply: impl Fn(Caps) + Send + Sync + 'static) -> Self { Self(Arc::new(apply)) } diff --git a/rs/moq-relay/src/cluster.rs b/rs/moq-relay/src/cluster.rs index a04c3bb85ed..f8a90802a50 100644 --- a/rs/moq-relay/src/cluster.rs +++ b/rs/moq-relay/src/cluster.rs @@ -338,7 +338,6 @@ impl DialTarget { } /// A LAN peer's advertised addresses, each carrying that peer's credential. - #[cfg(feature = "cluster-lan")] fn from_lan_peer(peer: &moq_tokio::mdns::Peer) -> anyhow::Result { let mut urls = peer.urls(); anyhow::ensure!(!urls.is_empty(), "peer advertised no reachable address"); @@ -394,7 +393,6 @@ enum DialSource { Api, /// Discovered on the LAN via mDNS (`--cluster-lan`). Released as soon as the /// advertisement goes away. - #[cfg(feature = "cluster-lan")] Mdns, } @@ -403,7 +401,6 @@ enum DialSource { struct DialSources { seeded: Option, api: Option, - #[cfg(feature = "cluster-lan")] mdns: Option, } @@ -412,7 +409,6 @@ impl DialSources { match source { DialSource::Static => self.seeded.as_ref(), DialSource::Api => self.api.as_ref(), - #[cfg(feature = "cluster-lan")] DialSource::Mdns => self.mdns.as_ref(), } } @@ -421,7 +417,6 @@ impl DialSources { match source { DialSource::Static => self.seeded = Some(target), DialSource::Api => self.api = Some(target), - #[cfg(feature = "cluster-lan")] DialSource::Mdns => self.mdns = Some(target), } } @@ -430,7 +425,6 @@ impl DialSources { match source { DialSource::Static => self.seeded = None, DialSource::Api => self.api = None, - #[cfg(feature = "cluster-lan")] DialSource::Mdns => self.mdns = None, } } @@ -439,14 +433,11 @@ impl DialSources { /// first: operator intent, then the API list, then LAN discovery, whose /// targets come and go on their own. fn fallback(&self) -> Option<(DialSource, &DialTarget)> { - let fallback = self - .seeded + self.seeded .as_ref() .map(|target| (DialSource::Static, target)) - .or_else(|| self.api.as_ref().map(|target| (DialSource::Api, target))); - #[cfg(feature = "cluster-lan")] - let fallback = fallback.or_else(|| self.mdns.as_ref().map(|target| (DialSource::Mdns, target))); - fallback + .or_else(|| self.api.as_ref().map(|target| (DialSource::Api, target))) + .or_else(|| self.mdns.as_ref().map(|target| (DialSource::Mdns, target))) } } @@ -574,10 +565,8 @@ enum DialCommand { /// The latest valid `--cluster-api-url` peer list. Api(HashMap), /// A LAN peer this node should dial appeared or changed. - #[cfg(feature = "cluster-lan")] Found(DialTarget), /// A LAN peer's advertisement went away, by canonical key. - #[cfg(feature = "cluster-lan")] Lost(PeerKey), } @@ -831,7 +820,6 @@ pub struct Config { pub node: Option, /// LAN discovery over mDNS (`[cluster.lan]`). - #[cfg(feature = "cluster-lan")] #[usage(flatten)] #[serde(default)] pub lan: LanConfig, @@ -928,7 +916,6 @@ impl Config { #[serde_with::skip_serializing_none] #[serde(default, deny_unknown_fields)] #[non_exhaustive] -#[cfg(feature = "cluster-lan")] pub struct LanConfig { /// Enable mDNS discovery. Boolean flag: pass `--cluster-lan` (or `=true` / /// `=false`). Advertises the listener fingerprint when the certificate was @@ -972,7 +959,6 @@ pub struct LanConfig { pub app: Option, } -#[cfg(feature = "cluster-lan")] impl LanConfig { /// Reject a secret or app configured without the mesh that would read it. pub fn validate(&self) -> anyhow::Result<()> { @@ -1021,7 +1007,6 @@ impl LanAdvertise { /// The per-advertisement credential [`Connection::authenticate`] checks on /// `/.cluster/`. Shared via `Arc` so clones taken before /// [`Cluster::start`] still see it. -#[cfg(feature = "cluster-lan")] struct LanAuth { credential: String, } @@ -1066,7 +1051,7 @@ pub struct Options { /// The simulated host peer dials bind on, for tests over QUIC on `kio::clock::sim`; /// see [`moq_tokio::client::Config::sim`]. `None` binds UDP sockets. - #[cfg(all(feature = "test-support", feature = "quic"))] + #[cfg(feature = "test-support")] pub sim: Option, } @@ -1230,7 +1215,6 @@ struct Work { token: ClusterToken, http: Option, /// The live mDNS advertisement, bound by [`Cluster::start`]. - #[cfg(feature = "cluster-lan")] discovery: Option, } @@ -1286,9 +1270,7 @@ impl Mesh { let mut dial = dialer(&self.cluster, &self.token); match command { DialCommand::Api(desired) => self.dialed.reconcile_api(&desired, &mut dial), - #[cfg(feature = "cluster-lan")] DialCommand::Found(target) => self.dialed.upsert(target, DialSource::Mdns, &mut dial), - #[cfg(feature = "cluster-lan")] DialCommand::Lost(peer) => self.dialed.release(&peer, DialSource::Mdns, &mut dial), } // A replaced dial keeps its peer's `/nodes` history; a peer that left the @@ -1344,7 +1326,7 @@ pub struct Cluster { #[cfg(feature = "test-support")] network: Option, /// The simulated host peer dials bind on; see [`Options::sim`]. - #[cfg(all(feature = "test-support", feature = "quic"))] + #[cfg(feature = "test-support")] sim: Option, /// The client static and API peers share when the template binds a fixed /// `[connect]` port, so that port stays the cluster's egress port. Otherwise @@ -1357,7 +1339,6 @@ pub struct Cluster { advertise: Option, /// Set by [`Self::start`] when LAN discovery is on, so inbound /// `/.cluster/` can be verified on every clone. - #[cfg(feature = "cluster-lan")] lan_auth: Arc>, pub(crate) nodes: crate::nodes::Nodes, @@ -1469,7 +1450,7 @@ impl Cluster { stats_hold, #[cfg(feature = "test-support")] network, - #[cfg(all(feature = "test-support", feature = "quic"))] + #[cfg(feature = "test-support")] sim, } = options; let deprecated = config.deprecated(); @@ -1483,7 +1464,6 @@ impl Cluster { } crate::configured_tier(config.tier.clone()).context("invalid --cluster-tier")?; peer.quic.validate()?; - #[cfg(feature = "cluster-lan")] config.lan.validate()?; stats.check(&config)?; let mut work = kio::Tasks::new(); @@ -1534,12 +1514,11 @@ impl Cluster { quic: None, #[cfg(feature = "test-support")] network, - #[cfg(all(feature = "test-support", feature = "quic"))] + #[cfg(feature = "test-support")] sim, dial: None, dialers: Dialers::new(), advertise: None, - #[cfg(feature = "cluster-lan")] lan_auth: Arc::new(std::sync::OnceLock::new()), nodes, refusals: crate::refusals::Refusals::new(&stats), @@ -1747,10 +1726,7 @@ impl Cluster { /// Whether `--cluster-lan` asked this relay to discover peers over mDNS. fn lan(&self) -> bool { - #[cfg(feature = "cluster-lan")] - return self.config.lan.enabled; - #[cfg(not(feature = "cluster-lan"))] - false + self.config.lan.enabled } /// The credential a LAN path carries, if `path` is `/.cluster/`. @@ -1774,21 +1750,12 @@ impl Cluster { /// /// `None` means this cluster has no LAN discovery, so the path must be /// refused rather than routed through JWT or public prefixes. - #[cfg(feature = "cluster-lan")] pub(crate) fn verify_lan_credential(&self, presented: &str) -> Option { self.lan_auth .get() .map(|auth| moq_tokio::mdns::ct_eq(&auth.credential, presented)) } - /// Verify a presented `/.cluster/` against the live advertisement. - /// - /// Without the `cluster-lan` feature there is no discovery to consult. - #[cfg(not(feature = "cluster-lan"))] - pub(crate) fn verify_lan_credential(&self, _presented: &str) -> Option { - None - } - /// The grant a LAN peer gets once its membership proof checks out: everything, /// billed under `--cluster-tier`. The proof is a secret this relay minted for /// itself, so no auth server is asked. @@ -1839,7 +1806,6 @@ impl Cluster { pub async fn start(mut self) -> anyhow::Result { let node = self.config.node.clone(); let lan = self.lan(); - #[cfg(feature = "cluster-lan")] if lan { let advertise = self.advertise.as_ref(); anyhow::ensure!( @@ -1901,7 +1867,6 @@ impl Cluster { // Binds the multicast socket and reads the key, so it belongs here rather // than in `run`: both fail loudly, and the whole point of `--cluster-lan` is // that a relay which cannot join the mesh is misconfigured, not degraded. - #[cfg(feature = "cluster-lan")] let discovery = match lan { true => { let advertise = self @@ -1931,7 +1896,6 @@ impl Cluster { self.dial = shared.then(|| Arc::new(client)); // After everything fallible, so a failed start leaves no credential behind. - #[cfg(feature = "cluster-lan")] if let Some(discovery) = &discovery { let _ = self.lan_auth.set(LanAuth { credential: discovery.credential().to_string(), @@ -1943,7 +1907,6 @@ impl Cluster { http, node, token, - #[cfg(feature = "cluster-lan")] discovery, }), cluster: self, @@ -1958,7 +1921,6 @@ impl Cluster { http, node, token, - #[cfg(feature = "cluster-lan")] discovery, } = work; @@ -1988,7 +1950,6 @@ impl Cluster { })); } - #[cfg(feature = "cluster-lan")] if let Some(discovery) = discovery { // A dial ending is ordinary (that peer went away), but discovery ending is // the relay going blind, so `run_mdns` only returns an error. @@ -2006,7 +1967,6 @@ impl Cluster { /// pinned. The lower discovery id dials; the other waits inbound. A LAN dial /// never carries `?jwt=`: [`Config::token`] is for static and API peers /// only. - #[cfg(feature = "cluster-lan")] async fn run_mdns(commands: DialCommands, mut discovery: moq_tokio::mdns::Discovery) -> anyhow::Result<()> { use moq_tokio::mdns::Event; @@ -2384,7 +2344,7 @@ impl Cluster { let mut config = moq_tokio::client::Config::default(); config.connect = connect; config.quic = quic; - #[cfg(all(feature = "test-support", feature = "quic"))] + #[cfg(feature = "test-support")] { config.sim = self.sim.clone(); } @@ -2399,7 +2359,7 @@ impl Cluster { /// Start a reconnecting LAN session from discovered details. Tests wire this /// without multicast. - #[cfg(all(test, feature = "cluster-lan"))] + #[cfg(test)] fn dial_lan_target(&self, target: &DialTarget) -> anyhow::Result { let addrs = moq_tokio::Addrs::collect(target.addrs()).context("peer advertised no reachable address")?; let origin = self.origin.clone().with_link(origin::Link::Peer); @@ -2413,7 +2373,7 @@ impl Cluster { Ok(client.connect(addrs)) } - #[cfg(all(test, feature = "cluster-lan"))] + #[cfg(test)] fn set_lan_credential(&self, credential: impl Into) { let _ = self.lan_auth.set(LanAuth { credential: credential.into(), @@ -2423,7 +2383,6 @@ impl Cluster { /// Advertise this listener on the LAN: fingerprint when the certificate was /// generated, node URL when configured, secret when shared. -#[cfg(feature = "cluster-lan")] async fn lan_discovery( advertise: &LanAdvertise, node: Option<&str>, @@ -2682,7 +2641,6 @@ mod tests { } /// The next route and whether it is active. - #[cfg(feature = "cluster-lan")] async fn next_update(announced: &mut moq_net::origin::Routes) -> Option<(moq_net::announce::Announce, bool)> { match announced.next().await? { moq_net::origin::RouteEvent { @@ -3732,7 +3690,6 @@ mod tests { node: Some("https://B.example".to_string()), token: ClusterToken::default(), http: None, - #[cfg(feature = "cluster-lan")] discovery: None, }) .expect("mesh"); @@ -3742,7 +3699,6 @@ mod tests { } /// The nested `[cluster.lan]` table survives the TOML-to-CLI merge. - #[cfg(feature = "cluster-lan")] #[test] fn cluster_lan_survives_toml_merge() { // Usage reads the environment while parsing, so a variable in the developer's @@ -3772,7 +3728,6 @@ mod tests { /// A CLI flag overrides the same key from TOML, rather than the nesting /// hiding it from `update_from`. - #[cfg(feature = "cluster-lan")] #[test] fn cli_overrides_toml_cluster_lan() { if !test_env::Env::without(&["MOQ_CLUSTER_LAN", "MOQ_CLUSTER_LAN_SECRET", "MOQ_CLUSTER_LAN_APP"]).isolate() { @@ -3806,7 +3761,6 @@ mod tests { /// A path-capable client version that the listener does not offer cannot /// negotiate, so start-up must refuse it rather than retry forever. - #[cfg(feature = "cluster-lan")] #[test] fn lan_versions_must_overlap_on_a_path_capable_version() { let lite04: moq_net::Version = "moq-lite-04".parse().unwrap(); @@ -3830,7 +3784,6 @@ mod tests { /// A LAN mesh without a node URL still starts when the listener has a /// generated certificate to advertise. - #[cfg(feature = "cluster-lan")] #[tokio::test] async fn lan_without_node_needs_a_fingerprint() { let config = Config { @@ -3862,7 +3815,6 @@ mod tests { /// The secret is optional: without one the mesh is open, and start-up does /// not refuse it. Binding mDNS is skipped here by not attaching a client; /// the missing-fingerprint/node check still runs first. - #[cfg(feature = "cluster-lan")] #[tokio::test] async fn lan_without_a_secret_is_open() { let config = Config { @@ -3889,7 +3841,6 @@ mod tests { } /// A secret or app without the mesh is an error, not a silently ignored flag. - #[cfg(feature = "cluster-lan")] #[test] fn lan_secret_and_app_require_the_mesh() { assert!( @@ -3918,7 +3869,6 @@ mod tests { /// A LAN dial presents the peer's credential on the mesh path and drops /// `?jwt=` even when the advertised node URL carried one. - #[cfg(feature = "cluster-lan")] #[test] fn lan_dial_urls_carry_the_credential_not_the_token() { let mut url = Url::parse("https://relay.example.com/anon?jwt=secret&cost=2").expect("url"); @@ -3946,7 +3896,6 @@ mod tests { /// mDNS is just another wanter: a peer also reached by a static seed keeps /// its dial when the advertisement goes away, and only the last release /// tears it down. - #[cfg(feature = "cluster-lan")] #[test] fn mdns_release_respects_the_other_sources() { let mut dialed = DialMap::new(None); @@ -4067,7 +4016,6 @@ mod tests { /// exercise `run_mdns`, `Peer::urls()` order, or `discovery.should_dial`; /// the names "node" and "fingerprint" are the two origins, not two /// advertising modes. - #[cfg(feature = "cluster-lan")] #[tokio::test] async fn lan_cluster_path_carries_broadcasts_both_ways() { const TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10); @@ -4305,7 +4253,6 @@ mod tests { /// A QUIC endpoint that accepts the ALPNs of `connect` and speaks no MoQ, so a /// test sees the transport close of the dial itself. `idle` outlasts any wait. - #[cfg(feature = "quic")] fn bare_quic_server( connect: &moq_tokio::connect::Config, idle: std::time::Duration, @@ -4346,7 +4293,6 @@ mod tests { /// Cancelling `run` aborts the dials a peer list started, which run outside /// the tasks of `run` itself, so none keeps redialing with nothing left to close it. - #[cfg(feature = "quic")] #[tokio::test] async fn cancelling_run_stops_its_dynamic_dials() { const TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10); @@ -4394,7 +4340,6 @@ mod tests { /// caller consumed the cluster, so nothing else could. The dialing runtime stops /// right after, as a process exit would, and the peer's idle timeout is far past /// the wait, so only the close explains the link ending. - #[cfg(feature = "quic")] #[tokio::test] async fn a_critical_failure_closes_the_dials() { use moq_tokio::quic::driver; @@ -4489,7 +4434,6 @@ mod tests { /// A LAN dial owns its client, so closing the cluster closes that too: the peer /// drops the dialer's routes at once, though the dialing runtime stops right /// after, as a process exit would. Both idle timeouts are far past the wait. - #[cfg(feature = "cluster-lan")] #[tokio::test] async fn closing_a_cluster_closes_its_lan_dials() { const TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10); @@ -4660,7 +4604,6 @@ mod tests { } /// A `/.cluster` request on a cluster without LAN discovery is refused. - #[cfg(feature = "cluster-lan")] #[tokio::test] async fn lan_path_without_discovery_is_refused() { assert_eq!( diff --git a/rs/moq-relay/src/config.rs b/rs/moq-relay/src/config.rs index 23f496df01b..9de03a513a3 100644 --- a/rs/moq-relay/src/config.rs +++ b/rs/moq-relay/src/config.rs @@ -329,7 +329,6 @@ impl Config { self.check_runtime()?; self.check_handoff()?; self.stats.check(&self.cluster)?; - #[cfg(feature = "cluster-lan")] self.check_lan()?; self.quic @@ -364,18 +363,8 @@ impl Config { ); #[cfg(not(target_os = "linux"))] anyhow::ensure!(!io_uring, "runtime.io_uring is Linux-only"); - #[cfg(all(target_os = "linux", not(feature = "_uring")))] - anyhow::ensure!( - !io_uring, - "runtime.io_uring needs moq-relay built with the `io-uring` feature" - ); // Refused rather than ignored: a group is the whole point of the setting, and // silently serving from the shared runtime instead would look like it worked. - #[cfg(not(feature = "_quic"))] - anyhow::ensure!( - io_uring || !workers, - "runtime.workers needs moq-relay built with the `quic` feature" - ); Ok(()) } @@ -408,17 +397,15 @@ impl Config { } /// Refuse LAN discovery this relay cannot advertise or dial. - #[cfg(feature = "cluster-lan")] fn check_lan(&self) -> anyhow::Result<()> { if !self.cluster.lan.enabled { return Ok(()); } // The io_uring workers always bind QUIC (`check_runtime` requires their bind). The - // tokio listener and workers need the `quic` feature, and the workers bind the - // default address when `--listen` is unset. + // tokio workers bind the default address when `--listen` is unset. let tokio = self.listen.serves_quic() || self.runtime.workers().is_some(); anyhow::ensure!( - self.runtime.io_uring() || (cfg!(feature = "_quic") && tokio), + self.runtime.io_uring() || tokio, "--cluster-lan needs a QUIC listener (--listen) to advertise. See https://doc.moq.dev/bin/relay/cluster." ); // A fingerprint is advertised only for a certificate generated or supplied in memory. @@ -907,7 +894,7 @@ root = ["ca.pem"] "[handoff]\nsupervise = true\n", "handoff.supervise needs handoff.socket", ); - #[cfg(all(target_os = "linux", feature = "_quic"))] + #[cfg(target_os = "linux")] { // The QUIC port is handed on as a worker group, which the shared listener is not. let quic = "[listen]\nbind = \"127.0.0.1:0\"\n"; @@ -942,7 +929,7 @@ root = ["ca.pem"] } /// LAN discovery needs a QUIC port and an identity to advertise. - #[cfg(all(feature = "cluster-lan", feature = "uds", unix))] + #[cfg(unix)] #[test] fn lan_discovery_needs_something_to_advertise() { let refuse = |body: &str, needle: &str| { @@ -955,18 +942,12 @@ root = ["ca.pem"] &format!("{node}[listen.unix]\nbind = \"relay.sock\"\n"), "needs a QUIC listener", ); - // The default listener is QUIC only in a build with a QUIC backend for it. - #[cfg(not(feature = "_quic"))] - refuse(node, "needs a QUIC listener"); - #[cfg(feature = "_quic")] - { - refuse("[cluster.lan]\nenabled = true\n", "--cluster-node"); - let workers = format!("{node}[listen.unix]\nbind = \"relay.sock\"\n[runtime]\nworkers = 1\n"); - let config: Config = toml::from_str(&workers).expect("parse"); - config.resolve().expect("workers serve QUIC on the default address"); - let config: Config = toml::from_str(node).expect("parse"); - config.resolve().expect("a node URL and the default QUIC listener"); - } + refuse("[cluster.lan]\nenabled = true\n", "--cluster-node"); + let workers = format!("{node}[listen.unix]\nbind = \"relay.sock\"\n[runtime]\nworkers = 1\n"); + let config: Config = toml::from_str(&workers).expect("parse"); + config.resolve().expect("workers serve QUIC on the default address"); + let config: Config = toml::from_str(node).expect("parse"); + config.resolve().expect("a node URL and the default QUIC listener"); } /// The canonical top-level table, which is what the demo configs use. @@ -1099,7 +1080,6 @@ io_uring = false ws = false "#; - #[cfg(feature = "websocket")] let toml = format!("{toml}\n[connect.websocket]\nenabled = false\n"); let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("runtime-toml-wins.toml"); @@ -1118,7 +1098,6 @@ ws = false "TOML's runtime.io_uring=false must survive the merge" ); assert!(!config.web.ws, "TOML's web.ws=false must survive the merge"); - #[cfg(feature = "websocket")] assert_eq!( config.connect.websocket.enabled, Some(false), @@ -1131,14 +1110,12 @@ ws = false std::ffi::OsString::from("--runtime-pin=true"), std::ffi::OsString::from("--runtime-workers=auto"), std::ffi::OsString::from("--web-ws=true"), - #[cfg(feature = "websocket")] std::ffi::OsString::from("--connect-websocket-enabled=true"), ]; let config = Config::parse_and_merge(args).expect("config load"); assert!(config.runtime.pin); assert_eq!(config.runtime.workers, crate::runtime::Workers::Auto); assert!(config.web.ws); - #[cfg(feature = "websocket")] assert_eq!(config.connect.websocket.enabled, Some(true)); } @@ -1535,7 +1512,7 @@ ws = false check: |config| assert_eq!(config.listen.preferred_v4, Some("192.0.2.1:443".parse().unwrap())), source: "preferred_v4", }, - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] Case { name: "int-list-from-file", toml: "[listen.unix]\nbind = \"/run/moq/internal.sock\"\n\n[listen.unix.allow]\nuid = [1001]\n", @@ -1550,7 +1527,6 @@ ws = false }, source: "uid", }, - #[cfg(feature = "cluster-lan")] Case { name: "newtype-from-file", toml: "[cluster.lan]\nenabled = true\napp = \"custom\"\n", @@ -1729,7 +1705,6 @@ ws = false "requires --listen-quic-lb-id", ); - #[cfg(feature = "quic")] { let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("typed.toml"); diff --git a/rs/moq-relay/src/handoff.rs b/rs/moq-relay/src/handoff.rs index 059e0c8ab48..e8f546dafc1 100644 --- a/rs/moq-relay/src/handoff.rs +++ b/rs/moq-relay/src/handoff.rs @@ -324,7 +324,6 @@ mod imp { /// The QUIC port's reuseport group on `addr`: the predecessor's, or a fresh one /// of `count` members with room for a successor. - #[cfg(any(feature = "_quic", feature = "_uring"))] pub(crate) fn group(&mut self, addr: SocketAddr, count: u16) -> anyhow::Result> { if !self.enabled() { return Ok(None); @@ -394,7 +393,6 @@ mod imp { /// The tokio QUIC workers: on the predecessor's group, or a fresh one with room /// for a successor when handoff is on. - #[cfg(feature = "_quic")] pub(crate) fn workers( &mut self, server: moq_tokio::server::Config, @@ -924,7 +922,6 @@ mod imp { false } - #[cfg(feature = "_quic")] pub(crate) fn workers( &mut self, server: moq_tokio::server::Config, @@ -941,7 +938,7 @@ mod imp { Ok(None) } - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] pub(crate) fn unix( &mut self, _role: Role, diff --git a/rs/moq-relay/src/incoming.rs b/rs/moq-relay/src/incoming.rs index aef9192dbe4..d065b759781 100644 --- a/rs/moq-relay/src/incoming.rs +++ b/rs/moq-relay/src/incoming.rs @@ -10,7 +10,7 @@ pub trait Incoming: Sealed {} impl Incoming for moq_tokio::server::Request {} -#[cfg(all(target_os = "linux", feature = "_uring"))] +#[cfg(target_os = "linux")] impl Incoming for crate::uring::Request {} #[cfg(feature = "test-support")] @@ -122,7 +122,6 @@ impl Sealed for moq_tokio::server::Request { let _ = moq_tokio::server::Request::reject(self, code).await; } - #[cfg(feature = "quic")] fn pacer(&self) -> Option { let quic = moq_tokio::server::Request::quic_limits(self)?; Some(auth::Pacer::new(move |caps| { @@ -132,7 +131,6 @@ impl Sealed for moq_tokio::server::Request { })) } - #[cfg(feature = "quic")] fn with_quic_limits(self, limits: moq_quic::Limits) -> anyhow::Result { Ok(moq_tokio::server::Request::with_quic_limits(self, limits)?) } diff --git a/rs/moq-relay/src/internal.rs b/rs/moq-relay/src/internal.rs index fa900fa8177..9aec67fc184 100644 --- a/rs/moq-relay/src/internal.rs +++ b/rs/moq-relay/src/internal.rs @@ -54,11 +54,11 @@ use prometheus_client::{ /// list is always empty there and the renderer skips itself, rather than /// `cfg`-ing the two fields, the two struct literals that fill them, and the /// renderer's signature separately. -#[cfg(all(target_os = "linux", feature = "_uring"))] +#[cfg(target_os = "linux")] type UringWorker = moq_uring::metrics::Metrics; /// One io_uring worker's counters. See the io_uring build's alias. -#[cfg(not(all(target_os = "linux", feature = "_uring")))] +#[cfg(not(target_os = "linux"))] type UringWorker = std::convert::Infallible; /// Configuration for the internal (ops) listener. @@ -98,7 +98,6 @@ pub struct Internal { health: moq_tokio::accept::Health, listeners: Vec, uring: Vec, - #[cfg(feature = "_quic")] demux: Option, shutdown: Option, listener: Option, @@ -113,7 +112,6 @@ struct InternalState { sessions: crate::session::Registry, listeners: Vec, uring: Vec, - #[cfg(feature = "_quic")] demux: Option, shutdown: Option, } @@ -142,7 +140,6 @@ impl Internal { health, listeners, uring: Vec::new(), - #[cfg(feature = "_quic")] demux: None, shutdown: None, listener: None, @@ -150,7 +147,6 @@ impl Internal { } } - #[cfg(feature = "_quic")] pub(crate) fn with_demux(mut self, counters: Option) -> Self { self.demux = counters; self @@ -233,7 +229,7 @@ impl Internal { /// Register them before the threads start, so a worker that never came up /// (or has died) still has a series that has stopped moving rather than no /// series at all. - #[cfg(all(target_os = "linux", feature = "_uring"))] + #[cfg(target_os = "linux")] pub(crate) fn with_uring(mut self, workers: impl IntoIterator) -> Self { self.uring.extend(workers); self @@ -282,7 +278,6 @@ impl Internal { sessions: self.sessions.clone(), listeners: self.listeners.clone(), uring: self.uring.clone(), - #[cfg(feature = "_quic")] demux: self.demux.clone(), shutdown: self.shutdown.clone(), }) @@ -449,10 +444,7 @@ async fn serve_health() -> Response { /// counts (`open - closed`). async fn serve_metrics(State(state): State) -> Response { let mut scrape = Scrape::new(state.stats.snapshot(), &state.listeners, &state.uring); - #[cfg(feature = "_quic")] - { - scrape.demux = state.demux; - } + scrape.demux = state.demux; scrape.draining = state.shutdown.map(|shutdown| shutdown.draining_count()); scrape.refusals = state.refusals.map(|refusals| refusals.snapshot()); ( @@ -585,7 +577,6 @@ struct Scrape { stats: moq_net::stats::Snapshot, listeners: Vec, uring: Vec, - #[cfg(feature = "_quic")] demux: Option, draining: Option, refusals: Option, @@ -595,7 +586,6 @@ struct Scrape { /// Datagrams the QUIC port dropped instead of handing to QUIC or the WebRTC feed, /// one row per reason from zero. `unclaimed` is WebRTC traffic while no embedder /// takes the feed, which is every WebRTC datagram on a bare relay. -#[cfg(feature = "_quic")] fn encode_demux(encoder: &mut DescriptorEncoder, counters: &moq_tokio::quic::demux::Counters) -> std::fmt::Result { counter( encoder, @@ -613,7 +603,6 @@ impl Scrape { stats, listeners: listeners.to_vec(), uring: uring.to_vec(), - #[cfg(feature = "_quic")] demux: None, draining: None, refusals: None, @@ -630,7 +619,6 @@ impl Scrape { self.encode_sessions(encoder)?; encode_accepts(encoder, &self.listeners)?; encode_uring(encoder, &self.uring)?; - #[cfg(feature = "_quic")] if let Some(demux) = &self.demux { encode_demux(encoder, demux)?; } @@ -895,7 +883,7 @@ fn encode_accepts(encoder: &mut DescriptorEncoder, listeners: &[moq_tokio::accep /// exists for. The pool gauges are the buffer space each worker has allocated, /// which stays at its high-water mark after a burst; only the pages datagrams /// have touched count toward RSS. -#[cfg(all(target_os = "linux", feature = "_uring"))] +#[cfg(target_os = "linux")] fn encode_uring(encoder: &mut DescriptorEncoder, workers: &[UringWorker]) -> std::fmt::Result { use moq_uring::metrics::Snapshot; @@ -1058,17 +1046,17 @@ fn encode_uring(encoder: &mut DescriptorEncoder, workers: &[UringWorker]) -> std /// Off the io_uring path there are no workers to describe, and [`UringWorker`] /// is uninhabited, so the list handed here is always empty. -#[cfg(not(all(target_os = "linux", feature = "_uring")))] +#[cfg(not(target_os = "linux"))] fn encode_uring(_encoder: &mut DescriptorEncoder, _workers: &[UringWorker]) -> std::fmt::Result { Ok(()) } /// An io_uring worker's histogram, whose cumulative buckets the encoder takes as /// per-bucket counts. -#[cfg(all(target_os = "linux", feature = "_uring"))] +#[cfg(target_os = "linux")] struct Distribution(moq_uring::metrics::Histogram); -#[cfg(all(target_os = "linux", feature = "_uring"))] +#[cfg(target_os = "linux")] impl EncodeMetric for Distribution { fn encode(&self, mut encoder: prometheus_client::encoding::MetricEncoder) -> std::fmt::Result { let mut below = 0; @@ -1256,7 +1244,6 @@ mod tests { /// Every drop reason renders from zero, and only for a relay whose QUIC port /// runs the demux. - #[cfg(feature = "_quic")] #[tokio::test] async fn demux_metrics_list_every_reason_from_zero() { use moq_tokio::quic::demux::{Counters, Discard}; @@ -1422,7 +1409,7 @@ mod tests { /// yet is empty rather than zero, so an alert on a worker whose receive pool /// has started running dry is unwritable until it has already happened. A /// worker that never started has to publish stuck zeros, not nothing. - #[cfg(all(target_os = "linux", feature = "_uring"))] + #[cfg(target_os = "linux")] #[test] fn uring_metrics_list_every_worker_from_zero() { let workers = vec![ @@ -1503,7 +1490,7 @@ mod tests { } /// A worker's cumulative buckets come out cumulative again, not summed twice. - #[cfg(all(target_os = "linux", feature = "_uring"))] + #[cfg(target_os = "linux")] #[test] fn uring_histograms_keep_cumulative_buckets() { let histogram = moq_uring::metrics::Histogram { @@ -1601,7 +1588,6 @@ mod tests { sessions: crate::session::Registry::new(), listeners: Vec::new(), uring: Vec::new(), - #[cfg(feature = "_quic")] demux: None, shutdown: None, }; @@ -1621,7 +1607,6 @@ mod tests { sessions: crate::session::Registry::new(), listeners: Vec::new(), uring: Vec::new(), - #[cfg(feature = "_quic")] demux: None, shutdown: None, }; @@ -2027,11 +2012,10 @@ mod tests { refusals: Some(refusals), sessions: crate::session::Registry::new(), listeners: vec![moq_tokio::accept::Health::new("tcp")], - #[cfg(all(target_os = "linux", feature = "_uring"))] + #[cfg(target_os = "linux")] uring: vec![moq_uring::metrics::Metrics::default()], - #[cfg(not(all(target_os = "linux", feature = "_uring")))] + #[cfg(not(target_os = "linux"))] uring: Vec::new(), - #[cfg(feature = "_quic")] demux: Some(moq_tokio::quic::demux::Counters::default()), shutdown: Some(shutdown), }; @@ -2048,9 +2032,8 @@ mod tests { actual.remove(panics); let mut expected: Vec = EXPECTED_SERIES.trim().lines().map(str::to_string).collect(); - #[cfg(all(target_os = "linux", feature = "_uring"))] + #[cfg(target_os = "linux")] expected.extend(EXPECTED_URING_SERIES.trim().lines().map(str::to_string)); - #[cfg(feature = "_quic")] expected.extend(EXPECTED_DEMUX_SERIES.trim().lines().map(str::to_string)); expected.sort(); assert_eq!(actual, expected, "{body}"); @@ -2142,7 +2125,7 @@ gauge moq_relay_sessions_connected{state="active",tier="edge"} 0 gauge moq_relay_sessions_connected{state="idle",tier="edge"} 1 "#; - #[cfg(all(target_os = "linux", feature = "_uring"))] + #[cfg(target_os = "linux")] const EXPECTED_URING_SERIES: &str = r#" # TYPE moq_relay_uring_completions_total counter # TYPE moq_relay_uring_cqes_per_enter histogram @@ -2220,7 +2203,6 @@ histogram moq_relay_uring_sqes_per_enter_count{worker="0"} 0 histogram moq_relay_uring_sqes_per_enter_sum{worker="0"} 0 "#; - #[cfg(feature = "_quic")] const EXPECTED_DEMUX_SERIES: &str = r#" # TYPE moq_relay_demux_dropped_total counter counter moq_relay_demux_dropped_total{reason="overflow"} 0 diff --git a/rs/moq-relay/src/lib.rs b/rs/moq-relay/src/lib.rs index c349e9ee7c4..dc7eb540eb6 100644 --- a/rs/moq-relay/src/lib.rs +++ b/rs/moq-relay/src/lib.rs @@ -35,11 +35,10 @@ pub mod shutdown; pub mod stats; #[cfg(feature = "test-support")] mod test_support; -#[cfg(all(target_os = "linux", feature = "_uring"))] +#[cfg(target_os = "linux")] pub(crate) mod uring; /// The HTTP/HTTPS server: health, certificate fingerprint, announcements, fetch, and WebSocket sessions. pub mod web; -#[cfg(feature = "websocket")] mod websocket; /// The shared default stream limit for MoQ clients and relays. diff --git a/rs/moq-relay/src/listener.rs b/rs/moq-relay/src/listener.rs index dac84f2a581..41bc878e377 100644 --- a/rs/moq-relay/src/listener.rs +++ b/rs/moq-relay/src/listener.rs @@ -18,7 +18,6 @@ mod demux; mod idle; pub(crate) use demux::{Classified, Stream, Tls, classify}; pub(crate) use idle::Admission; -#[cfg(feature = "websocket")] pub(crate) use idle::Io; use std::{ @@ -45,7 +44,7 @@ impl Accepted { } } -#[cfg(all(test, unix, feature = "websocket"))] +#[cfg(all(test, unix))] impl Accepted { /// A socket accepted outside [`Listener`], holding no admission. pub(crate) fn new(stream: TcpStream) -> Self { diff --git a/rs/moq-relay/src/listener/idle.rs b/rs/moq-relay/src/listener/idle.rs index 786b91613c9..9bd4986ac2a 100644 --- a/rs/moq-relay/src/listener/idle.rs +++ b/rs/moq-relay/src/listener/idle.rs @@ -187,7 +187,6 @@ pub(crate) struct Io { impl Io { /// The stream underneath, once HTTP has handed it to another protocol and no longer /// needs the idle deadline. - #[cfg(feature = "websocket")] #[allow( dead_code, reason = "the http_idle benchmark includes this module without the WebSocket route" diff --git a/rs/moq-relay/src/relay.rs b/rs/moq-relay/src/relay.rs index 677a8bb5a3d..a621fde49be 100644 --- a/rs/moq-relay/src/relay.rs +++ b/rs/moq-relay/src/relay.rs @@ -109,17 +109,15 @@ pub struct Relay { /// The thread-per-core QUIC workers, already bound and waiting to be split /// and run. `None` unless `runtime.workers` is configured, in which case /// `server` carries no QUIC listener of its own. - #[cfg(feature = "_quic")] workers: Option, /// The io_uring QUIC workers, already bound and waiting for /// [`serve`](crate::uring::Spawned::serve). `None` unless both /// `runtime.workers` and `runtime.io_uring` are configured, in which case /// they own the QUIC listen address instead of `workers`. - #[cfg(all(target_os = "linux", feature = "_uring"))] + #[cfg(target_os = "linux")] uring: Option, /// The tokio QUIC listener's demux, which every worker shares. `None` when /// nothing on tokio serves QUIC: a stream-only relay, or the io_uring workers. - #[cfg(feature = "_quic")] demux: Option, /// The sockets this relay hands to the relay that replaces it. `None` unless /// `handoff.socket` is set. @@ -180,10 +178,6 @@ impl Relay { // Bind the QUIC workers first: they own the listen address when configured, // so the server below must not also try to bind it. - #[cfg_attr( - not(feature = "_quic"), - allow(unused_variables, reason = "only the worker groups read it") - )] let io_uring = config.runtime.io_uring(); // Workers and the stream server split one relay across listeners, so they share @@ -196,10 +190,8 @@ impl Relay { // Shared by whichever tokio listener serves QUIC, so one feed and one set of // counters covers every worker. - #[cfg(feature = "_quic")] let demux = moq_tokio::quic::demux::Demux::default(); - #[cfg(feature = "_quic")] let workers = match config.runtime.workers() { Some(worker) if !io_uring => { let mut server = moq_tokio::server::Config::default(); @@ -216,16 +208,10 @@ impl Relay { // What the rest of setup reads off the group, so it has one shape whether or // not a QUIC backend gave us one to read. - #[cfg(feature = "_quic")] let workers_addr = workers.as_ref().map(moq_tokio::worker::Workers::local_addr); - #[cfg(not(feature = "_quic"))] - let workers_addr: Option = None; - #[cfg(feature = "_quic")] let workers_certificates = workers.as_ref().map(moq_tokio::worker::Workers::certificates); - #[cfg(not(feature = "_quic"))] - let workers_certificates: Option = None; - #[cfg(all(target_os = "linux", feature = "_uring"))] + #[cfg(target_os = "linux")] let uring = match config.runtime.workers() { Some(worker) if io_uring => { let mut server = moq_tokio::server::Config::default(); @@ -240,16 +226,16 @@ impl Relay { _ => None, }; - #[cfg(all(target_os = "linux", feature = "_uring"))] + #[cfg(target_os = "linux")] let quic_owned_elsewhere = workers_addr.is_some() || uring.is_some(); - #[cfg(not(all(target_os = "linux", feature = "_uring")))] + #[cfg(not(target_os = "linux"))] let quic_owned_elsewhere = workers_addr.is_some(); let mut server_config = moq_tokio::server::Config::default(); if let Some(addr) = listen.tcp.bind { server_config.streams.tcp = sockets.tcp(crate::handoff::Role::Tcp, addr)?; } - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] if let Some(path) = &listen.unix.bind { server_config.streams.unix = sockets.unix(crate::handoff::Role::Unix, path)?; } @@ -257,19 +243,16 @@ impl Relay { server_config.tls = served; server_config.quic = config.quic.clone(); server_config.admission = shutdown.admission.clone(); - #[cfg(feature = "_quic")] - { - server_config.demux = demux.clone(); - } + server_config.demux = demux.clone(); let server = match quic_owned_elsewhere { true => server_config.init_streams()?, false => server_config.init()?, }; // `None` for a stream-only server (no QUIC); any other error is real. - #[cfg(all(target_os = "linux", feature = "_uring"))] + #[cfg(target_os = "linux")] let uring_addr = uring.as_ref().map(crate::uring::Workers::local_addr); - #[cfg(not(all(target_os = "linux", feature = "_uring")))] + #[cfg(not(target_os = "linux"))] let uring_addr: Option = None; let addr = match (workers_addr, uring_addr) { (Some(addr), _) => Some(addr), @@ -283,17 +266,17 @@ impl Relay { // The io_uring workers serve QUIC without the demux, and a stream-only relay // has no UDP port at all. - #[cfg(all(feature = "_quic", target_os = "linux", feature = "_uring"))] + #[cfg(target_os = "linux")] let demux = (addr.is_some() && uring.is_none()).then_some(demux); - #[cfg(all(feature = "_quic", not(all(target_os = "linux", feature = "_uring"))))] + #[cfg(not(target_os = "linux"))] let demux = addr.is_some().then_some(demux); let cache = config.cache.init()?; // Whichever worker group owns QUIC holds the certificates; the shared // server then has none of its own. - #[cfg(all(target_os = "linux", feature = "_uring"))] + #[cfg(target_os = "linux")] let uring_certificates = uring.as_ref().map(crate::uring::Workers::certificates); - #[cfg(not(all(target_os = "linux", feature = "_uring")))] + #[cfg(not(target_os = "linux"))] let uring_certificates: Option = None; let certificates = match (workers_certificates, uring_certificates) { (Some(certificates), _) => certificates, @@ -368,12 +351,11 @@ impl Relay { .with_listeners(web.accept_health()) .with_listeners(server.accept_health()) .bind()?; - #[cfg(feature = "_quic")] let internal = internal.with_demux(demux.as_ref().map(|demux| demux.counters().clone())); // Bound but not yet serving: registering here (rather than after the // threads start) is what gives every worker a series from the first // scrape, including one that is about to fail setup. - #[cfg(all(target_os = "linux", feature = "_uring"))] + #[cfg(target_os = "linux")] let internal = match uring.as_ref() { Some(uring) => internal.with_uring(uring.metrics()), None => internal, @@ -406,11 +388,9 @@ impl Relay { web_routes: None, internal_routes: None, sessions, - #[cfg(feature = "_quic")] workers, - #[cfg(all(target_os = "linux", feature = "_uring"))] + #[cfg(target_os = "linux")] uring, - #[cfg(feature = "_quic")] demux, handoff, alone, @@ -470,7 +450,6 @@ impl Relay { /// dropped and counted. `None` once taken, or when no tokio listener serves /// QUIC: a stream-only relay, or one on the io_uring workers, which do not /// split the port yet. - #[cfg(feature = "_quic")] pub fn webrtc(&mut self) -> Option { self.demux.take().map(|demux| demux.webrtc()) } @@ -628,9 +607,8 @@ impl Relay { web_routes, internal_routes, sessions, - #[cfg(feature = "_quic")] workers, - #[cfg(all(target_os = "linux", feature = "_uring"))] + #[cfg(target_os = "linux")] uring, handoff, alone, @@ -657,7 +635,7 @@ impl Relay { // before it: an unsupported kernel, a refused ring, or a certificate // identity rustls will not load fails here, and reporting ready first would // release the units depending on a relay that is about to exit. - #[cfg(all(target_os = "linux", feature = "_uring"))] + #[cfg(target_os = "linux")] let mut uring = uring .map(|uring| { uring @@ -692,7 +670,7 @@ impl Relay { false => None, }; - #[cfg(all(target_os = "linux", feature = "_uring"))] + #[cfg(target_os = "linux")] if let Some(uring) = uring.as_mut() { uring.serve(); } @@ -717,9 +695,9 @@ impl Relay { #[cfg(not(feature = "jemalloc"))] let jemalloc = std::future::pending::>(); - #[cfg(all(target_os = "linux", feature = "_uring"))] + #[cfg(target_os = "linux")] let uring_serving = uring.is_some(); - #[cfg(all(target_os = "linux", feature = "_uring"))] + #[cfg(target_os = "linux")] let uring_failed = { let uring = uring.as_mut(); async move { @@ -729,20 +707,18 @@ impl Relay { } } }; - #[cfg(not(all(target_os = "linux", feature = "_uring")))] + #[cfg(not(target_os = "linux"))] let uring_failed = std::future::pending::(); // Each worker serves from its own thread, so the future built here only // reports the outcome. The group owns those threads and ends serving // when the first member finishes, so it has to outlive the loop below // and is torn down after it. - #[cfg(feature = "_quic")] let mut workers = workers.map(|workers| workers.split()); // Pends forever with no workers, so it composes into the `select!` either // way. A worker only stops on error or on shutdown, so the first one to // finish ends the relay the same way the shared accept loop does. - #[cfg(feature = "_quic")] let quic_workers = { let mut running = futures::stream::FuturesUnordered::new(); if let Some(workers) = workers.as_mut() { @@ -772,22 +748,17 @@ impl Relay { }; // No group to run, so this leg never resolves and the shared accept loop // below decides the `select!` on its own. - #[cfg(not(feature = "_quic"))] - let quic_workers = std::future::pending::>(); - #[cfg(feature = "_quic")] let has_workers = workers.is_some(); - #[cfg(not(feature = "_quic"))] - let has_workers = false; // With the QUIC listener owned by a worker group, the shared server has // only the `tcp`/`unix` stream listeners left, and a config with none // of those has nothing to accept: its loop would fail with // `NoBackend` immediately and take the healthy relay down. Pend instead; // the workers are what serve. - #[cfg(all(target_os = "linux", feature = "_uring"))] + #[cfg(target_os = "linux")] let quic_on_workers = has_workers || uring_serving; - #[cfg(not(all(target_os = "linux", feature = "_uring")))] + #[cfg(not(target_os = "linux"))] let quic_on_workers = has_workers; // Set once the relay replacing this one serves: every accept loop stops, since // that relay accepts on the same sockets, and the drain starts. @@ -865,11 +836,10 @@ impl Relay { // Explicitly, so the joins land on the blocking pool rather than on the // executor thread this future happens to be running on. - #[cfg(feature = "_quic")] if let Some(workers) = workers { workers.shutdown().await; } - #[cfg(all(target_os = "linux", feature = "_uring"))] + #[cfg(target_os = "linux")] if let Some(uring) = uring { uring.shutdown().await; } @@ -944,7 +914,6 @@ async fn drain( /// /// The accept loop for a single [`moq_tokio::Server`]. [`Relay::run`] owns /// worker selection and shutdown for embedders. -#[cfg(feature = "_quic")] async fn serve( server: moq_tokio::Server, cluster: cluster::Cluster, @@ -1111,19 +1080,4 @@ mod tests { let err = relay.run().await.expect_err("the relay kept running"); assert_eq!(err.root_cause().to_string(), "origin driver panicked: injected"); } - - #[cfg(not(feature = "_quic"))] - #[tokio::test] - async fn workers_require_a_quic_backend() { - let mut config = crate::Config::default(); - config.runtime.workers = crate::runtime::Workers::Count(std::num::NonZeroU16::new(1).unwrap()); - let error = match super::Relay::load(config).await { - Ok(_) => panic!("workers accepted without a QUIC backend"), - Err(error) => error, - }; - assert_eq!( - error.to_string(), - "runtime.workers needs moq-relay built with the `quic` feature" - ); - } } diff --git a/rs/moq-relay/src/shutdown.rs b/rs/moq-relay/src/shutdown.rs index 0853065ec37..876657d22c8 100644 --- a/rs/moq-relay/src/shutdown.rs +++ b/rs/moq-relay/src/shutdown.rs @@ -562,7 +562,6 @@ mod tests { /// A WebSocket peer that upgrades and never sends SETUP ends at the drain /// deadline even with the SETUP timeout disabled, so its task does not /// outlive the relay. - #[cfg(all(feature = "quic", feature = "websocket"))] #[tokio::test] async fn withheld_websocket_setup_ends_at_the_deadline() { let window = Duration::from_secs(1); diff --git a/rs/moq-relay/src/stats.rs b/rs/moq-relay/src/stats.rs index 17478280a04..032b293b7ae 100644 --- a/rs/moq-relay/src/stats.rs +++ b/rs/moq-relay/src/stats.rs @@ -128,10 +128,7 @@ impl Config { .map(Path::new) .transpose() .context("invalid stats.node")?; - #[cfg(feature = "cluster-lan")] let lan = cluster.lan.enabled; - #[cfg(not(feature = "cluster-lan"))] - let lan = false; let clustered = !cluster.connect.is_empty() || cluster.api.url.is_some() || cluster.node.is_some() || lan; // An empty name is the root path, which publishes the shared unnamed broadcast. anyhow::ensure!( diff --git a/rs/moq-relay/src/web.rs b/rs/moq-relay/src/web.rs index 005bac72ebc..30252983034 100644 --- a/rs/moq-relay/src/web.rs +++ b/rs/moq-relay/src/web.rs @@ -435,7 +435,6 @@ impl Web { // the root route, axum's wildcard never matches `/`, the request falls // through to the landing page, and the client's WS fallback is silently // dead. - #[cfg(feature = "websocket")] let app = if self.config.resolved_ws() { app.route("/", axum::routing::any(crate::websocket::serve_ws)) .route("/{*path}", axum::routing::any(crate::websocket::serve_ws)) @@ -622,17 +621,9 @@ fn build_https_config( /// /// Absent on platforms with no readable TCP info, and on any socket the read fails /// for; handlers extract `Option>` accordingly. -#[cfg(feature = "websocket")] #[derive(Clone)] pub(crate) struct SocketStats(pub(crate) qmux::SharedSocketStats); -/// Without the `websocket` feature there is no qmux to hand a socket to, so this -/// carries nothing and is never constructed. Keeping the type present either way -/// lets the acceptor and its service stay free of feature gates. -#[cfg(not(feature = "websocket"))] -#[derive(Clone)] -pub(crate) struct SocketStats(std::convert::Infallible); - /// The client certificate HTTPS mTLS verified, inserted as a request extension. /// /// Embedded routes can extract `Option>` to mirror the @@ -785,14 +776,14 @@ impl Accept for WebAcceptor { /// The kernel's view of `stream`, when this platform exposes one and there is a /// qmux session that could use it. -#[cfg(all(any(target_os = "linux", target_os = "macos"), feature = "websocket"))] +#[cfg(any(target_os = "linux", target_os = "macos"))] fn socket_stats(stream: &tokio::net::TcpStream) -> Option { qmux::TcpStats::new(stream) .ok() .map(|s| SocketStats(std::sync::Arc::new(s))) } -#[cfg(not(all(any(target_os = "linux", target_os = "macos"), feature = "websocket")))] +#[cfg(not(any(target_os = "linux", target_os = "macos")))] fn socket_stats(_stream: &tokio::net::TcpStream) -> Option { None } @@ -1218,7 +1209,7 @@ mod tests { } /// The state an acceptor built outside [`Web::serve`] hands a `tls://` session. - #[cfg(all(feature = "websocket", any(unix, windows)))] + #[cfg(any(unix, windows))] fn acceptor_state() -> Arc { let cluster = cluster::Cluster::spawn(crate::cluster::Options::default()).unwrap(); let cert = (|| -> std::result::Result<_, rcgen::Error> { @@ -1848,7 +1839,7 @@ mod tests { /// Without a capture the handle is `None`, qmux gets no socket, and the session /// advertises no Probe capability -- silently, which is why this drives an actual /// `TcpStream` rather than constructing the service by hand. - #[cfg(all(unix, feature = "websocket"))] + #[cfg(unix)] #[tokio::test] async fn web_acceptor_surfaces_the_accepted_socket() { use axum::http::Request; @@ -1916,7 +1907,7 @@ mod tests { /// The handle holds a duplicated descriptor for the life of the connection, so /// capturing it for every API, HLS, and health-check connection would halve the /// descriptors a relay can spend on connections, for nothing. - #[cfg(all(unix, feature = "websocket"))] + #[cfg(unix)] #[tokio::test] async fn web_acceptor_skips_capture_without_websockets() { let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap(); @@ -1939,7 +1930,7 @@ mod tests { } /// Reports whether the connection's socket reached the request. - #[cfg(all(unix, feature = "websocket"))] + #[cfg(unix)] async fn report_socket(socket: Option>) -> &'static str { match socket { Some(_) => "captured", @@ -1951,7 +1942,7 @@ mod tests { /// /// Hand-rolled rather than reached through an HTTP client so the same request /// works over TLS and plain TCP. `Connection: close` is what ends the read. - #[cfg(all(unix, feature = "websocket"))] + #[cfg(unix)] async fn get_socket(mut io: S) -> String { use tokio::io::{AsyncReadExt, AsyncWriteExt}; @@ -1972,7 +1963,7 @@ mod tests { /// A TLS client trusting only `ca`, so the handshake also proves the relay /// served the certificate it was configured with. - #[cfg(all(unix, feature = "websocket"))] + #[cfg(unix)] fn tls_connector(ca: &std::path::Path) -> tokio_rustls::TlsConnector { use rustls::pki_types::{CertificateDer, pem::PemObject}; @@ -1997,7 +1988,7 @@ mod tests { /// that skips it hands qmux a session with no descriptor, which stays on the /// fallback jitter buffer while the other listener still looks correct, so both /// run here and each is asked whether the capture reached the request. - #[cfg(all(unix, feature = "websocket"))] + #[cfg(unix)] #[tokio::test] async fn serve_captures_the_socket_on_every_listener() { let dir = TempDir::new().unwrap(); @@ -2052,7 +2043,7 @@ mod tests { /// WebSocket alike, never the `Host` the client wrote; plain HTTP has no SNI, so it /// reports none rather than the header. `host` carries the header on both, lowercased and /// without its port. Real sockets, so this runs on the wall clock. - #[cfg(all(unix, feature = "websocket"))] + #[cfg(unix)] #[tokio::test] async fn server_name_is_the_sni_never_the_host() { use tokio::io::{AsyncReadExt, AsyncWriteExt}; @@ -2143,7 +2134,6 @@ mod tests { /// A `tls://` dial to the HTTPS port lands a MoQ session served with the listen /// identity rather than `https.cert`, while the port keeps serving HTTPS. - #[cfg(feature = "quic")] #[tokio::test] async fn https_listener_serves_tls_qmux() { use rustls::pki_types::{CertificateDer, pem::PemObject}; @@ -2216,7 +2206,6 @@ mod tests { /// `tls://` on the HTTPS port applies the listen client-certificate policy, as the /// `listen.tcp` `tls://` listener does: under pinned peers a dial without a pinned /// certificate is refused. HTTPS on the same port is never asked for one. - #[cfg(feature = "quic")] #[tokio::test] async fn https_listener_verifies_tls_qmux_client_certificates() { use rustls::pki_types::{CertificateDer, pem::PemObject}; @@ -2617,7 +2606,6 @@ mod tests { /// Read the windows advertised by the real relay upgrade, before MoQ admission can /// widen them. Nondefault values distinguish operator configuration from defaults. - #[cfg(feature = "websocket")] #[tokio::test] async fn websocket_upgrade_advertises_the_configured_receive_windows() { use bytes::Buf; @@ -2702,7 +2690,6 @@ mod tests { /// even with no timeout to end the wait. The socket is the listener's own, reclaimed from /// under hyper rather than read through its boxed IO. Real sockets, so this runs on the /// wall clock. - #[cfg(feature = "websocket")] #[tokio::test] async fn a_websocket_frame_past_one_record_is_refused_at_its_header() { use tokio::io::{AsyncBufReadExt, AsyncReadExt, AsyncWriteExt}; @@ -2826,7 +2813,7 @@ mod tests { ); } - #[cfg(all(feature = "websocket", any(unix, windows)))] + #[cfg(any(unix, windows))] mod drain { use super::*; diff --git a/rs/moq-relay/tests/drills.rs b/rs/moq-relay/tests/drills.rs index 7fc2f762200..098b04c812a 100644 --- a/rs/moq-relay/tests/drills.rs +++ b/rs/moq-relay/tests/drills.rs @@ -24,7 +24,6 @@ //! See `test/drill/README.md` for the recipe, the sensitivity proof that each //! drill fails when its recovery behavior is removed, and the fuzz targets //! covering the wire underneath. -#![cfg(all(feature = "quic", feature = "websocket"))] use std::time::Duration; diff --git a/rs/moq-relay/tests/integration/auth_lifetime.rs b/rs/moq-relay/tests/integration/auth_lifetime.rs index 9f2aac15885..f18e41163f2 100644 --- a/rs/moq-relay/tests/integration/auth_lifetime.rs +++ b/rs/moq-relay/tests/integration/auth_lifetime.rs @@ -23,7 +23,6 @@ use axum::routing::post; use axum::{Json, Router}; use moq_auth::{Event, Grant, Pattern, Patterns, Request}; use moq_net::stats; -#[cfg(feature = "websocket")] use moq_relay::web; use moq_relay::{Config, Connection, Relay, auth, cluster}; @@ -43,10 +42,6 @@ enum Answer { Status(u16), Token(Grant, moq_auth::Token), /// A 403 carrying a typed refusal. - #[cfg_attr( - not(feature = "websocket"), - allow(dead_code, reason = "only the `websocket` feature uses it") - )] Refuse(moq_auth::refusal::Reason), } @@ -92,7 +87,6 @@ impl Script { *self.revalidate.lock().unwrap() = answer; } - #[cfg(feature = "websocket")] fn on_revalidate_http(&self, answer: Answer) { *self.revalidate_http.lock().unwrap() = Some(answer); } @@ -245,13 +239,11 @@ async fn spawn_relay_config( /// Stand up the relay's axum web stack with WebSocket enabled and return the /// port plus an abort handle. -#[cfg(feature = "websocket")] async fn spawn_ws_relay(auth: moq_relay::auth::Auth) -> (u16, tokio::task::JoinHandle<()>) { let cluster = crate::spawn_cluster(cluster::Options::default()); spawn_ws_relay_with(auth, cluster).await } -#[cfg(feature = "websocket")] async fn spawn_ws_relay_with( auth: moq_relay::auth::Auth, cluster: cluster::Cluster, @@ -284,10 +276,7 @@ async fn spawn_ws_relay_with( fn client() -> moq_tokio::Client { let mut config = moq_tokio::connect::Config::default(); config.tls.insecure = Some(true); - #[cfg(feature = "websocket")] - { - config.websocket.delay = Some((Duration::ZERO).into()); - } + config.websocket.delay = Some((Duration::ZERO).into()); config.bind = Some("127.0.0.1:0".parse().expect("parse bind")); config .init(Default::default()) @@ -405,7 +394,6 @@ async fn assert_refused_with(client: moq_tokio::Client, url: &url::Url) { } /// A QUIC relay, verifying client certificates against `root` when given. -#[cfg(feature = "quic")] async fn spawn_quic_relay( auth: moq_relay::auth::Auth, root: Option, @@ -415,7 +403,6 @@ async fn spawn_quic_relay( } /// [`spawn_quic_relay`] serving `cluster`. -#[cfg(feature = "quic")] async fn spawn_quic_relay_with( auth: moq_relay::auth::Auth, root: Option, @@ -501,7 +488,6 @@ async fn admits_and_reports_the_session() { } /// Write all of `data` to a raw qmux stream. -#[cfg(feature = "websocket")] async fn write_all(send: &mut qmux::SendStream, mut data: &[u8]) { use moq_net::transport::poll::SendStream as _; while !data.is_empty() { @@ -511,7 +497,6 @@ async fn write_all(send: &mut qmux::SendStream, mut data: &[u8]) { } /// A moq-transport client's SETUP token reaches the auth server byte for byte. -#[cfg(feature = "websocket")] #[tokio::test] async fn forwards_the_setup_token() { use moq_net::transport::poll::{RecvStream as _, Session as _}; @@ -838,7 +823,6 @@ async fn a_moved_tier_retags_the_live_session() { /// A re-check resizes the live session in place, over TCP and WebSocket: a narrower /// grant resets the deafened path with `Unauthorized` while a sibling under the same /// prefix keeps flowing, a wider one brings the path back, and neither session closes. -#[cfg(feature = "websocket")] #[tokio::test] async fn a_rechecked_grant_resizes_live_sessions() { let clock = crate::manual(); @@ -1046,7 +1030,6 @@ async fn a_refusal_closes_live_sessions() { /// as `http` and ended when it answers, and `/fetch` holds its lease for as long /// as the body streams, so a refusal on re-check cuts the transfer and the `end` /// says why. -#[cfg(feature = "websocket")] #[tokio::test] async fn http_routes_hold_a_lease() { let clock = crate::manual(); @@ -1189,7 +1172,6 @@ async fn http_routes_hold_a_lease() { /// A session the client closes reports `end` with its duration and byte counters. /// Over QUIC, the one transport whose connection reports its totals. -#[cfg(feature = "quic")] #[tokio::test] async fn the_end_carries_duration_and_bytes() { let script = Script::new(grant(Duration::from_secs(3600))); @@ -1323,7 +1305,6 @@ async fn the_drain_waits_for_a_closed_session_to_report_its_end() { /// A certificate is a fact: with no server grant for it, a verified peer is /// refused; with a narrow one, it is scoped to that and nothing more. Over QUIC /// with a client certificate, and over WebSocket where none can be presented. -#[cfg(all(feature = "quic", feature = "websocket"))] #[tokio::test] async fn a_certificate_admits_only_what_the_server_grants() { let _ = rind_rustls::default_provider().unwrap().install_default(); @@ -1407,7 +1388,6 @@ async fn a_certificate_admits_only_what_the_server_grants() { /// A relay dialing in with a certificate, admitted by `moq auth serve --mtls-link peer`, /// is a cluster peer: what it announces entered the cluster elsewhere. -#[cfg(feature = "quic")] #[tokio::test] async fn an_mtls_peer_is_a_cluster_peer() { let source = mtls_route_source(true).await; @@ -1418,7 +1398,6 @@ async fn an_mtls_peer_is_a_cluster_peer() { } /// Without `--mtls-link peer`, a certificate identifies a client ingesting here. -#[cfg(feature = "quic")] #[tokio::test] async fn an_mtls_client_ingests_here() { assert_eq!(mtls_route_source(false).await, moq_net::origin::Source::Local); @@ -1426,7 +1405,6 @@ async fn an_mtls_client_ingests_here() { /// The source the relay records for a broadcast announced over a certificate /// session, admitted by `moq auth serve` with the peer link role when requested. -#[cfg(feature = "quic")] async fn mtls_route_source(mtls_peer: bool) -> moq_net::origin::Source { let _ = rind_rustls::default_provider().unwrap().install_default(); let dir = tempfile::tempdir().expect("tempdir"); @@ -1477,7 +1455,6 @@ async fn mtls_route_source(mtls_peer: bool) -> moq_net::origin::Source { update.route.source() } -#[cfg(feature = "quic")] fn signed_client(dir: &std::path::Path) -> (std::path::PathBuf, std::path::PathBuf, std::path::PathBuf) { let ca_key = rind_rcgen::KeyPair::generate(&rcgen::PKCS_ECDSA_P256_SHA256).expect("ca keypair"); let mut ca_params = rcgen::CertificateParams::new(Vec::new()) @@ -1882,7 +1859,6 @@ async fn next_update(announced: &mut moq_net::origin::Routes) -> Option<(moq_net /// The auth server sees the accepted transport, independent of negotiated MoQ ALPN. /// An IP-literal dial sends no SNI, so neither reports a `server_name`: the /// WebTransport CONNECT host selected no certificate and never stands in for one. -#[cfg(feature = "quic")] #[tokio::test] async fn quic_and_webtransport_report_distinct_auth_transports() { let script = Script::new(grant(Duration::from_secs(3600))); @@ -1908,7 +1884,6 @@ async fn quic_and_webtransport_report_distinct_auth_transports() { /// A token can reach a prefix outside the initial credential, and withdrawing it /// revokes only the streams that depended on it on both native and upgraded WS. Only /// lite-07 carries a token in band. -#[cfg(feature = "websocket")] #[tokio::test] async fn in_band_tokens_widen_and_withdraw_live_prefixes() { for scheme in ["tcp", "ws"] { @@ -1924,10 +1899,7 @@ async fn in_band_tokens_widen_and_withdraw_live_prefixes() { let client = || { let mut config = moq_tokio::connect::Config::default(); config.version = vec!["moq-lite-07-wip".parse().unwrap()]; - #[cfg(feature = "websocket")] - { - config.websocket.delay = Some((Duration::ZERO).into()); - } + config.websocket.delay = Some((Duration::ZERO).into()); config.init(Default::default()).unwrap().with_reconnect(false) }; let origin = moq_tokio::origin::spawn(); @@ -2125,7 +2097,6 @@ async fn request_token_lease_ends_before_the_connection_and_reopens_later() { } /// Both admission paths apply the selected cap before starting the session driver. -#[cfg(feature = "websocket")] #[tokio::test] async fn relay_request_limits_distinguish_clients_and_peers() { for scheme in ["tcp", "ws"] { @@ -2186,7 +2157,6 @@ async fn relay_request_limits_distinguish_clients_and_peers() { } /// Browser-visible policy refusals happen after the WebSocket upgrade, in MoQ's close registry. -#[cfg(feature = "websocket")] #[tokio::test] async fn websocket_refusal_is_in_band() { use moq_auth::refusal::Reason; @@ -2226,7 +2196,6 @@ async fn websocket_refusal_is_in_band() { } /// The role seen at SETUP reaches the shared admission gate on the WebSocket path. -#[cfg(feature = "websocket")] #[tokio::test] async fn websocket_publisher_role_is_refused_by_a_subscribe_only_grant() { let script = Script::new(Grant::new(Patterns::new(), all())); @@ -2263,7 +2232,6 @@ async fn websocket_publisher_role_is_refused_by_a_subscribe_only_grant() { /// Once a session went live, the native reconnect loop redials an in-band unauthorized /// refusal like any other close, rather than judging its kind. -#[cfg(feature = "websocket")] #[tokio::test] async fn websocket_unauthorized_keeps_native_reconnect_going() { let script = Script::new(grant(Duration::from_secs(3600))); diff --git a/rs/moq-relay/tests/integration/bitrate_caps.rs b/rs/moq-relay/tests/integration/bitrate_caps.rs index fef7b1e1292..078639f0cdf 100644 --- a/rs/moq-relay/tests/integration/bitrate_caps.rs +++ b/rs/moq-relay/tests/integration/bitrate_caps.rs @@ -4,7 +4,6 @@ //! //! Over real sockets, so the caps are measured on the wall clock as lower bounds on //! how long a transfer takes: uncapped, the same transfer takes milliseconds. -#![cfg(feature = "quic")] use std::time::Duration; @@ -236,7 +235,7 @@ async fn tokio_window_opens_once_admitted() { window_opens_once_admitted(relay, port).await; } -#[cfg(all(target_os = "linux", feature = "_uring"))] +#[cfg(target_os = "linux")] async fn uring_relay() -> Option<(Relay, u16, tempfile::TempDir)> { let _ = rind_rustls::default_provider().unwrap().install_default(); match moq_uring::Worker::new(Default::default()) { @@ -257,7 +256,7 @@ async fn uring_relay() -> Option<(Relay, u16, tempfile::TempDir)> { Some((relay, port, dir)) } -#[cfg(all(target_os = "linux", feature = "_uring"))] +#[cfg(target_os = "linux")] #[tokio::test] async fn uring_session_is_held_to_its_caps() { if let Some((relay, port, _dir)) = uring_relay().await { @@ -265,7 +264,7 @@ async fn uring_session_is_held_to_its_caps() { } } -#[cfg(all(target_os = "linux", feature = "_uring"))] +#[cfg(target_os = "linux")] #[tokio::test] async fn uring_window_opens_once_admitted() { if let Some((relay, port, _dir)) = uring_relay().await { diff --git a/rs/moq-relay/tests/integration/cluster_close.rs b/rs/moq-relay/tests/integration/cluster_close.rs index fcb9b1a7ff1..dbe17cc6de8 100644 --- a/rs/moq-relay/tests/integration/cluster_close.rs +++ b/rs/moq-relay/tests/integration/cluster_close.rs @@ -3,7 +3,6 @@ //! //! Each dialer runs on its own runtime, shut down right after, as a process exit //! would: a dropped link only queues its close, which nothing sends then. -#![cfg(feature = "quic")] use std::time::Duration; @@ -89,7 +88,6 @@ async fn closing_a_cluster_closes_its_static_dials() { /// `Client::close` reaches only QUIC, so a WebSocket link ends only because the /// close stops its dial task. The runtime keeps running, as an embedder's would. -#[cfg(feature = "websocket")] #[tokio::test] async fn closing_a_cluster_ends_its_websocket_dials() { use tokio::io::AsyncReadExt; diff --git a/rs/moq-relay/tests/integration/cluster_fresh_port.rs b/rs/moq-relay/tests/integration/cluster_fresh_port.rs index 64861dcbe31..0105a9fbcf9 100644 --- a/rs/moq-relay/tests/integration/cluster_fresh_port.rs +++ b/rs/moq-relay/tests/integration/cluster_fresh_port.rs @@ -5,7 +5,6 @@ //! redialing from its one port. Here a proxy drops everything from the first //! source port it sees, so the link only comes up once a redial leaves from //! another. -#![cfg(feature = "quic")] use std::collections::{HashMap, HashSet}; use std::net::SocketAddr; @@ -145,10 +144,7 @@ async fn dropped_flow_recovers(budget: Duration, effective: Duration) { connect.timeout = Some(Duration::from_millis(500).into()); connect.backoff.initial = Some(Duration::from_millis(100).into()); connect.backoff.timeout = Some(budget.into()); - #[cfg(feature = "websocket")] - { - connect.websocket.enabled = Some(false); - } + connect.websocket.enabled = Some(false); let mut config = cluster::Config::default(); config.connect = vec![Peer::new(format!("https://{proxy}/"))]; diff --git a/rs/moq-relay/tests/integration/cluster_idle.rs b/rs/moq-relay/tests/integration/cluster_idle.rs index 25228bea3b3..b1756a659fb 100644 --- a/rs/moq-relay/tests/integration/cluster_idle.rs +++ b/rs/moq-relay/tests/integration/cluster_idle.rs @@ -3,7 +3,6 @@ //! A crashed or partitioned peer sends no close, so the idle timeout is the whole //! outage window for subscribes routed through it. The dial here runs a short //! timeout; moq-tokio's `defaults_apply_when_unset` pins the 10s default. -#![cfg(feature = "quic")] use std::time::Duration; @@ -98,10 +97,7 @@ async fn silent_peer_detected() { let mut connect = moq_tokio::connect::Config::default(); connect.bind = Some("127.0.0.1:0".parse().expect("parse bind")); connect.tls.insecure = Some(true); - #[cfg(feature = "websocket")] - { - connect.websocket.enabled = Some(false); - } + connect.websocket.enabled = Some(false); let mut config = cluster::Config::default(); config.connect = vec![Peer::new(format!("https://127.0.0.1:{port}/"))]; diff --git a/rs/moq-relay/tests/integration/embed.rs b/rs/moq-relay/tests/integration/embed.rs index 1d0eb43350b..179f118a32a 100644 --- a/rs/moq-relay/tests/integration/embed.rs +++ b/rs/moq-relay/tests/integration/embed.rs @@ -7,8 +7,6 @@ //! live QUIC subscriber, then stops the owner through its shutdown trigger //! and proves `run` returned with its sockets closed. -#![cfg(feature = "_quic")] - #[cfg(not(target_os = "linux"))] use std::net::SocketAddr; use std::net::TcpListener; @@ -422,10 +420,8 @@ async fn worker_tokio_custom_route_and_quic() { embed_and_stop(config).await; } -/// io_uring workers. Off the default feature set; the Linux gate's test build, -/// `just rs uring`, and nightly `--all-features` compile it. Skips below the -/// 6.12 floor unless CI_STRICT. -#[cfg(all(target_os = "linux", feature = "_uring"))] +/// io_uring workers. Skips below the 6.12 floor unless CI_STRICT. +#[cfg(target_os = "linux")] #[tokio::test] async fn uring_custom_route_and_quic() { match moq_uring::Worker::new(Default::default()) { diff --git a/rs/moq-relay/tests/integration/handoff.rs b/rs/moq-relay/tests/integration/handoff.rs index 826ac8010f4..f7e94575a97 100644 --- a/rs/moq-relay/tests/integration/handoff.rs +++ b/rs/moq-relay/tests/integration/handoff.rs @@ -3,7 +3,7 @@ //! //! Linux-only, as handoff is: the QUIC port is handed on as a reuseport group, //! steered by a socket filter. -#![cfg(all(target_os = "linux", feature = "_quic"))] +#![cfg(target_os = "linux")] use std::path::{Path, PathBuf}; use std::time::Duration; @@ -36,7 +36,7 @@ fn certificate(dir: &Path) -> (PathBuf, PathBuf) { #[derive(Clone, Copy, Debug)] enum Backend { Tokio, - #[cfg(feature = "_uring")] + #[cfg(target_os = "linux")] Uring, } @@ -59,7 +59,7 @@ fn config(dir: &Path, cert: &Path, key: &Path, backend: Backend) -> Config { config.handoff.socket = Some(dir.join("handoff.sock")); match backend { Backend::Tokio => {} - #[cfg(feature = "_uring")] + #[cfg(target_os = "linux")] Backend::Uring => config.runtime.io_uring = true, } config @@ -130,7 +130,7 @@ async fn a_new_relay_takes_over_while_the_old_one_drains() { takes_over(Backend::Tokio, Backend::Tokio).await; } -#[cfg(feature = "_uring")] +#[cfg(target_os = "linux")] #[tokio::test] async fn an_io_uring_relay_takes_over() { if crate::runtime_uring::supported() { @@ -139,7 +139,7 @@ async fn an_io_uring_relay_takes_over() { } /// Both backends hand on the same group, with connection IDs in the same layout. -#[cfg(feature = "_uring")] +#[cfg(target_os = "linux")] #[tokio::test] async fn a_relay_takes_over_across_backends() { if crate::runtime_uring::supported() { diff --git a/rs/moq-relay/tests/integration/lan_mesh.rs b/rs/moq-relay/tests/integration/lan_mesh.rs index 3c2320ea997..beebe225ace 100644 --- a/rs/moq-relay/tests/integration/lan_mesh.rs +++ b/rs/moq-relay/tests/integration/lan_mesh.rs @@ -14,8 +14,6 @@ //! moq --connect http://127.0.0.1:4443 --connect-tls-insecure export ts > /dev/null //! ``` -#![cfg(feature = "cluster-lan")] - use std::time::Duration; use moq_relay::cluster; diff --git a/rs/moq-relay/tests/integration/logs.rs b/rs/moq-relay/tests/integration/logs.rs index 0aa2ceb3999..62744246e3a 100644 --- a/rs/moq-relay/tests/integration/logs.rs +++ b/rs/moq-relay/tests/integration/logs.rs @@ -33,10 +33,6 @@ impl Logs { } /// Wait until the output contains `needle`. - #[cfg_attr( - not(feature = "websocket"), - allow(dead_code, reason = "only the `websocket` feature uses it") - )] pub async fn wait_for(&self, needle: &str) { loop { // Created before the check, so a write in between still wakes it. diff --git a/rs/moq-relay/tests/integration/main.rs b/rs/moq-relay/tests/integration/main.rs index 244392033ef..b955c3d3d8c 100644 --- a/rs/moq-relay/tests/integration/main.rs +++ b/rs/moq-relay/tests/integration/main.rs @@ -31,7 +31,7 @@ mod logs; mod memory; mod peer_limits; mod public_rules; -#[cfg(all(feature = "test-support", feature = "quic"))] +#[cfg(feature = "test-support")] mod quic_sim; mod refusals; mod released_cli; diff --git a/rs/moq-relay/tests/integration/peer_limits.rs b/rs/moq-relay/tests/integration/peer_limits.rs index 646b97dd22e..efa016eaef5 100644 --- a/rs/moq-relay/tests/integration/peer_limits.rs +++ b/rs/moq-relay/tests/integration/peer_limits.rs @@ -1,7 +1,6 @@ //! A session admitted as a cluster peer widens its QUIC limits before SETUP OK, //! while a viewer opens to the `--quic-*` ones, on the tokio listener and the //! io_uring workers alike. -#![cfg(feature = "quic")] use std::time::Duration; @@ -352,7 +351,7 @@ async fn tokio_worker_peer_session_widens_quic_limits() { peer_widens_and_viewer_does_not(relay, port).await; } -#[cfg(all(target_os = "linux", feature = "_uring"))] +#[cfg(target_os = "linux")] #[tokio::test] async fn uring_peer_session_widens_quic_limits() { let _ = rind_rustls::default_provider().unwrap().install_default(); diff --git a/rs/moq-relay/tests/integration/public_rules.rs b/rs/moq-relay/tests/integration/public_rules.rs index 387be32e1da..c3504c771a3 100644 --- a/rs/moq-relay/tests/integration/public_rules.rs +++ b/rs/moq-relay/tests/integration/public_rules.rs @@ -7,8 +7,6 @@ //! the dialed path, `anon/**` at `/anon` meant `anon/anon/**`, and at `/rooms/123` //! it let an anonymous client into `rooms/123/anon/**`. -#![cfg(feature = "websocket")] - use std::time::Duration; use moq_relay::{auth, cluster, web}; diff --git a/rs/moq-relay/tests/integration/refusals.rs b/rs/moq-relay/tests/integration/refusals.rs index 559f07cacf7..b72014ccc59 100644 --- a/rs/moq-relay/tests/integration/refusals.rs +++ b/rs/moq-relay/tests/integration/refusals.rs @@ -1,8 +1,6 @@ //! Sessions admission refuses reach `/metrics` by reason, through a real relay //! over QUIC and WebSocket. -#![cfg(feature = "_quic")] - use std::net::SocketAddr; use std::time::Duration; @@ -51,10 +49,6 @@ struct Running { stats: moq_net::stats::Registry, origin: moq_net::origin::Consumer, quic: SocketAddr, - #[cfg_attr( - not(feature = "websocket"), - allow(dead_code, reason = "only the `websocket` feature uses it") - )] http: SocketAddr, metrics: String, trigger: moq_relay::shutdown::Trigger, @@ -157,7 +151,6 @@ async fn refused_sessions_are_counted() { } /// The WebSocket path counts a refusal the same way. -#[cfg(feature = "websocket")] #[tokio::test] async fn websocket_refused_sessions_are_counted() { let dir = tempfile::tempdir().expect("tempdir"); @@ -550,7 +543,7 @@ async fn tokio_refuses_uri_setup_paths() { uri_setup_paths(false).await; } -#[cfg(all(target_os = "linux", feature = "_uring"))] +#[cfg(target_os = "linux")] #[tokio::test] async fn uring_refuses_uri_setup_paths() { match moq_uring::Worker::new(Default::default()) { diff --git a/rs/moq-relay/tests/integration/released_cli.rs b/rs/moq-relay/tests/integration/released_cli.rs index d7af8640d92..747818f4073 100644 --- a/rs/moq-relay/tests/integration/released_cli.rs +++ b/rs/moq-relay/tests/integration/released_cli.rs @@ -78,13 +78,13 @@ const RELEASED: &[(&str, Option<&str>)] = &[ ("server-quic-qlog", Some("MOQ_SERVER_QUIC_QLOG")), ("server-tcp-bind", Some("MOQ_SERVER_TCP_BIND")), ("server-tls-root", Some("MOQ_SERVER_TLS_ROOT")), - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] ("server-unix-allow-gid", Some("MOQ_SERVER_UNIX_ALLOW_GID")), - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] ("server-unix-allow-pid", Some("MOQ_SERVER_UNIX_ALLOW_PID")), - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] ("server-unix-allow-uid", Some("MOQ_SERVER_UNIX_ALLOW_UID")), - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] ("server-unix-bind", Some("MOQ_SERVER_UNIX_BIND")), ("server-version", Some("MOQ_SERVER_VERSION")), ("stats-depth", Some("MOQ_STATS_DEPTH")), @@ -105,9 +105,7 @@ const RELEASED: &[(&str, Option<&str>)] = &[ ("web-https-listen", Some("MOQ_WEB_HTTPS_LISTEN")), ("web-https-root", Some("MOQ_WEB_HTTPS_ROOT")), ("web-ws", Some("MOQ_WEB_WS")), - #[cfg(feature = "websocket")] ("websocket-delay", Some("MOQ_CLIENT_WEBSOCKET_DELAY")), - #[cfg(feature = "websocket")] ("websocket-enabled", Some("MOQ_CLIENT_WEBSOCKET_ENABLED")), ]; diff --git a/rs/moq-relay/tests/integration/runtime_uring.rs b/rs/moq-relay/tests/integration/runtime_uring.rs index 6057c746f8b..07801878456 100644 --- a/rs/moq-relay/tests/integration/runtime_uring.rs +++ b/rs/moq-relay/tests/integration/runtime_uring.rs @@ -5,7 +5,7 @@ //! //! Linux-only like the mode itself. Unsupported local kernels skip loudly; //! CI_STRICT makes CI refuse them. -#![cfg(all(target_os = "linux", feature = "_uring"))] +#![cfg(target_os = "linux")] use std::net::SocketAddr; use std::time::Duration; @@ -945,7 +945,6 @@ async fn next_update(announced: &mut moq_net::origin::Routes) -> Option<(moq_net } /// A moq-transport SETUP credential reaches the decider on both ring transports. -#[cfg(feature = "quic")] #[tokio::test] async fn uring_forwards_the_setup_token() { use moq_tokio::quic::{driver, web}; @@ -1095,7 +1094,6 @@ async fn uring_auth_reports_distinct_quic_and_webtransport() { /// The relay and the client run on a manual clock, so only the test passes time. /// Both select no congestion control, so neither paces: a pacer waits on time /// passing. -#[cfg(feature = "quic")] #[test] fn uring_workers_bound_stalled_handshakes() { use moq_net::transport::Error as _; @@ -1203,7 +1201,6 @@ fn uring_workers_bound_stalled_handshakes() { /// first answers, and every answer back, so the server never sees the client /// finish its handshake. Returns the address to dial, and a signal for the /// server's first answer. -#[cfg(feature = "quic")] async fn stall_after_hello(server: SocketAddr) -> (SocketAddr, tokio::sync::oneshot::Receiver<()>) { let socket = tokio::net::UdpSocket::bind("127.0.0.1:0").await.expect("bind hop"); let addr = socket.local_addr().expect("hop address"); diff --git a/rs/moq-relay/tests/integration/runtime_workers.rs b/rs/moq-relay/tests/integration/runtime_workers.rs index 05f6682654d..ea03c1f491b 100644 --- a/rs/moq-relay/tests/integration/runtime_workers.rs +++ b/rs/moq-relay/tests/integration/runtime_workers.rs @@ -2,9 +2,8 @@ //! //! Linux-only, because the mode is: every worker binds the listen address with //! `SO_REUSEPORT`, and no other platform load-balances a unicast UDP port -//! across the group. There is also nothing to serve without a QUIC backend, so -//! a build without one refuses `runtime.workers` at load. -#![cfg(all(target_os = "linux", feature = "_quic"))] +//! across the group. +#![cfg(target_os = "linux")] use std::time::Duration; diff --git a/rs/moq-relay/tests/integration/session_revalidate.rs b/rs/moq-relay/tests/integration/session_revalidate.rs index 6f31e5bb745..eddbcd743d6 100644 --- a/rs/moq-relay/tests/integration/session_revalidate.rs +++ b/rs/moq-relay/tests/integration/session_revalidate.rs @@ -155,7 +155,6 @@ impl Fixture { Self::spawn(auth, false).await } - #[cfg(feature = "websocket")] async fn ws(auth: moq_relay::auth::Auth) -> Self { Self::spawn(auth, true).await } @@ -266,10 +265,7 @@ impl Fixture { fn client_at(bind: &str) -> moq_tokio::Client { let mut config = moq_tokio::connect::Config::default(); config.tls.insecure = Some(true); - #[cfg(feature = "websocket")] - { - config.websocket.delay = Some((Duration::ZERO).into()); - } + config.websocket.delay = Some((Duration::ZERO).into()); config.bind = Some(bind.parse().expect("parse bind")); config .init(Default::default()) @@ -394,7 +390,6 @@ async fn path_and_cidr_select_a_subset() { } /// A WebSocket session is listed and closes on a push like a QUIC one. -#[cfg(feature = "websocket")] #[tokio::test] async fn websocket_is_listed_and_closes_on_a_push() { let script = Script::new(grant()); diff --git a/rs/moq-relay/tests/integration/smoke.rs b/rs/moq-relay/tests/integration/smoke.rs index 3fa6567d27e..c066e787bd6 100644 --- a/rs/moq-relay/tests/integration/smoke.rs +++ b/rs/moq-relay/tests/integration/smoke.rs @@ -9,11 +9,9 @@ use std::time::Duration; -#[cfg(all(feature = "quic", feature = "websocket"))] use moq_relay::{Config, Relay}; use moq_relay::{Connection, auth, cluster, web}; -#[cfg(feature = "websocket")] use crate::logs::Logs; /// A millisecond track: the frames written here carry timestamps. @@ -86,7 +84,6 @@ async fn spawn_relay() -> (u16, tokio::task::JoinHandle<()>) { } /// Stand up the assembled relay path with `--server-version` restricted. -#[cfg(all(feature = "quic", feature = "websocket"))] async fn spawn_versioned_relay(versions: Vec) -> (u16, tokio::task::JoinHandle<()>) { let mut config = Config::default(); config.listen.bind = Some("127.0.0.1:0".parse().unwrap()); @@ -116,10 +113,7 @@ fn client_version(version: Option) -> moq_tokio::Client { // One-shot: these tests were written against a single dial, and a background // redial would re-register with the relay behind the assertions' back. // Zero head start so the WebSocket path runs immediately. - #[cfg(feature = "websocket")] - { - config.websocket.delay = Some((std::time::Duration::ZERO).into()); - } + config.websocket.delay = Some((std::time::Duration::ZERO).into()); // Every relay in this file listens on IPv4 loopback, so bind the same family // rather than egressing a QUIC dial from a dual-stack IPv6 socket. config.bind = Some("127.0.0.1:0".parse().expect("parse bind")); @@ -135,7 +129,6 @@ fn client_version(version: Option) -> moq_tokio::Client { /// Connect a publisher and a subscriber to a real relay over `ws://`, push /// one frame end-to-end, and assert both sides see the newest moq-lite ALPN. /// Regression for the `serve_ws` downgrade to Lite02. -#[cfg(feature = "websocket")] #[tokio::test] async fn relay_websocket_round_trip_uses_newest_version() { let (port, web_handle) = spawn_relay().await; @@ -225,7 +218,6 @@ async fn relay_websocket_round_trip_uses_newest_version() { /// A WebSocket session takes its id from the cluster-wide counter and logs its close, like /// a QUIC one, so the interop harness can pair its `conn{id=N}` span with that close. -#[cfg(feature = "websocket")] #[tokio::test] async fn relay_websocket_logs_its_close_under_a_cluster_id() { let logs = Logs::default(); @@ -264,7 +256,6 @@ async fn relay_websocket_logs_its_close_under_a_cluster_id() { } /// Read announcements until `until` shows up, returning every active prefix seen. -#[cfg(all(feature = "quic", feature = "websocket"))] async fn announced_until(announcements: &mut moq_net::origin::Routes, until: &str) -> Vec { let mut seen = Vec::new(); while !seen.iter().any(|prefix| prefix == until) { @@ -286,7 +277,6 @@ async fn announced_until(announcements: &mut moq_net::origin::Routes, until: &st /// A `.`-named broadcast stays out of discovery unless the reader opts in, and /// a client that predates the opt-in (moq-lite-06) never discovers it. Subscribing /// by exact path needs no opt-in. -#[cfg(all(feature = "quic", feature = "websocket"))] #[tokio::test] async fn hidden_broadcasts_need_a_lite07_opt_in() { // lite-07 is work-in-progress and off by default, so the relay must enable it. @@ -387,7 +377,6 @@ async fn hidden_broadcasts_need_a_lite07_opt_in() { } /// `--server-version` applies to the WebSocket fallback as well as QUIC. -#[cfg(all(feature = "quic", feature = "websocket"))] #[tokio::test] async fn relay_websocket_honors_server_version() { let allowed: moq_net::Version = "moq-transport-18".parse().expect("parse allowed version"); @@ -503,7 +492,6 @@ async fn relay_https_terminates_tls() { /// root auth scope (same as the internal listener). Regression for the /// `/{*path}`-only route, which left bare-URL clients (e.g. /// `moqsink url="https://host:4443"`) with a silently dead WS fallback. -#[cfg(feature = "websocket")] #[tokio::test] async fn relay_websocket_root_path_upgrades() { let (port, web_handle) = spawn_relay().await; @@ -726,7 +714,7 @@ async fn internal_tcp_round_trip() { /// Stand up a stream `--server-bind` on a Unix socket and return the socket path /// plus an abort handle. -#[cfg(all(unix, feature = "uds"))] +#[cfg(unix)] async fn spawn_internal_unix_relay() -> (std::path::PathBuf, tokio::task::JoinHandle<()>) { // Keep the path short: macOS caps AF_UNIX paths around 104 bytes, and the // system temp dir is long. /tmp is fine on macOS and Linux. A per-call counter @@ -750,7 +738,7 @@ async fn spawn_internal_unix_relay() -> (std::path::PathBuf, tokio::task::JoinHa /// Connect over `unix://` (qmux on a Unix socket) and confirm a frame /// round-trips. Also asserts both sides land on the newest moq-lite version, /// which proves the in-band ALPN negotiation populated the protocol. -#[cfg(all(unix, feature = "uds"))] +#[cfg(unix)] #[tokio::test] async fn internal_unix_round_trip() { let (path, handle) = spawn_internal_unix_relay().await; @@ -916,7 +904,7 @@ async fn internal_tcp_path_reaches_server() { /// `unix://` carries no resource path in its URL (that's the socket), so /// the request path rides in the `?path=` query. Same assertion as TCP, across /// every version whose SETUP carries a path. -#[cfg(all(unix, feature = "uds"))] +#[cfg(unix)] #[tokio::test] async fn internal_unix_path_reaches_server() { let (path, handle) = spawn_internal_unix_relay().await; @@ -940,7 +928,6 @@ async fn internal_unix_path_reaches_server() { /// Stand up the relay listening only on a QUIC `--server-bind` on an ephemeral /// loopback port, with fully public auth (no-JWT => whole root). Returns the bound /// address and an abort handle. -#[cfg(feature = "quic")] async fn spawn_quic_relay() -> (std::net::SocketAddr, tokio::task::JoinHandle<()>) { let mut config = moq_tokio::listen::Config::default(); config.bind = Some("127.0.0.1:0".parse().unwrap()); @@ -956,7 +943,6 @@ async fn spawn_quic_relay() -> (std::net::SocketAddr, tokio::task::JoinHandle<() /// Raw QUIC has no request URI either, so `moqt://host:port/` only reaches the /// relay if the client puts it in the SETUP. Same assertion as TCP: the relay scopes /// the publisher's grant to that root, across every version whose SETUP carries a path. -#[cfg(feature = "quic")] #[tokio::test] async fn raw_quic_path_reaches_server() { let (addr, handle) = spawn_quic_relay().await; diff --git a/rs/moq-relay/tests/integration/stack.rs b/rs/moq-relay/tests/integration/stack.rs index b1e3d7b660e..d911aa163a3 100644 --- a/rs/moq-relay/tests/integration/stack.rs +++ b/rs/moq-relay/tests/integration/stack.rs @@ -1,6 +1,6 @@ //! The library's startup and serving futures fit a Windows main-thread stack. -#![cfg(all(debug_assertions, feature = "_quic"))] +#![cfg(debug_assertions)] use moq_relay::{Config, Relay}; diff --git a/rs/moq-relay/tests/integration/tenant_matrix.rs b/rs/moq-relay/tests/integration/tenant_matrix.rs index 12b2a40f59c..b4595606971 100644 --- a/rs/moq-relay/tests/integration/tenant_matrix.rs +++ b/rs/moq-relay/tests/integration/tenant_matrix.rs @@ -6,8 +6,6 @@ //! dials: `a` is rooted at `tenant-a`, `b` at `tenant-b` with a read-only //! mount of `tenant-a/public` at `shared`. -#![cfg(feature = "quic")] - use std::collections::{BTreeMap, BTreeSet, HashMap}; use std::net::SocketAddr; use std::sync::{Arc, Mutex}; @@ -515,7 +513,7 @@ async fn tokio_keeps_tenants_apart() { matrix(false).await; } -#[cfg(all(target_os = "linux", feature = "_uring"))] +#[cfg(target_os = "linux")] #[tokio::test] async fn uring_keeps_tenants_apart() { if !crate::runtime_uring::supported() { diff --git a/rs/moq-relay/tests/integration/wire_stats.rs b/rs/moq-relay/tests/integration/wire_stats.rs index 47e13b86b45..13beaf6a10d 100644 --- a/rs/moq-relay/tests/integration/wire_stats.rs +++ b/rs/moq-relay/tests/integration/wire_stats.rs @@ -1,5 +1,4 @@ //! Transport wire counters across the shared-runtime and io_uring listener boundary. -#![cfg(feature = "_quic")] use moq_net::stats::{Presence, Registry, Tier}; use moq_relay::{Config, Relay}; @@ -139,7 +138,7 @@ async fn native_sessions_supply_direct_wire_counters() { wire_sources(false).await; } -#[cfg(all(target_os = "linux", feature = "_uring"))] +#[cfg(target_os = "linux")] #[tokio::test] async fn uring_sessions_supply_direct_wire_counters() { match moq_uring::Worker::new(Default::default()) { diff --git a/rs/moq-rtmp/Cargo.toml b/rs/moq-rtmp/Cargo.toml index 4dcc478978e..52e360ff754 100644 --- a/rs/moq-rtmp/Cargo.toml +++ b/rs/moq-rtmp/Cargo.toml @@ -60,10 +60,8 @@ url = { workspace = true } criterion = { package = "bench-harness", path = "../bench-harness" } kio = { path = "../kio", features = ["sim"] } # The RTMPS test borrows moq-tokio's self-signed cert generation to build a -# `rustls::ServerConfig`. No transport feature: a QUIC backend here would be -# unified into every other crate a `--workspace` build selects, which is exactly -# what hid moq-tokio's backend-less build from the nightly feature matrix. -moq-tokio = { path = "../moq-tokio", default-features = false, features = ["net"] } +# `rustls::ServerConfig`. +moq-tokio = { path = "../moq-tokio" } rind-rustls = { workspace = true } tokio = { workspace = true, features = ["test-util"] } tracing-test = { workspace = true } diff --git a/rs/moq-tokio/Cargo.toml b/rs/moq-tokio/Cargo.toml index 0bec7dc2878..46a89c521ae 100644 --- a/rs/moq-tokio/Cargo.toml +++ b/rs/moq-tokio/Cargo.toml @@ -13,82 +13,51 @@ keywords = ["quic", "http3", "webtransport", "media", "live"] categories = ["multimedia", "network-programming", "web-programming"] [features] -default = ["net", "quic", "websocket", "tcp", "uds"] -# MoQ sessions over moq-net: `Client`, `Server`, `origin`, and the `connect`, `listen`, -# and `transport` modules. Every transport feature turns it on, since none works without it. -net = ["dep:moq-net", "moq-net/async", "_certs"] -# The async QUIC driver alone (`quic::driver`): moq-quic on tokio, without moq-net or -# the MoQ backend. Includes rind cryptography. -driver = ["_certs", "dep:moq-congestion", "dep:moq-quic", "dep:rustc-hash"] -# QUIC and WebTransport over moq-quic, for `https://`, `moqt://`, and `moql://`. -quic = ["_transport", "driver", "dep:http", "dep:web-transport-proto", "dep:reqwest", "watch", "dep:dns-lookup"] -# 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, -# enabled by every transport and the session API. -_certs = ["dep:rcgen", "dep:rind-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 = ["net", "dep:moq-quic"] -# Filesystem watcher for hot-reloading on-disk TLS certs, keys, and root CAs. -watch = ["dep:notify"] # Capture qlog traces (`--*-quic-qlog `). Off by default so production # builds do not pull in the qlog crate and its serde_json encoder. -qlog = ["moq-quic?/qlog"] -# LAN peer discovery over mDNS (the `mdns` module). -mdns = ["dep:mdns-sd"] +qlog = ["moq-quic/qlog"] jemalloc = ["dep:tikv-jemallocator", "dep:tikv-jemalloc-ctl"] -websocket = ["qmux", "watch", "dep:dns-lookup", "dep:httparse", "dep:tokio-rustls", "dep:tokio-tungstenite"] -# Qmux over TCP: plaintext `tcp://`, and `tls://`. Server-side and client-side. -tcp = ["qmux", "dep:dns-lookup", "dep:tokio-rustls"] -# MoQ over a qmux session established elsewhere, such as over a WebRTC data channel: -# `Client::connect_with` and `Listener::accept_with`. Every qmux transport turns it on. -qmux = ["_transport", "dep:qmux"] -# 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"] # Inside `kio::clock::sim::run`, detached tasks spawn on kio's deterministic simulator, -# and with `driver`, `quic::driver::sim` carries datagrams over seeded, impaired -# `moq_quic::sim::Link`s with no sockets; with `quic` too, `client::Config::sim` and -# `server::Config::sim` bind a `Client` or `Server` on one of its hosts. With `net`, -# `sim::Network` routes a client's dials over in-memory links instead. Turns on no transport of its own. Hidden from the -# docs. Meant for dev-dependencies, so production builds never compile it. -sim = ["kio/sim", "moq-quic?/sim"] +# `quic::driver::sim` carries datagrams over seeded, impaired `moq_quic::sim::Link`s with +# no sockets, `client::Config::sim` and `server::Config::sim` bind a `Client` or `Server` +# on one of its hosts, and `sim::Network` routes a client's dials over in-memory links +# instead. Hidden from the docs. Meant for dev-dependencies, so production builds never +# compile it. +sim = ["kio/sim", "moq-quic/sim"] [dependencies] bytes = "1" # Family-restricted `getaddrinfo`, so the AAAA and A queries can be issued separately # (RFC 8305 section 3) while still going through the system resolver. -dns-lookup = { version = "4", optional = true } +dns-lookup = "4" futures = "0.3" hex = { workspace = true } -http = { version = "1", optional = true } +http = "1" # Parses the WebSocket upgrade response without reading past it. -httparse = { workspace = true, optional = true } +httparse = { workspace = true } humantime = { workspace = true } humantime-serde = { workspace = true } kio = { workspace = true, features = ["async", "runtime"] } -mdns-sd = { workspace = true, optional = true } -moq-congestion = { workspace = true, optional = true } +mdns-sd = { workspace = true } +moq-congestion = { workspace = true } # rind's rustls provider and the `UnsupportedCpu` error, re-exported as `crypto`. Needs no moq-net. moq-crypto = { workspace = true, features = ["provider"] } -moq-net = { workspace = true, optional = true } +moq-net = { workspace = true, features = ["async"] } # The QUIC state machine `quic::driver` drives; rind supplies its cryptography. -moq-quic = { workspace = true, optional = true } +moq-quic = { workspace = true } moq-sock = { workspace = true } -notify = { version = "8", optional = true } -qmux = { workspace = true, features = ["wss", "tls", "tcp"], optional = true } +notify = "8" +qmux = { workspace = true } rand = "0.10.1" -rcgen = { workspace = true, optional = true } -reqwest = { version = "0.13", default-features = false, optional = true } +rcgen = { workspace = true } +reqwest = { version = "0.13", default-features = false } rind = { workspace = true } -rind-rcgen = { workspace = true, optional = true } -rustc-hash = { workspace = true, optional = true } +rind-rcgen = { workspace = true } +rustc-hash = { workspace = true } rustls = { version = "0.23", default-features = false, features = ["std", "tls12"] } # OS-native server-cert verifier for the rustls backend. rustls-platform-verifier = "0.7" -rustls-webpki = { version = "0.103", default-features = false, features = ["std"], optional = true } +rustls-webpki = { version = "0.103", default-features = false, features = ["std"] } serde = { version = "1", features = ["derive"] } serde_with = { version = "3", features = ["hex"] } thiserror = "2" @@ -97,15 +66,15 @@ tikv-jemallocator = { version = "0.7", features = ["profiling", "unprefixed_mall time = { workspace = true } tokio = { workspace = true, features = ["full"] } # The TLS stream `tcp::TlsAcceptor` accepts from a listener sharing its port. -tokio-rustls = { workspace = true, optional = true } +tokio-rustls = { workspace = true } # The WebSocket upgrade's HTTP handshake; qmux runs the frames after it. -tokio-tungstenite = { workspace = true, features = ["handshake"], optional = true } +tokio-tungstenite = { workspace = true, features = ["handshake"] } toml = { workspace = true } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } url = { version = "2", features = ["serde"] } usage-rs = { workspace = true, features = ["config"] } -web-transport-proto = { workspace = true, optional = true } +web-transport-proto = { workspace = true } x509-parser = { workspace = true } [target.'cfg(target_os = "android")'.dependencies] @@ -156,30 +125,10 @@ toml = "1.1" tracing-test = { workspace = true } workspace-hack = { path = "../workspace-hack" } -# The examples and integration tests run MoQ sessions, which a driver-only build lacks. -[[example]] -name = "chat" -required-features = ["net"] - -[[example]] -name = "clock" -required-features = ["net"] - -# The QUIC Interop Runner endpoint (`test/quic-interop`), on the driver alone. -[[example]] -name = "quic-interop" -required-features = ["driver"] - -[[test]] -name = "integration" -path = "tests/integration/main.rs" -required-features = ["net"] - # Stream fanout through the driver on localhost, swept over streams per connection. [[bench]] name = "fanout" harness = false -required-features = ["driver"] [lints] workspace = true diff --git a/rs/moq-tokio/README.md b/rs/moq-tokio/README.md index bf8830d6abb..8122dafaabc 100644 --- a/rs/moq-tokio/README.md +++ b/rs/moq-tokio/README.md @@ -10,11 +10,12 @@ Tokio-based connection helpers for native [Media over QUIC](https://moq.dev) applications, on top of [moq-net](https://github.com/moq-dev/moq/tree/main/rs/moq-net). -Establishes MoQ connections over a few different transports, selectable via cargo features: +Establishes MoQ connections over a few different transports, all compiled in and picked at runtime by URL scheme or config: - **WebTransport** (HTTP/3) via [moq-quic](https://crates.io/crates/moq-quic) - **Raw QUIC** with ALPN negotiation - **WebSocket** as a fallback when QUIC isn't available +- **TCP**, **TLS**, and **Unix sockets** (Unix only) via [qmux](https://crates.io/crates/qmux) Also handles TLS, certificate generation, logging setup, and reconnection logic, with Usage-derived configuration ready for binaries. `quic::web` exposes WebTransport streams, datagrams, and send groups without requiring a MoQ session; its session also implements moq-net's poll traits directly. diff --git a/rs/moq-tokio/benches/fanout.rs b/rs/moq-tokio/benches/fanout.rs index f8a49f0a385..039d075a3de 100644 --- a/rs/moq-tokio/benches/fanout.rs +++ b/rs/moq-tokio/benches/fanout.rs @@ -159,7 +159,6 @@ fn bench_fanout(c: &mut Criterion) { group.finish(); } -#[cfg(feature = "quic")] mod native { use super::*; use bytes::Bytes; @@ -266,10 +265,5 @@ mod native { } } -#[cfg(not(feature = "quic"))] -mod native { - pub fn benchmark(_: &mut criterion::Criterion) {} -} - criterion_group!(benches, bench_fanout, native::benchmark); criterion_main!(benches); diff --git a/rs/moq-tokio/src/abort.rs b/rs/moq-tokio/src/abort.rs index 6e9ae1dd8f2..be3f1dd8b71 100644 --- a/rs/moq-tokio/src/abort.rs +++ b/rs/moq-tokio/src/abort.rs @@ -6,10 +6,8 @@ /// with nothing left able to reach it. Derefs to the handle, so an owner can still /// await the task's output or abort it early. #[derive(Debug)] -#[cfg(any(feature = "quic", all(feature = "watch", feature = "_certs")))] pub(crate) struct AbortOnDrop(tokio::task::JoinHandle); -#[cfg(any(feature = "quic", all(feature = "watch", feature = "_certs")))] impl AbortOnDrop { /// Take ownership of a spawned task. pub(crate) fn new(handle: tokio::task::JoinHandle) -> Self { @@ -17,7 +15,6 @@ impl AbortOnDrop { } } -#[cfg(any(feature = "quic", all(feature = "watch", feature = "_certs")))] impl std::ops::Deref for AbortOnDrop { type Target = tokio::task::JoinHandle; @@ -26,14 +23,12 @@ impl std::ops::Deref for AbortOnDrop { } } -#[cfg(any(feature = "quic", all(feature = "watch", feature = "_certs")))] impl std::ops::DerefMut for AbortOnDrop { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } -#[cfg(any(feature = "quic", all(feature = "watch", feature = "_certs")))] impl Drop for AbortOnDrop { fn drop(&mut self) { self.0.abort(); @@ -42,11 +37,9 @@ impl Drop for AbortOnDrop { /// Owns a task spawned where [`Spawner::current`](crate::runtime::Spawner::current) picks, /// the simulator included, cancelling it when this guard drops. -#[cfg(feature = "net")] #[derive(Debug)] pub(crate) struct Detached(futures::future::AbortHandle); -#[cfg(feature = "net")] impl Detached { /// Spawn `future` beside the caller. pub(crate) fn spawn(future: impl Future + Send + 'static) -> Self { @@ -61,7 +54,6 @@ impl Detached { } } -#[cfg(feature = "net")] impl Drop for Detached { fn drop(&mut self) { self.0.abort(); diff --git a/rs/moq-tokio/src/client.rs b/rs/moq-tokio/src/client.rs index e4842c27546..3f6b061e7eb 100644 --- a/rs/moq-tokio/src/client.rs +++ b/rs/moq-tokio/src/client.rs @@ -5,7 +5,6 @@ //! accept side is [`crate::server`]. use crate::{Addrs, Connection, Error, Restart}; -#[cfg(all(feature = "websocket", feature = "quic"))] use std::future::Future; use url::Url; @@ -29,7 +28,7 @@ pub struct Config { /// The simulated host the QUIC endpoint binds on, at the configured bind port, in place of /// a UDP socket. For tests on `kio::clock::sim`; see [`crate::quic::driver::sim`]. - #[cfg(all(feature = "sim", feature = "quic"))] + #[cfg(feature = "sim")] pub sim: Option, } @@ -52,7 +51,6 @@ pub struct Client { /// every transport (passed into the QUIC backend's `connect` and used directly for /// raw TCP/UDS qmux and WebSocket). Resolved once in [`Client::new`] so the ALPN list /// can't diverge between transports. - #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", feature = "uds"))] pub(crate) versions: moq_net::Versions, /// The URL from [`connect.url`](crate::connect::Config::url), dialed by [`Client::publish`] / [`Client::consume`]. connect: Option, @@ -61,38 +59,29 @@ pub struct Client { /// The connect deadline, backoff, and GOAWAY handling each [`Connection`] runs under. pub(crate) policy: moq_net::reconnect::Config, /// Whether dials present an mTLS client certificate, refusing schemes that can't. - #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", feature = "uds"))] client_cert: bool, /// The resolved Happy Eyeballs timings, used by the `tcp://` and `tls://` /// dials here; the QUIC backend captures its own copy from the config. - #[cfg(feature = "tcp")] failover_delay: std::time::Duration, - #[cfg(feature = "tcp")] resolution_delay: std::time::Duration, /// The TLS settings a `tls://` dial builds from when it runs, so a client /// that only dials plaintext `tcp://` never needs a crypto provider. - #[cfg(feature = "tcp")] tcp_tls: crate::tls::Connect, - #[cfg(feature = "websocket")] websocket: crate::websocket::Config, /// The TLS server name override used by the WebSocket fallback. - #[cfg(feature = "websocket")] tls_host_name: Option, /// Only the TLS-based dials read this; the plaintext qmux transports have none. - #[cfg(any(feature = "quic", feature = "websocket"))] tls: rustls::ClientConfig, - #[cfg(feature = "quic")] quic: Option, /// The settings each qmux dial starts from: the `[quic]` windows and stream count, so a /// qmux session takes the same per-session numbers as a QUIC one. - #[cfg(any(feature = "websocket", feature = "tcp"))] qmux: qmux::Config, /// Replaces the transport dial in tests, so the reconnect loop can run over /// in-memory sessions on a paused clock. #[cfg(test)] pub(crate) dialer: Option>, /// Replaces the QUIC transport a probe reaches in tests. - #[cfg(all(test, feature = "websocket", feature = "quic"))] + #[cfg(test)] pub(crate) prober: Option>, /// Where every dial goes instead of the network, set by [`Self::with_network`]. #[cfg(feature = "sim")] @@ -107,29 +96,18 @@ pub(crate) type Dialer = dyn Fn(crate::connect::Addr, moq_net::Client) -> std::p + Sync; /// A test stand-in for the QUIC transport [`Client::probe`] reaches, handed the address. -#[cfg(all(test, feature = "websocket", feature = "quic"))] +#[cfg(test)] pub(crate) type Prober = dyn Fn(crate::connect::Addr) -> std::pin::Pin> + Send>> + Send + Sync; impl Client { - /// Build a client from its config. - /// - /// Errors if no transport feature is compiled in. - #[cfg(not(feature = "_transport"))] - pub fn new(_config: Config) -> crate::Result { - Err(Error::NoBackend( - "no backend compiled; enable quic, websocket, tcp, or uds feature", - )) - } - /// Build a client from its config, binding the QUIC socket up front. - #[cfg(feature = "_transport")] pub fn new(config: Config) -> crate::Result { let Config { connect: config, quic, - #[cfg(all(feature = "sim", feature = "quic"))] + #[cfg(feature = "sim")] sim, } = config; @@ -146,33 +124,25 @@ impl Client { // Only the rustls-backed transports use this. The plaintext qmux // transports must not require a rustls crypto provider. - #[cfg(any(feature = "quic", feature = "websocket"))] let tls = config.tls.build()?; - #[cfg(any(feature = "websocket", feature = "tcp"))] let qmux = crate::qmux_config(&quic.resolve()); - #[cfg(all(feature = "quic", not(feature = "sim")))] + #[cfg(not(feature = "sim"))] let quic = crate::quic::Client::new(&config, &quic); - #[cfg(all(feature = "quic", feature = "sim"))] + #[cfg(feature = "sim")] let quic = match sim { Some(host) => crate::quic::Client::simulated(&config, &quic, host), None => crate::quic::Client::new(&config, &quic), }; - #[cfg(feature = "quic")] let quic = Some(quic?); let versions = config.versions(); // Read before the struct literal below moves fields out of `config`. let resolved = config.resolve(); - #[cfg(feature = "tcp")] let failover_delay = resolved.race; - #[cfg(feature = "tcp")] let resolution_delay = resolved.resolution_delay; - #[cfg(feature = "tcp")] let tcp_tls = config.tls.clone(); - #[cfg(feature = "websocket")] let tls_host_name = config.tls.host_name.clone(); - #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", feature = "uds"))] let client_cert = config.tls.has_client_cert(); let mut policy = moq_net::reconnect::Config::default(); policy.backoff = config.backoff.resolve(); @@ -190,32 +160,22 @@ impl Client { Ok(Self { moq, peer_hop: None, - #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", feature = "uds"))] versions, connect: config.url, tokens: config.tokens, policy, - #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", feature = "uds"))] client_cert, - #[cfg(feature = "tcp")] failover_delay, - #[cfg(feature = "tcp")] resolution_delay, - #[cfg(feature = "tcp")] tcp_tls, - #[cfg(feature = "websocket")] websocket: config.websocket, - #[cfg(feature = "websocket")] tls_host_name, - #[cfg(any(feature = "quic", feature = "websocket"))] tls, - #[cfg(feature = "quic")] quic, - #[cfg(any(feature = "websocket", feature = "tcp"))] qmux, #[cfg(test)] dialer: None, - #[cfg(all(test, feature = "websocket", feature = "quic"))] + #[cfg(test)] prober: None, #[cfg(feature = "sim")] network: None, @@ -323,15 +283,8 @@ impl Client { Connection::new(self.clone(), addrs.into()) } - /// With no transport compiled in, no URL can be dialed. - #[cfg(not(any(feature = "quic", feature = "websocket", feature = "tcp", feature = "uds")))] - pub(crate) fn reaches(&self, _url: &Url) -> bool { - false - } - /// Whether this client has a transport that can ever dial `url`, decided from its scheme /// and the backends and certificate it was built with, not from a failed dial. - #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", feature = "uds"))] pub(crate) fn reaches(&self, url: &Url) -> bool { #[cfg(test)] if self.dialer.is_some() { @@ -346,21 +299,15 @@ impl Client { return false; } // An explicitly closed QUIC endpoint cannot open another socket. - #[cfg(feature = "quic")] let quic = self.quic.as_ref().is_some_and(|quic| !quic.is_closed()); - #[cfg(all(feature = "sim", feature = "quic"))] + #[cfg(feature = "sim")] if self.simulated() { return quic && simulated_scheme(scheme); } - #[cfg(not(feature = "quic"))] - let quic = false; - #[cfg(feature = "websocket")] let websocket = self.websocket.resolve().enabled; - #[cfg(not(feature = "websocket"))] - let websocket = false; match scheme { - "tcp" | "tls" => cfg!(feature = "tcp"), - "unix" => cfg!(all(feature = "uds", unix)), + "tcp" | "tls" => true, + "unix" => cfg!(unix), "ws" | "wss" => websocket, "http" | "https" => quic || websocket, "moqt" | "moql" => quic, @@ -369,12 +316,11 @@ impl Client { } /// Whether QUIC binds on a simulated host, where no other transport can dial. - #[cfg(all(feature = "sim", feature = "quic"))] + #[cfg(feature = "sim")] fn simulated(&self) -> bool { self.quic.as_ref().is_some_and(crate::quic::Client::is_simulated) } - #[cfg(feature = "quic")] pub(crate) fn fresh_port(&mut self) -> crate::Result<()> { if let Some(quic) = &mut self.quic { quic.fresh_port()?; @@ -396,7 +342,6 @@ impl Client { /// Only the QUIC endpoint is closed. WebSocket, TCP, and UDS sessions end when their /// [`Connection`] is dropped (the kernel closes the socket on exit). pub async fn close(self) { - #[cfg(feature = "quic")] if let Some(quic) = self.quic { quic.close().await; } @@ -430,7 +375,6 @@ impl Client { /// /// The connect timeout bounds the MoQ handshake from this call. A transport handed /// over cannot be redialed, so there is no reconnect: the session ends with it. - #[cfg(feature = "qmux")] pub async fn connect_with(&self, session: qmux::Session) -> crate::Result { let timeout = self.policy.timeout; let connect = connect_session(&self.moq, session); @@ -445,19 +389,6 @@ impl Client { .await } - /// Dial one attempt of a [`Connection`]'s policy and complete the MoQ handshake. - /// - /// Errors if no transport feature is compiled in. - #[cfg(not(any(feature = "quic", feature = "websocket", feature = "tcp", feature = "uds")))] - pub(crate) async fn dial( - &self, - _attempt: moq_net::reconnect::Attempt, - ) -> crate::Result { - Err(Error::NoBackend( - "no backend compiled; enable quic, websocket, tcp, or uds feature", - )) - } - /// Dial one attempt of a [`Connection`]'s policy and complete the MoQ handshake, /// presenting the URL and credential the attempt carries. /// @@ -466,7 +397,6 @@ impl Client { /// protocol driver is spawned on the current tokio runtime, else the fallback; the session /// closes once the last returned handle drops. The policy bounds the attempt: dropping /// it cancels whichever arm is still pending. - #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", feature = "uds"))] pub(crate) async fn dial( &self, attempt: moq_net::reconnect::Attempt, @@ -478,7 +408,7 @@ impl Client { if self.client_cert && matches!(addr.url().scheme(), "http" | "ws" | "tcp" | "unix") { return Err(Error::ClientCertScheme(addr.url().scheme().to_string())); } - #[cfg(all(feature = "sim", feature = "quic"))] + #[cfg(feature = "sim")] if self.simulated() && !simulated_scheme(addr.url().scheme()) { return Err(Error::SimScheme(addr.url().scheme().to_string())); } @@ -505,7 +435,6 @@ impl Client { } /// The address an attempt dials, and this client presenting the attempt's credential. - #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", feature = "uds"))] fn attempt(&self, attempt: &moq_net::reconnect::Attempt) -> (crate::connect::Addr, Self) { let mut client = self.clone(); client.moq = attempt.client(&self.moq); @@ -515,7 +444,6 @@ impl Client { /// Whether a session dialed at `url` over `transport` sits on the WebSocket fallback of /// a race QUIC could win, so it should probe QUIC. - #[cfg(all(feature = "websocket", feature = "quic"))] pub(crate) fn on_fallback(&self, url: &Url, transport: crate::Transport) -> bool { transport == crate::Transport::WebSocket && self.quic.is_some() && matches!(url.scheme(), "http" | "https") } @@ -525,7 +453,6 @@ impl Client { /// /// The handshake waits for the policy to move off the fallback, since the tokens back /// one session at a time. - #[cfg(all(feature = "websocket", feature = "quic"))] pub(crate) async fn probe( &self, attempt: moq_net::reconnect::Attempt, @@ -551,7 +478,6 @@ impl Client { })) } - #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", feature = "uds"))] async fn connect_inner(&self, addr: crate::connect::Addr) -> crate::Result { let url = addr.url().clone(); // Each session's transport says whether its own request URI carries the target or @@ -560,7 +486,6 @@ impl Client { // Plain TCP (qmux, no TLS). Explicit opt-in scheme; never raced against // QUIC, which can't speak it. Use only on a trusted network. - #[cfg(feature = "tcp")] if url.scheme() == "tcp" { let session = crate::tcp::connect( url, @@ -575,7 +500,6 @@ impl Client { } // Qmux over TLS over TCP, for links that need neither QUIC nor a WebSocket. - #[cfg(feature = "tcp")] if url.scheme() == "tls" { let session = crate::tcp::connect_tls( url, @@ -592,7 +516,7 @@ impl Client { // Unix domain socket (qmux, no TLS). Same-host only; the server can // authenticate us by uid/gid via SO_PEERCRED. - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] if url.scheme() == "unix" { let session = crate::unix::connect(url, &self.versions.alpns(), &self.qmux).await?; let session = connect_session(&moq, session).await?; @@ -601,12 +525,10 @@ impl Client { // A WebSocket URL names its transport. No QUIC backend can dial it, so there is // nothing to race and the fallback's answer is the connect's verdict. - #[cfg(feature = "websocket")] if matches!(url.scheme(), "ws" | "wss") { return self.connect_websocket(&moq, addr).await; } - #[cfg(feature = "quic")] if let Some(quic) = self.quic.as_ref() { let quic_addr = addr.clone(); let quic_handle = async { @@ -616,7 +538,6 @@ impl Client { }; // A simulated host has no TCP for the fallback to race. - #[cfg(feature = "websocket")] if !quic.is_simulated() { return self.race_moq_connect(&moq, addr, quic_handle).await; } @@ -626,15 +547,10 @@ impl Client { return Ok(Dialed::new(session, quic_transport(&url))); } - #[cfg(feature = "websocket")] return self.connect_websocket(&moq, addr).await; - - #[cfg(not(feature = "websocket"))] - return Err(Error::NoBackend("no QUIC backend matched; this should not happen")); } /// Connect over WebSocket alone. - #[cfg(feature = "websocket")] async fn connect_websocket(&self, moq: &moq_net::Client, addr: crate::connect::Addr) -> crate::Result { let alpns = self.versions.alpns(); let session = crate::websocket::connect( @@ -652,10 +568,6 @@ impl Client { /// Race the QUIC dial against the WebSocket fallback, handshaking whichever wins. /// The loser is cancelled as soon as the winner's transport is up. - /// - /// Only compiled when there is a QUIC dial to race: a WebSocket-only build connects - /// over the fallback directly. - #[cfg(all(feature = "websocket", feature = "quic"))] async fn race_moq_connect( &self, moq: &moq_net::Client, @@ -698,7 +610,6 @@ impl Client { /// What a QUIC dial to `url` runs on: WebTransport for `https://` (and the `http://` /// bootstrap), raw QUIC for `moqt://` and `moql://`. -#[cfg(feature = "quic")] fn quic_transport(url: &Url) -> crate::Transport { match url.scheme() { "moqt" | "moql" => crate::Transport::Quic, @@ -714,17 +625,12 @@ pub(crate) struct Dialed { } impl Dialed { - #[cfg_attr( - not(any(feature = "quic", feature = "websocket", feature = "tcp", feature = "uds")), - allow(dead_code, reason = "only a transport feature dials") - )] fn new(session: moq_net::Session, transport: crate::Transport) -> Self { Self { session, transport } } } /// The arm that won a [`race_transport_connect`]; the other was dropped, cancelling it. -#[cfg(all(feature = "websocket", feature = "quic"))] enum TransportRace { Quic(Q), WebSocket(W), @@ -732,7 +638,6 @@ enum TransportRace { /// Race the QUIC dial to `url` against the WebSocket fallback, returning whichever /// transport comes up first. -#[cfg(all(feature = "websocket", feature = "quic"))] async fn race_transport_connect(url: &Url, quic: Q, websocket: W) -> crate::Result> where Q: Future>, @@ -791,7 +696,7 @@ where /// Whether a client on a simulated host can dial `scheme`: only QUIC's, without the `http://` /// bootstrap's fetch over TCP. -#[cfg(all(feature = "sim", feature = "quic"))] +#[cfg(feature = "sim")] fn simulated_scheme(scheme: &str) -> bool { matches!(scheme, "https" | "moqt" | "moql") } @@ -801,7 +706,6 @@ fn simulated_scheme(scheme: &str) -> bool { /// Auth is terminal only when both arms refused. A WebTransport-only endpoint /// answers the fallback with 403 while QUIC is still in flight, and reconnect /// treats is_auth() as terminal, so a mixed pair reports the retryable error. -#[cfg(all(feature = "websocket", feature = "quic"))] fn race_error(quic: Error, websocket: Error) -> Error { match (quic.is_auth(), websocket.is_auth()) { (false, false) => Error::TransportRace { @@ -813,7 +717,6 @@ fn race_error(quic: Error, websocket: Error) -> Error { } } -#[cfg(feature = "_transport")] async fn connect_session( client: &moq_net::Client, transport: S, @@ -830,13 +733,11 @@ mod tests { use super::*; /// A millisecond track: the frames written here carry timestamps. - #[cfg(all(feature = "websocket", feature = "quic"))] fn timed() -> moq_net::track::Info { moq_net::track::Info::default().with_timescale(moq_net::Timescale::MILLI) } /// A client certificate refuses every scheme that can't present it, before dialing. - #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", feature = "uds"))] #[tokio::test] async fn client_cert_refuses_schemes_that_cannot_present_it() { let mut config = crate::connect::Config::default(); @@ -864,25 +765,21 @@ mod tests { assert_eq!(*dialed.lock().unwrap(), ["https", "wss", "moqt", "moql", "tls"]); } - #[cfg(feature = "quic")] #[tokio::test] async fn fixed_target_preserves_request_and_refuses_redirect() { check_fixed_redirect(false, true).await; } - #[cfg(feature = "quic")] #[tokio::test] async fn one_shot_fixed_target_refuses_redirect() { check_fixed_redirect(true, true).await; } - #[cfg(feature = "quic")] #[tokio::test] async fn unused_fixed_fallback_does_not_restrict_connected_target() { check_fixed_redirect(true, false).await; } - #[cfg(feature = "quic")] async fn check_fixed_redirect(once: bool, pinned: bool) { let mut listen = crate::listen::Config { bind: Some("127.0.0.1:0".parse().unwrap()), @@ -940,7 +837,6 @@ mod tests { /// A token set on the client reaches the peer's SETUP with its type and bytes intact, /// on every connection, unless a connect token takes its place. - #[cfg(feature = "tcp")] #[tokio::test] async fn a_token_keeps_its_type_and_bytes() { kio::clock::host_time(); // real TCP sockets @@ -1205,7 +1101,6 @@ mod tests { assert_eq!(config.versions().alpns().len(), moq_net::ALPNS.len()); } - #[cfg(all(feature = "websocket", feature = "quic"))] #[tokio::test] async fn race_transport_connect_keeps_websocket_after_quic_auth_error() { let quic = async { Err::(crate::ConnectError::Unauthorized.into()) }; @@ -1221,7 +1116,6 @@ mod tests { assert!(matches!(value, super::TransportRace::WebSocket(1))); } - #[cfg(all(feature = "websocket", feature = "quic"))] #[tokio::test] async fn race_transport_connect_keeps_quic_after_websocket_forbidden() { let quic = async { @@ -1243,7 +1137,6 @@ mod tests { /// Inline rather than in `tests/` so each arm dials its own ephemeral port: the /// public connect sends the fallback to the QUIC port, which nothing reserves over /// TCP as well. - #[cfg(all(feature = "websocket", feature = "quic"))] #[tokio::test] async fn websocket_forbidden_does_not_end_a_quic_connect() { use tokio::io::{AsyncReadExt, AsyncWriteExt}; @@ -1311,7 +1204,6 @@ mod tests { /// QUIC wins while the fallback handshake is held until QUIC connects. /// Each transport owns its ephemeral port; this exercises the same race as /// connect_inner without depending on which real handshake runs faster. - #[cfg(all(feature = "websocket", feature = "quic"))] #[tracing_test::traced_test] #[tokio::test] async fn broadcast_race_quic_wins() { @@ -1424,7 +1316,6 @@ mod tests { .expect("server task failed"); } - #[cfg(all(feature = "websocket", feature = "quic"))] #[tokio::test] async fn race_transport_connect_reports_auth_when_both_refuse() { let quic = async { Err::(crate::ConnectError::Unauthorized.into()) }; @@ -1436,7 +1327,6 @@ mod tests { assert!(err.is_auth(), "unexpected error: {err}"); } - #[cfg(all(feature = "websocket", feature = "quic"))] #[tokio::test] async fn race_transport_connect_reports_quic_error_when_websocket_forbidden() { let quic = async { @@ -1452,7 +1342,6 @@ mod tests { assert!(!err.is_auth(), "mixed auth/non-auth must stay retryable: {err}"); } - #[cfg(all(feature = "websocket", feature = "quic"))] #[tokio::test] async fn race_transport_connect_keeps_websocket_after_quic_non_auth_error() { let quic = async { Err::(Error::ConnectFailed) }; @@ -1466,14 +1355,12 @@ mod tests { /// The URL a race unit test dials. Each test runs in its own process under nextest, /// so the process-wide [`crate::websocket::won`] memo starts empty. - #[cfg(all(feature = "websocket", feature = "quic"))] fn race_url() -> Url { Url::parse("https://race.invalid/").unwrap() } /// QUIC winning a race clears WebSocket's earlier win, so the next dial gives QUIC /// its head start again. - #[cfg(all(feature = "websocket", feature = "quic"))] #[tokio::test(start_paused = true)] async fn quic_winning_restores_its_head_start() { crate::websocket::remember(&race_url()); @@ -1491,7 +1378,6 @@ mod tests { } /// A race arm that never finishes, and reports through `dropped` once it is dropped. - #[cfg(all(feature = "websocket", feature = "quic"))] fn loser() -> ( impl Future, tokio::sync::oneshot::Receiver, @@ -1506,7 +1392,6 @@ mod tests { /// WebSocket winning cancels the QUIC dial before the race returns, so no QUIC /// session can come up behind the one WebSocket serves. - #[cfg(all(feature = "websocket", feature = "quic"))] #[tokio::test(start_paused = true)] async fn websocket_winning_cancels_the_quic_dial() { let (quic, mut dropped) = loser::>(); @@ -1524,7 +1409,6 @@ mod tests { } /// QUIC winning cancels the WebSocket dial before the race returns. - #[cfg(all(feature = "websocket", feature = "quic"))] #[tokio::test(start_paused = true)] async fn quic_winning_cancels_the_websocket_dial() { let quic = async { Ok("quic") }; @@ -1541,7 +1425,6 @@ mod tests { ); } - #[cfg(all(feature = "websocket", feature = "quic"))] #[tokio::test] async fn race_transport_connect_returns_when_quic_transport_connects() { let quic = async { Ok("quic") }; @@ -1564,7 +1447,6 @@ mod tests { /// That is what wedged a publisher against a livelocked relay: [`Connection`] only /// re-arms its backoff (and checks its give-up timeout) *between* attempts, so an /// attempt that never returns stalls the retry loop for good. - #[cfg(feature = "websocket")] #[tokio::test] async fn connect_times_out_against_a_peer_that_never_speaks() { let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap(); diff --git a/rs/moq-tokio/src/connect.rs b/rs/moq-tokio/src/connect.rs index a458b15dd75..51830c57e5d 100644 --- a/rs/moq-tokio/src/connect.rs +++ b/rs/moq-tokio/src/connect.rs @@ -87,7 +87,6 @@ impl Addr { } /// The same peer and addresses, requested at `url`. - #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", feature = "uds"))] pub(crate) fn with_url(&self, url: Url) -> Self { Self { url, @@ -351,7 +350,6 @@ pub enum ConnectError { impl ConnectError { /// Only the transports that carry an HTTP status (WebTransport, WebSocket) can /// classify one; qmux over tcp/unix has no such response. - #[cfg(any(feature = "quic", feature = "websocket"))] pub(crate) fn from_status_u16(status: u16) -> Option { match status { 401 => Some(Self::Unauthorized), @@ -367,7 +365,7 @@ impl ConnectError { } } -#[cfg(all(test, any(feature = "quic", feature = "websocket")))] +#[cfg(test)] mod tests { use super::*; @@ -678,7 +676,6 @@ pub struct Config { /// WebSocket fallback settings (`--websocket-*`), used when QUIC is /// blocked. - #[cfg(feature = "websocket")] #[usage(flatten)] #[serde(default)] pub websocket: crate::websocket::Config, @@ -728,7 +725,6 @@ impl Config { found.toml("[client.quic]", "[quic]", Some("now applies to both directions")); } found.extend(self.tls.deprecated()); - #[cfg(feature = "websocket")] found.extend(self.websocket.deprecated()); found } diff --git a/rs/moq-tokio/src/connection.rs b/rs/moq-tokio/src/connection.rs index 764497fb124..2549cda8e4b 100644 --- a/rs/moq-tokio/src/connection.rs +++ b/rs/moq-tokio/src/connection.rs @@ -200,7 +200,6 @@ impl Backoff { /// Refuse a zero healthy threshold, which would count every session as healthy and /// reset the timeout forever under a peer that drops each one on sight. - #[cfg(feature = "_transport")] pub(crate) fn validate(&self) -> crate::Result<()> { if self.resolve().healthy.is_zero() { return Err(Error::BackoffHealthy); @@ -369,7 +368,6 @@ impl Goaway { } /// The policy these knobs configure, with each unset one at its default. - #[cfg(any(feature = "_transport", test))] pub(crate) fn resolve(&self) -> moq_net::reconnect::Goaway { let mut goaway = moq_net::reconnect::Goaway::default(); goaway.redirect = self.redirect.into(); @@ -1101,7 +1099,6 @@ impl Connection { /// Drive moq-net's policy: dial each attempt it asks for and publish what it does. async fn run(shared: &Shared, client: Client, addrs: Addrs) -> crate::Result<()> { - #[cfg(feature = "quic")] let mut client = client; let mut policy = moq_net::Reconnect::new(client.policy, addrs.as_slice().to_vec(), kio::clock::now()) .map_err(|_| Error::BackoffHealthy)? @@ -1111,14 +1108,12 @@ impl Connection { let mut dial: Option<(url::Url, std::pin::Pin>)> = None; // The QUIC probe in flight while the live session runs on the WebSocket fallback, and // the address whose race that fallback won, which its end makes QUIC's again. - #[cfg(all(feature = "websocket", feature = "quic"))] let (mut probe, mut fallback): (Option, Option) = (None, None); // Mirrors the live session's estimates while it serves. let mut forward: Option = None; let mut timer: Option = None; // Consecutive walks that failed since the last session, and whether a dial failed // since then, which tells a failed walk from a session that ended too soon. - #[cfg(feature = "quic")] let (mut failed_walks, mut dial_failed) = (0, false); loop { @@ -1131,30 +1126,22 @@ impl Connection { match res { Ok(crate::client::Dialed { session, transport }) => { tracing::info!(peer = %Endpoint(&url), %transport, "connected"); - #[cfg(feature = "quic")] - { - (failed_walks, dial_failed) = (0, false); - } + (failed_walks, dial_failed) = (0, false); shared.connected(&session, transport); forward = Some(Forward::new(&session)); policy.connected(kio::clock::now(), session); - #[cfg(all(feature = "websocket", feature = "quic"))] if client.on_fallback(&url, transport) { policy.fallback(kio::clock::now()); fallback = Some(url); } } Err(err) => { - #[cfg(feature = "quic")] - { - dial_failed = true; - } + dial_failed = true; let verdict = verdict(&client, &url, &err); policy.failed(kio::clock::now(), err, verdict); } } } - #[cfg(all(feature = "websocket", feature = "quic"))] if let Some((_, attempt)) = probe.as_mut() && let Poll::Ready(res) = waiter.poll_future(attempt.as_mut()) { @@ -1201,26 +1188,18 @@ impl Connection { } // The policy already counted the timeout; dropping the dial cancels it. Action::Abandon => { - #[cfg(feature = "quic")] if dial.is_some() { dial_failed = true; } dial = None; - #[cfg(all(feature = "websocket", feature = "quic"))] - { - probe = None; - } + probe = None; } - #[cfg(all(feature = "websocket", feature = "quic"))] Action::Probe(attempt) => { let url = attempt.target().url().clone(); let client = client.clone(); probe = Some((url, Box::pin(async move { client.probe(attempt).await }))); } - #[cfg(not(all(feature = "websocket", feature = "quic")))] - Action::Probe(_) => unreachable!("only a WebSocket fallback probes"), Action::Migrating => { - #[cfg(all(feature = "websocket", feature = "quic"))] left_fallback(&mut probe, &mut fallback); forward = None; // One write publishes the predecessor with this status, so a close woken by @@ -1231,7 +1210,6 @@ impl Connection { } Action::Retired => shared.retired(), Action::Offline(failure) => { - #[cfg(all(feature = "websocket", feature = "quic"))] left_fallback(&mut probe, &mut fallback); forward = None; shared.offline(failure.as_ref()); @@ -1242,7 +1220,6 @@ impl Connection { // socket, then try another flow before the next walk. Only a retry window // that allows a third walk gets there: a black-holed handshake outlasts the // default window after the first walk. - #[cfg(feature = "quic")] if std::mem::take(&mut dial_failed) && policy.targets().iter().any(|addr| quic_scheme(addr.url())) { failed_walks += 1; if failed_walks >= 2 { @@ -1259,7 +1236,6 @@ impl Connection { // The terminal snapshot does the offline bookkeeping, so a watcher never sees a // `Disconnected` the loop will not redial from. Action::Done(res) => { - #[cfg(all(feature = "websocket", feature = "quic"))] left_fallback(&mut probe, &mut fallback); shared.retired(); return res; @@ -1459,11 +1435,9 @@ impl Connection { pub(crate) type Dial = dyn Future> + Send; /// A QUIC probe in flight, resolving to the MoQ handshake to finish over what it reached. -#[cfg(all(feature = "websocket", feature = "quic"))] type Probe = dyn Future>>> + Send; /// The address a probe dials, and the probe in flight. -#[cfg(all(feature = "websocket", feature = "quic"))] type Probing = (url::Url, std::pin::Pin>); /// A random non-zero hop id within 2^53, which older `@moq/lite` clients still decode. @@ -1474,7 +1448,6 @@ fn random_hop() -> std::num::NonZeroU64 { /// The live session left the WebSocket fallback: stop probing, and give QUIC its head start /// on the next race, since the outage that lost the last one may be over. -#[cfg(all(feature = "websocket", feature = "quic"))] fn left_fallback(probe: &mut Option, fallback: &mut Option) { *probe = None; if let Some(url) = fallback.take() { @@ -1483,7 +1456,6 @@ fn left_fallback(probe: &mut Option, fallback: &mut Option) { } /// Whether a dial to `url` runs over the QUIC endpoint, whose socket a fresh port replaces. -#[cfg(feature = "quic")] fn quic_scheme(url: &url::Url) -> bool { matches!(url.scheme(), "http" | "https" | "moqt" | "moql") } @@ -1827,7 +1799,6 @@ mod tests { /// SYN to a socket that is bound but not listening, while macOS drops it and /// each attempt waits out its timeout. Listening also keeps the port reserved, /// so no other listener (or an ephemeral self-connect) can take it mid-test. - #[cfg(feature = "tcp")] async fn dead() -> Url { let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.expect("bind"); let addr = listener.local_addr().expect("local addr"); @@ -1837,7 +1808,6 @@ mod tests { } /// A bound stream listener and the URL that reaches it. - #[cfg(feature = "tcp")] async fn live() -> (crate::Listener, Url) { let mut config = crate::listen::Config::default(); config.tcp.bind = Some("127.0.0.1:0".parse().unwrap()); @@ -1852,7 +1822,6 @@ mod tests { } /// A client that trusts the self-signed [`live`] listener. - #[cfg(feature = "tcp")] fn client() -> Client { crate::crypto::install_default().unwrap(); @@ -1980,7 +1949,6 @@ mod tests { assert!(matches!(woken.phases()[..], [Phase::Closed { .. }])); } - #[cfg(feature = "tcp")] #[tokio::test] async fn aborting_before_the_loop_is_polled_publishes_its_final_snapshot() { // The current-thread runtime cannot poll the spawned loop before our first await. @@ -2013,7 +1981,6 @@ mod tests { /// The first address that answers wins, however many dead ones precede it. /// This is what keeps a peer reachable when discovery advertises an interface /// that doesn't route from here ahead of the one that does. - #[cfg(feature = "tcp")] #[tokio::test] async fn the_walk_lands_past_the_dead_addresses() { let (mut server, live) = live().await; @@ -2043,7 +2010,6 @@ mod tests { } /// With nothing reachable the walk reports a failure rather than hanging. - #[cfg(feature = "tcp")] #[tokio::test] async fn the_walk_fails_when_nothing_answers() { let dead_a = dead().await; @@ -2063,7 +2029,6 @@ mod tests { /// anyone who can read logs. This drives the real `tracing` stack rather than /// [`Endpoint`]'s `Display`, so it also catches a log site that forgot to use /// it. moq-net's own log sites have a test of their own. - #[cfg(feature = "tcp")] #[tracing_test::traced_test] #[tokio::test] async fn dialing_never_logs_the_credential() { @@ -2086,7 +2051,6 @@ mod tests { } /// Invalid local configuration must end an unlimited reconnect loop without waiting. - #[cfg(all(feature = "quic", feature = "websocket"))] #[tokio::test(start_paused = true)] async fn an_unsupported_scheme_ends_unlimited_reconnects() { let mut config = crate::connect::Config::default(); @@ -2103,20 +2067,13 @@ mod tests { } /// A URL host that parses but can never be a TLS server name ends an unlimited reconnect loop. - #[cfg(all(feature = "quic", feature = "websocket"))] #[tokio::test(start_paused = true)] async fn an_invalid_tls_server_name_ends_unlimited_reconnects() { let mut config = crate::connect::Config::default(); config.tls.insecure = Some(true); config.backoff.timeout = Some((Duration::ZERO).into()); let client = config.init(Default::default()).expect("build client"); - for target in [ - "https://a!b:1/", - "wss://a!b:1/", - "moqt://a!b:1/", - #[cfg(feature = "tcp")] - "tls://a!b:1/", - ] { + for target in ["https://a!b:1/", "wss://a!b:1/", "moqt://a!b:1/", "tls://a!b:1/"] { let connection = client.connect(url(target)); let _ = kio::clock::timeout(Duration::from_secs(1), connection.closed()) .await @@ -2128,7 +2085,6 @@ mod tests { /// A refused first dial ends the loop with its error at once, spending none of an /// unlimited retry window: a peer that never answered is more likely a setup mistake /// than a restart. - #[cfg(feature = "tcp")] #[tokio::test(start_paused = true)] async fn a_refused_first_dial_fails_at_once() { // Refusal is what's under test, so this can't use [`dead`]. Only Linux @@ -2177,7 +2133,6 @@ mod tests { /// ends the session from the server. Returns the connection, already reporting /// [`Status::Disconnected`], the live server's address and its later sessions, and the /// server task. - #[cfg(feature = "tcp")] async fn redialing( host: &str, config: crate::connect::Config, @@ -2212,7 +2167,6 @@ mod tests { /// A redial that keeps failing reports why while it retries, and the connect that /// finally lands clears it. Without this a caller only learns the reason once the /// loop gives up, which with no retry window is never. - #[cfg(feature = "tcp")] #[tokio::test] async fn a_failing_redial_reports_why_until_it_connects() { // Unique to this test: the table is process-wide. @@ -2255,7 +2209,6 @@ mod tests { } /// Closing a connection between retries ends the retry, so its reason goes with it. - #[cfg(feature = "tcp")] #[tokio::test] async fn closing_between_retries_clears_the_failure() { // Unique to this test: the table is process-wide. @@ -2289,7 +2242,6 @@ mod tests { /// The connection's auth handle presents its token on every session the loop makes, /// without the application adding it again. - #[cfg(feature = "tcp")] #[tokio::test] async fn a_token_is_presented_on_every_session() { const WAIT: Duration = Duration::from_secs(10); @@ -2357,7 +2309,6 @@ mod tests { /// Ending the connection's auth handle ends the loop at its next reconnect, rather than /// redialing sessions the handle refuses. - #[cfg(feature = "tcp")] #[tokio::test] async fn an_ended_auth_handle_ends_the_loop() { const WAIT: Duration = Duration::from_secs(10); @@ -2384,7 +2335,6 @@ mod tests { } /// A session that ends the loop reports through `closed`, not as a retry reason. - #[cfg(feature = "tcp")] #[tokio::test] async fn a_session_that_ends_the_loop_reports_no_failure() { const WAIT: Duration = Duration::from_secs(10); @@ -2420,7 +2370,6 @@ mod tests { /// A loop that gives up reports its error next, never a `Disconnected` it will not redial /// from, whether or not a session ever connected. - #[cfg(feature = "tcp")] #[tokio::test] async fn a_stopped_loop_reports_its_error_next() { const WAIT: Duration = Duration::from_secs(10); @@ -2476,7 +2425,6 @@ mod tests { /// An auth rejection settles the walk like a status, an unreachable scheme is unusable, and /// every other failure, a protocol violation included, is just a failed dial. - #[cfg(feature = "tcp")] #[test] fn a_verdict_reads_the_address_and_the_answer_not_the_error_kind() { let client = client(); @@ -2498,7 +2446,6 @@ mod tests { assert_eq!(verdict(Error::MoqNet(moq_net::Error::Expired)), Verdict::Retry); assert_eq!(verdict(Error::NoBackend("none")), Verdict::Retry); let unknown = url("moqz://localhost/"); - #[cfg(feature = "websocket")] { let mut config = crate::connect::Config::default(); config.websocket.enabled = Some(false); @@ -2518,12 +2465,10 @@ mod tests { /// /// Holding is what decides the transport race without depending on timing: the /// QUIC dial cannot finish until the test says so. - #[cfg(all(feature = "websocket", feature = "quic"))] struct Forwarder { gate: tokio::sync::watch::Sender, } - #[cfg(all(feature = "websocket", feature = "quic"))] impl Forwarder { async fn start(front: tokio::net::UdpSocket, server: std::net::SocketAddr) -> Self { use std::sync::Arc; @@ -2582,7 +2527,6 @@ mod tests { /// When QUIC wins the race the WebSocket dial is cancelled at once: its socket /// closes without carrying a session, and the one session runs over QUIC. - #[cfg(all(feature = "websocket", feature = "quic"))] #[tokio::test] async fn quic_winning_cancels_the_websocket_dial() { use tokio::io::AsyncReadExt; @@ -2661,7 +2605,6 @@ mod tests { /// /// Returns its address, a receiver yielding each accepted session (so the test /// can drain it), and the listener task. - #[cfg(feature = "tcp")] async fn serve( origin: moq_net::origin::Producer, ) -> ( @@ -2690,7 +2633,6 @@ mod tests { /// name again. The drained relay still accepts, so a cached resolve would land /// right back on it. The live track hands over at a group boundary, and the old /// session closes at our handover cap, well before the peer's own deadline. - #[cfg(feature = "tcp")] #[tokio::test] async fn a_fleet_drain_redials_through_a_fresh_resolve() { const WAIT: Duration = Duration::from_secs(10); @@ -2790,7 +2732,6 @@ mod tests { /// A replacement that drops while the drained session still serves leaves the handle /// on that session, reporting Migrating rather than a Disconnected that would claim /// nothing serves. Its subscription keeps delivering through the handover. - #[cfg(feature = "tcp")] #[tokio::test] async fn a_dropped_replacement_hands_back_to_the_draining_session() { kio::clock::host_time(); // real TCP sockets @@ -2901,7 +2842,6 @@ mod tests { /// Under [`Restart::Wait`] an empty-URI GOAWAY changes nothing while the peer keeps /// the session: no migration and no redial. Its close then reconnects like any drop. - #[cfg(feature = "tcp")] #[tokio::test] async fn a_waited_restart_redials_only_once_the_session_closes() { use futures::FutureExt; @@ -2957,7 +2897,6 @@ mod tests { .unwrap(); } - #[cfg(all(feature = "websocket", feature = "quic"))] fn fallback_version() -> moq_net::Version { "moq-lite-07-wip".parse().unwrap() } @@ -2969,7 +2908,6 @@ mod tests { /// A dial lands on WebSocket, as the race does while UDP is blocked, and records the win /// the way the race would. A probe fails while `blocked` holds and otherwise reaches what /// stands in for QUIC. - #[cfg(all(feature = "websocket", feature = "quic"))] fn fallback_client( origin: moq_net::origin::Producer, blocked: std::sync::Arc, @@ -3043,7 +2981,6 @@ mod tests { } /// The MoQ handshake a test dial runs over `transport`. - #[cfg(all(feature = "websocket", feature = "quic"))] async fn connect_session(moq: &moq_net::Client, transport: qmux::Session) -> crate::Result { let (session, driver) = moq.connect(moq_net::time::Instant::now(), transport).await?; tokio::spawn(moq_net::time::run(driver)); @@ -3054,7 +2991,6 @@ mod tests { /// probe gets through, without dropping the subscription it carries, and gives the race /// back QUIC's head start. Until then it stays on WebSocket, probing no faster than the /// backoff allows. - #[cfg(all(feature = "websocket", feature = "quic"))] #[tokio::test(start_paused = true)] async fn a_websocket_fallback_returns_to_quic_once_udp_works() { use std::sync::atomic::{AtomicBool, Ordering}; @@ -3143,7 +3079,6 @@ mod tests { /// A WebSocket win is provisional: once the session it brought up ends, the redial /// gives QUIC its head start again, since the outage that lost the race may be over. - #[cfg(all(feature = "websocket", feature = "quic"))] #[tokio::test(start_paused = true)] async fn a_websocket_session_ending_restores_the_quic_head_start() { const WAIT: Duration = Duration::from_secs(5); @@ -3169,7 +3104,6 @@ mod tests { /// A configured token is held before its dial starts the session, so a broadcast /// published before the dial, which only that token's grant covers, waits for its /// answer instead of closing the session against the connection credential's grant. - #[cfg(feature = "tcp")] #[tokio::test(start_paused = true)] async fn a_publication_waits_for_a_configured_token() { let version: moq_net::Version = "moq-lite-07-wip".parse().unwrap(); diff --git a/rs/moq-tokio/src/error.rs b/rs/moq-tokio/src/error.rs index 17796055334..0e03826b4b4 100644 --- a/rs/moq-tokio/src/error.rs +++ b/rs/moq-tokio/src/error.rs @@ -5,10 +5,6 @@ use std::sync::Arc; /// Dependency errors are stored as messages so their crates stay out of this crate's public /// API. Several of them (reqwest above all) keep the useful detail in `source()`, which a /// plain `to_string()` would drop. -#[allow( - dead_code, - reason = "a build with no transport feature compiles no backend module, so nothing calls this" -)] pub(crate) fn message(err: impl std::error::Error) -> String { use std::fmt::Write; @@ -23,10 +19,6 @@ pub(crate) fn message(err: impl std::error::Error) -> String { /// Generates `From` conversions into message-carrying variants of the enclosing module's `Error`, /// so `?` still works on a dependency's error without that dependency reaching our public API. -#[allow( - unused_macros, - reason = "a build with no transport feature compiles no backend module, so nothing calls this" -)] macro_rules! from_message { ($($ty:ty => $variant:ident),* $(,)?) => { $( @@ -39,10 +31,6 @@ macro_rules! from_message { }; } -#[allow( - unused_imports, - reason = "a build with no transport feature compiles no backend module, so nothing calls this" -)] pub(crate) use from_message; /// Whether an HTTP response status means "ask again later". @@ -50,7 +38,6 @@ pub(crate) use from_message; /// A response that arrived is the server's answer, and only this narrow set invites another /// attempt: request timeout, rate limit, and the gateway/overload statuses. Every other status, /// `404` and `403` included, is settled. -#[cfg(feature = "net")] pub(crate) fn status_retryable(status: u16) -> bool { matches!(status, 408 | 429 | 502 | 503 | 504) } @@ -77,7 +64,6 @@ pub enum Error { Io(Arc), /// The MoQ session itself failed, after the transport was established. - #[cfg(feature = "net")] #[error(transparent)] MoqNet(#[from] moq_net::Error), @@ -93,7 +79,7 @@ pub enum Error { #[error("failed to initialize Android logcat layer")] Logcat(#[source] Arc), - /// No compiled-in backend or configured listener can serve this. The string names what is missing. + /// No configured backend or listener can serve this. The string names what is missing. #[error("{0}")] NoBackend(&'static str), @@ -158,12 +144,10 @@ pub enum Error { SimScheme(String), /// The server rejected the connection with an auth status. See [`crate::ConnectError`]. - #[cfg(feature = "net")] #[error(transparent)] Connect(#[from] crate::ConnectError), /// Both halves of the QUIC/WebSocket race failed, so neither error alone tells the story. - #[cfg(feature = "websocket")] #[error("failed to connect to server: QUIC failed: {quic}; WebSocket failed: {websocket}")] TransportRace { /// Why the QUIC attempt failed. @@ -238,7 +222,6 @@ pub enum Error { /// A listener's endpoint stopped, so [`Listener::accept`](crate::Listener::accept) can never /// yield another session. The endpoint's own failure is logged where it happened. - #[cfg(feature = "_transport")] #[error("the {0} listener stopped accepting")] Accept(crate::Transport), @@ -247,58 +230,48 @@ pub enum Error { Tls(Arc), /// The QUIC backend failed. - #[cfg(feature = "quic")] #[error(transparent)] Quic(Arc), /// The WebSocket fallback transport failed. - #[cfg(feature = "websocket")] #[error(transparent)] WebSocket(Arc), /// The TCP (qmux) transport failed. - #[cfg(feature = "tcp")] #[error(transparent)] Tcp(Arc), /// The Unix socket transport failed. - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] #[error(transparent)] Unix(Arc), /// [`crate::watch::Files`] could not watch a file's directory. The string has the details. - #[cfg(feature = "watch")] #[error("failed to watch files: {0}")] Watch(String), /// A qmux session refused the limits [`crate::server::Request::with_quic_limits`] set, /// such as a rate cap, which qmux cannot pace. - #[cfg(feature = "qmux")] #[error("qmux refused the session limits: {0}")] QmuxLimits(String), } impl Error { /// The auth rejection behind this error, digging through backend and race variants. - #[cfg(feature = "net")] pub fn connect_error(&self) -> Option { match self { Self::Connect(err) => Some(*err), Self::MoqNet( moq_net::Error::Unauthorized | moq_net::Error::Session(moq_net::SessionError::Unauthorized), ) => Some(crate::ConnectError::Unauthorized), - #[cfg(feature = "quic")] Self::Quic(err) => err.connect_error(), - #[cfg(feature = "websocket")] Self::TransportRace { quic, websocket } => quic.connect_error().or_else(|| websocket.connect_error()), - #[cfg(feature = "websocket")] Self::WebSocket(err) => err.connect_error(), _ => None, } } /// True if the server rejected us for auth reasons, so retrying won't help without new credentials. - #[cfg(feature = "net")] pub fn is_auth(&self) -> bool { // Neither code has an HTTP status, so neither has a `ConnectError` to report. matches!( @@ -322,15 +295,12 @@ impl Error { // A race is only settled when both halves were answered, and answered with something not // worth repeating: one transport being refused says nothing about the other, so a `404` // over QUIC alongside a dead WebSocket is still just a failed dial. - #[cfg(feature = "websocket")] Self::TransportRace { quic, websocket } => match (quic.status(), websocket.status()) { (Some(quic), Some(websocket)) if !status_retryable(quic) && !status_retryable(websocket) => Some(quic), _ => None, }, - #[cfg(feature = "quic")] Self::Quic(err) => err.status(), - #[cfg(feature = "websocket")] Self::WebSocket(err) => err.status(), _ => None, } @@ -338,7 +308,6 @@ impl Error { } /// What a connection reports when moq-net's reconnect policy fails an attempt or gives up. -#[cfg(feature = "net")] impl From for Error { fn from(failure: moq_net::reconnect::Failure) -> Self { use moq_net::reconnect::Failure; @@ -372,7 +341,6 @@ impl From for Error { } } -#[cfg(feature = "quic")] impl From for Error { fn from(err: crate::quic::Error) -> Self { if let Some(err) = err.connect_error() { @@ -383,7 +351,6 @@ impl From for Error { } } -#[cfg(feature = "websocket")] impl From for Error { fn from(err: crate::websocket::Error) -> Self { if let Some(err) = err.connect_error() { @@ -394,14 +361,13 @@ impl From for Error { } } -#[cfg(feature = "tcp")] impl From for Error { fn from(err: crate::tcp::Error) -> Self { Self::Tcp(Arc::new(err)) } } -#[cfg(all(feature = "uds", unix))] +#[cfg(unix)] impl From for Error { fn from(err: crate::unix::Error) -> Self { Self::Unix(Arc::new(err)) @@ -411,7 +377,7 @@ impl From for Error { /// Convenience alias for results produced by this crate. pub type Result = std::result::Result; -#[cfg(all(test, feature = "websocket"))] +#[cfg(test)] mod tests { use super::*; diff --git a/rs/moq-tokio/src/lib.rs b/rs/moq-tokio/src/lib.rs index 8ceb8547c62..344af51f460 100644 --- a/rs/moq-tokio/src/lib.rs +++ b/rs/moq-tokio/src/lib.rs @@ -3,78 +3,56 @@ //! Establishes MoQ connections over: //! - WebTransport (HTTP/3) //! - Raw QUIC (with ALPN negotiation) -//! - WebSocket (fallback via [web-transport-ws](https://crates.io/crates/web-transport-ws)) -//! - TCP via the `tcp://` (plaintext) and `tls://` schemes (qmux; requires `tcp` feature) -//! - Unix domain socket via the `unix://` scheme (qmux, peer-credential aware; requires `uds` feature, unix-only) -//! - A qmux session established elsewhere, such as over a WebRTC data channel (requires `qmux` feature) +//! - WebSocket (qmux over WebSocket, the fallback when QUIC is blocked) +//! - TCP via the `tcp://` (plaintext) and `tls://` schemes (qmux) +//! - Unix domain socket via the `unix://` scheme (qmux, peer-credential aware; unix-only) +//! - A qmux session established elsewhere, such as over a WebRTC data channel //! -//! With `net`, `client::Client` connects to relays; transport features enable -//! `server::Server` for accepting connections. The `mdns` feature finds peers on the local network. +//! Every transport is compiled in, and the URL scheme or config picks one at runtime. +//! [`client::Client`] connects to relays, [`server::Server`] accepts connections, and +//! [`mdns`] finds peers on the local network. [`quic::driver`] is an async QUIC stack +//! for any application, MoQ or not. //! //! Cryptography always comes from rind. TLS setup checks CPU support and returns -//! an error naming a missing feature. Older x86_64 CPUs and aarch64 boards without +//! an error naming a missing CPU feature. Older x86_64 CPUs and aarch64 boards without //! crypto extensions use rind's software paths; aarch64 requires NEON. Armv7 is supported. -//! -//! MoQ sessions need the `net` feature, which every transport turns on. Without -//! it, `driver` builds [`quic::driver`] alone: an async -//! QUIC stack for any application, MoQ or not. #![warn(missing_docs)] -#[cfg(any(feature = "net", all(feature = "watch", feature = "_certs")))] mod abort; pub mod accept; pub use moq_sock::bind; pub mod cli; -#[cfg(feature = "net")] pub mod client; -#[cfg(feature = "net")] pub mod connect; -#[cfg(feature = "net")] pub mod connection; pub mod crypto; mod error; -#[cfg(any(feature = "quic", feature = "tcp", feature = "websocket"))] pub mod failover; #[cfg(feature = "jemalloc")] pub mod jemalloc; -#[cfg(feature = "net")] pub mod listen; mod log; -#[cfg(feature = "net")] +pub mod mdns; pub mod origin; pub mod panic; pub mod quic; -#[cfg(any(feature = "quic", feature = "tcp", feature = "websocket"))] mod resolve; -#[cfg(any( - feature = "net", - feature = "driver", - feature = "jemalloc", - feature = "mdns", - all(feature = "watch", feature = "_certs") -))] mod runtime; pub mod secret; -#[cfg(feature = "_transport")] pub mod server; -#[cfg(all(feature = "sim", feature = "net"))] +#[cfg(feature = "sim")] pub mod sim; -#[cfg(feature = "tcp")] pub mod tcp; pub mod tls; -#[cfg(feature = "net")] pub mod transport; -#[cfg(all(feature = "uds", unix))] +#[cfg(unix)] pub mod unix; pub mod worker; // Resolving a `host:port` bind string is a QUIC-listener concern; the stream // listeners take a `SocketAddr`/path straight from their config. -#[cfg(feature = "quic")] mod util; -#[cfg(feature = "watch")] pub mod watch; -#[cfg(feature = "websocket")] pub mod websocket; /// Session settings for every qmux transport moq-tokio establishes (WebSocket, `tcp://`, `tls://`, `unix://`), @@ -83,7 +61,6 @@ pub mod websocket; /// A qmux session leases receive credit as QUIC does, so it takes the same per-session /// numbers rather than qmux's own defaults. moq-lite holds a stream open per subscription, /// past qmux's default of 100, where a peer's opens would wait on credit forever. -#[cfg(any(feature = "websocket", feature = "tcp"))] fn qmux_config(quic: &quic::Resolved) -> qmux::Config { let mut config = qmux::Config::default(); config.limits = quic.limits(); @@ -92,13 +69,11 @@ fn qmux_config(quic: &quic::Resolved) -> qmux::Config { /// [`qmux_config`] at the `[quic]` defaults, for a server's qmux sessions, which widen once /// admitted (see [`server::Request::with_quic_limits`]). -#[cfg(any(feature = "websocket", feature = "tcp"))] fn qmux_default() -> qmux::Config { qmux_config(&quic::Resolved::default()) } /// Run a qmux session's driver on the runtime, handing back the session. -#[cfg(any(feature = "websocket", feature = "tcp"))] fn spawn_qmux( (session, driver): (qmux::Session, qmux::Driver), ) -> qmux::Session { @@ -108,22 +83,14 @@ fn spawn_qmux( // Enumerated rather than globbed, so the root surface is a deliberate list and a // new `pub` item in these modules doesn't silently join it. -#[cfg(feature = "net")] pub use client::Client; -#[cfg(feature = "net")] pub use connect::{Addrs, ConnectError}; -#[cfg(feature = "net")] pub use connection::{Backoff, Connection, Redirect, Restart, Status}; pub use error::{Error, Result}; pub use log::{Log, RedactedUrl}; -#[cfg(feature = "_transport")] pub use server::{Listener, Server}; -#[cfg(feature = "net")] pub use transport::Transport; -#[cfg(feature = "mdns")] -pub mod mdns; - /// Whether this build can capture qlog traces, which the `qlog` feature gates. /// /// Setting a qlog directory without it is an error at dial time, so a caller offering diff --git a/rs/moq-tokio/src/listen.rs b/rs/moq-tokio/src/listen.rs index 55c135e7c19..11495adff17 100644 --- a/rs/moq-tokio/src/listen.rs +++ b/rs/moq-tokio/src/listen.rs @@ -15,7 +15,6 @@ pub enum Bind { impl Bind { /// The socket address this names, resolving a host now. - #[cfg(feature = "quic")] pub fn resolve(&self) -> std::io::Result { match self { Self::Addr(addr) => Ok(*addr), @@ -101,16 +100,14 @@ pub struct Config { #[usage(skip)] pub(crate) listen: Option, - /// Plaintext qmux TCP listener (`--listen-tcp-bind`, no TLS). Requires the - /// `tcp` feature. - #[cfg(feature = "tcp")] + /// Plaintext qmux TCP listener (`--listen-tcp-bind`, no TLS). #[usage(flatten)] #[serde(default)] pub tcp: crate::tcp::Config, /// Plaintext qmux Unix-socket listener (`--listen-unix-bind`) with an optional - /// peer-credential allowlist. Requires the `uds` feature; unix-only. - #[cfg(all(feature = "uds", unix))] + /// peer-credential allowlist. Unix-only. + #[cfg(unix)] #[usage(flatten)] #[serde(default)] pub unix: crate::unix::Config, @@ -291,7 +288,6 @@ pub struct Resolved { /// /// Crate-private on purpose: [`crate::worker::Workers`] is the only thing that /// forms a group here, and callers do not need its raw serving handles. -#[cfg(feature = "_transport")] pub(crate) use moq_sock::shard::Socket; /// The `--server-*` flags from before the accept side was named `listen`. @@ -421,20 +417,17 @@ impl Config { found.toml("[server.quic]", "[quic]", Some("now applies to both directions")); } found.extend(self.tls.deprecated()); - #[cfg(feature = "tcp")] found.extend(self.tcp.deprecated()); - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] found.extend(self.unix.deprecated()); found } - #[cfg(feature = "_transport")] pub(crate) fn validate(&self) -> crate::Result<()> { - #[cfg(feature = "tcp")] if self.tcp.tls == Some(true) && self.tcp.bind.is_none() { return Err(crate::Error::NoBackend("--listen-tcp-tls requires --listen-tcp-bind")); } - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] if !self.unix.allow.is_empty() && self.unix.bind.is_none() { return Err(crate::Error::NoBackend( "--listen-unix-allow-* requires --listen-unix-bind", @@ -477,16 +470,9 @@ impl Config { } /// Refuse what only the QUIC listener reads, for a server that has none. - #[cfg(feature = "_transport")] pub(crate) fn validate_stream_only(&self) -> crate::Result<()> { - #[cfg(feature = "tcp")] let tcp_tls = self.tcp.tls == Some(true); - #[cfg(not(feature = "tcp"))] - let tcp_tls = false; - #[cfg(feature = "_certs")] let identity = self.tls.identity.is_some(); - #[cfg(not(feature = "_certs"))] - let identity = false; let refused = [ ( @@ -541,7 +527,6 @@ impl Config { /// does. Destructures every field, so a new one fails to compile here until it is /// either carried into [`Resolved`] or named as something a QUIC listener never /// reads. - #[cfg(feature = "_transport")] pub fn resolve(&self) -> crate::Result { let deprecated = self.deprecated(); if !deprecated.is_empty() { @@ -561,9 +546,8 @@ impl Config { lb, reset: Reset { secret: reset_secret }, // Served by `Server` on the caller's runtime, never by a QUIC listener. - #[cfg(feature = "tcp")] - tcp: _, - #[cfg(all(feature = "uds", unix))] + tcp: _, + #[cfg(unix)] unix: _, // Refused above as deprecated. listen: _, @@ -585,7 +569,6 @@ impl Config { }) } - #[cfg(feature = "quic")] /// Return the effective QUIC-LB connection-ID encoding. pub(crate) fn load_balancer(&self) -> Option { let forward = &self.lb.forward; @@ -730,7 +713,6 @@ mod tests { assert!("relay.example.com:443:8443".parse::().is_err()); } - #[cfg(feature = "quic")] #[test] fn cli_load_balancer_survives_the_merge_round_trip() { let config = config_from(["test", "--listen-quic-lb-id", "ab", "--listen-quic-lb-nonce", "9"]); @@ -767,7 +749,6 @@ mod tests { } /// Programmatic configuration keeps the QUIC-LB id and nonce paired. - #[cfg(feature = "quic")] #[test] fn load_balancer_is_a_single_typed_value() { assert_eq!(Config::default().load_balancer(), None); @@ -845,7 +826,6 @@ peers = "peers.toml" /// A stream-only server refuses each setting only QUIC reads rather than /// ignoring it, and accepts them once QUIC lives elsewhere. - #[cfg(feature = "tcp")] #[tokio::test] async fn stream_only_refuses_quic_settings() { let stream_only = || Config { @@ -888,7 +868,7 @@ peers = "peers.toml" } /// A Unix allowlist without the Unix listener it gates is refused. - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] #[test] fn unix_allow_requires_unix_bind() { let mut config = Config::default(); @@ -1038,7 +1018,6 @@ pub struct Forward { impl Forward { /// Whether any forwarding setting is present. - #[cfg(feature = "_transport")] pub(crate) fn configured(&self) -> bool { self.bind.is_some() || self.key.is_some() || self.peers.is_some() } diff --git a/rs/moq-tokio/src/quic.rs b/rs/moq-tokio/src/quic.rs index 9ca9eefd766..18b1cf647cb 100644 --- a/rs/moq-tokio/src/quic.rs +++ b/rs/moq-tokio/src/quic.rs @@ -3,7 +3,7 @@ //! One [`Config`] (`--quic-*`) carries the per-connection knobs (stream limits, //! GSO, timeouts) that each backend applies. They mean the same thing whichever //! way a connection was opened, so it is spelled once and shared by -//! the MoQ `connect` and `listen` helpers (`net` feature) rather than owned by either. +//! the MoQ `connect` and `listen` helpers rather than owned by either. //! //! The knobs that only apply when accepting (the QUIC preferred address and the //! QUIC-LB connection-ID encoding) live on `listen::Config` instead. @@ -14,19 +14,13 @@ use std::time::Duration; use crate::cli::Duration as CliDuration; -#[cfg(feature = "quic")] mod backend; -#[cfg(feature = "quic")] pub use backend::Error; -#[cfg(feature = "quic")] pub(crate) use backend::{Client, Closer, Options, Server, accept}; -#[cfg(feature = "quic")] pub mod demux; -#[cfg(feature = "driver")] pub mod driver; /// WebTransport over the moq-quic [`driver`], usable without a MoQ session. -#[cfg(feature = "quic")] pub mod web; /// The routable server ID a QUIC-LB load balancer encodes into connection IDs. @@ -38,7 +32,6 @@ pub mod web; pub struct ServerId(#[serde_as(as = "serde_with::hex::Hex")] pub(crate) Vec); impl ServerId { - #[allow(dead_code, reason = "only the QUIC backend reads it")] pub(crate) fn len(&self) -> usize { self.0.len() } @@ -59,7 +52,6 @@ impl std::str::FromStr for ServerId { } /// Resolved QUIC-LB connection-ID encoding. -#[cfg(feature = "quic")] #[derive(Clone, Debug, Eq, PartialEq)] pub(crate) struct LoadBalancer { /// The routable server identifier encoded into each connection ID. @@ -71,7 +63,6 @@ pub(crate) struct LoadBalancer { } /// Resolved QUIC-LB forwarding, every setting present. -#[cfg(feature = "quic")] #[derive(Clone, Debug, Eq, PartialEq)] pub(crate) struct Forward { /// The forward socket's address. @@ -85,11 +76,9 @@ pub(crate) struct Forward { /// A congestion controller of the application's own, built fresh for each connection. /// /// Implement [`moq_congestion::Factory`] and install it with [`Config::controller`]. -#[cfg(feature = "driver")] #[derive(Clone)] pub struct Controller(pub std::sync::Arc); -#[cfg(feature = "driver")] impl std::fmt::Debug for Controller { /// Opaque: a factory carries no description of its own. fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { @@ -137,7 +126,6 @@ pub const DEFAULT_MAX_STREAMS: u64 = 10_000; /// 100 ms RTT, room for any one viewer or publisher, and lets a session pause two group /// streams for slow readers (half the window, a stream window each). pub const DEFAULT_RECEIVE_WINDOW: u64 = 4 << 20; -#[cfg(feature = "_transport")] const _: () = assert!(DEFAULT_RECEIVE_WINDOW >= moq_net::transport::MIN_RECEIVE_WINDOW); /// Default per-stream receive window, used when [`Config::stream_receive_window`] is unset. @@ -254,7 +242,6 @@ pub struct Config { /// /// Code-only, since a controller has no text form: no flag or setting reaches it. /// Both the QUIC backend and the relay's io_uring runtime run it. - #[cfg(feature = "driver")] #[serde(skip)] #[usage(skip)] pub controller: Option, @@ -561,7 +548,6 @@ impl Config { /// Reject knobs this build can't honor, including limits QUIC cannot /// advertise. Called when the endpoint is built. - #[cfg(feature = "_transport")] pub fn validate(&self) -> crate::Result<()> { if self.keylog.as_ref().is_some_and(|path| path.as_os_str().is_empty()) { return Err(crate::Error::KeylogUnset); @@ -576,7 +562,6 @@ impl Config { } /// Reject limits QUIC cannot advertise, through moq-quic's own checks. - #[cfg(feature = "_transport")] fn validate_limits(&self) -> crate::Result<()> { use moq_quic::{ConfigError, LimitsError}; @@ -643,7 +628,6 @@ impl Config { keep_alive, mtu_discovery: self.mtu_discovery.unwrap_or(false), congestion_control: self.congestion_control, - #[cfg(feature = "driver")] controller: self.controller.clone(), receive_window: self.receive_window.unwrap_or(DEFAULT_RECEIVE_WINDOW), stream_receive_window: self.stream_receive_window.unwrap_or(DEFAULT_STREAM_RECEIVE_WINDOW), @@ -688,7 +672,6 @@ pub struct Resolved { /// Congestion control override, or `None` for the default. pub congestion_control: Option, /// The application's own congestion controller, in place of the family. - #[cfg(feature = "driver")] pub controller: Option, /// Connection-wide receive window in bytes, defaulting to [`DEFAULT_RECEIVE_WINDOW`]. /// @@ -712,7 +695,6 @@ impl Resolved { /// Delay-based unless the operator says otherwise: BBR keeps queues short and the /// send rate steady enough for a live encoder to track, which is what this stack /// carries. - #[cfg_attr(not(feature = "quic"), allow(dead_code, reason = "only the QUIC backend uses it"))] pub(crate) fn congestion(&self) -> CongestionControl { self.congestion_control.unwrap_or(CongestionControl::Delay) } @@ -721,20 +703,17 @@ impl Resolved { /// /// Only meaningful once [`Config::validate`] has passed; a build without the /// `qlog` feature never gets here with a directory set. - #[cfg_attr(not(feature = "quic"), allow(dead_code, reason = "only the `quic` feature uses it"))] pub(crate) fn qlog_dir(&self) -> Option<&std::path::Path> { self.qlog.as_deref() } /// The keep-alive interval against a peer whose idle timeout is no shorter than /// ours, using moq-quic's 30s default (a 9s interval) when neither peer sets one. - #[cfg(feature = "_transport")] pub fn keep_alive_interval(&self) -> Duration { moq_quic::transport::keep_alive_interval(self.keep_alive, self.idle_timeout) } /// The flow-control limits as moq-quic and qmux spell them. - #[cfg(feature = "_transport")] pub fn limits(&self) -> moq_quic::Limits { use std::num::NonZeroU64; @@ -753,15 +732,12 @@ mod tests { /// 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); /// The largest value a QUIC varint can carry. - #[cfg(feature = "_transport")] const MAX_VARINT: u64 = (1 << 62) - 1; /// The largest stream limit QUIC can advertise, 2^60. - #[cfg(feature = "_transport")] const MAX_STREAMS: u64 = 1 << 60; /// A minimal parser so we can exercise the `--quic-*` args (and the legacy /// role-prefixed spellings) in isolation. @@ -793,7 +769,6 @@ mod tests { assert!(quic.keylog.is_none()); } - #[cfg(feature = "_transport")] #[test] fn keep_alive_interval_derives_from_the_idle_timeout() { let interval = |idle: u64, keep_alive: Option| { @@ -925,7 +900,6 @@ 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(); @@ -945,7 +919,6 @@ 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 { @@ -989,7 +962,6 @@ 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 [ @@ -1022,7 +994,6 @@ mod tests { /// Incomplete messages hold connection credit, so a connection window that can't fit /// the largest one could stall it forever, so `[quic]` refuses it. - #[cfg(feature = "_transport")] #[test] fn the_receive_window_fits_the_largest_message() { let min = moq_net::transport::MIN_RECEIVE_WINDOW; @@ -1039,7 +1010,6 @@ 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 { @@ -1071,7 +1041,6 @@ mod tests { /// A MAX_STREAMS past 2^60 is a frame encoding error at the peer, and zero lets /// the peer open nothing, so `[quic]` refuses both. - #[cfg(feature = "_transport")] #[test] fn stream_limits_must_fit_a_stream_id() { for max_streams in [0, MAX_STREAMS + 1] { diff --git a/rs/moq-tokio/src/quic/backend.rs b/rs/moq-tokio/src/quic/backend.rs index 88a23c159d5..b10f2988ddd 100644 --- a/rs/moq-tokio/src/quic/backend.rs +++ b/rs/moq-tokio/src/quic/backend.rs @@ -1342,7 +1342,6 @@ mod tests { "client controller cannot probe" ); // BBRv3 can probe, so moq-net gets a target to write. - #[cfg(feature = "net")] assert!( session.connection().probe().is_some(), "BBRv3 connection has no probe target" diff --git a/rs/moq-tokio/src/quic/driver/connection.rs b/rs/moq-tokio/src/quic/driver/connection.rs index e51b23d65d6..3041366efc9 100644 --- a/rs/moq-tokio/src/quic/driver/connection.rs +++ b/rs/moq-tokio/src/quic/driver/connection.rs @@ -53,7 +53,6 @@ impl Connecting { runtime: &crate::runtime::Spawner, ) -> Self { let shared = Shared { - #[cfg(feature = "net")] probe: conn.congestion_state().probes().then(moq_net::transport::Probe::new), ..Shared::default() }; @@ -183,7 +182,6 @@ impl Future for ConnectionDriver { } // A new target waits for the next poll: probing only resends data in flight, so it has // nothing to send until a write or an ACK polls anyway. - #[cfg(feature = "net")] if let Some(probe) = &this.conn.shared.probe { conn.inner.set_probe_target(probe.target().as_bps() / 8); } @@ -199,7 +197,6 @@ impl Future for ConnectionDriver { conn.forward_endpoint_events(); // Every datagram sent or received passes through this poll. - #[cfg(feature = "net")] { let stats = conn.inner.stats(); this.conn.shared.wire.set_sent_bytes(stats.udp_tx.bytes); @@ -489,7 +486,6 @@ impl Connection { } /// The receive windows now in force: the connection's, and the most one stream holds. - #[cfg(feature = "quic")] pub(crate) fn receive_window(&self) -> moq_net::transport::ReceiveWindow { let state = self.0.state.lock(); moq_net::transport::ReceiveWindow::new(Some(state.inner.receive_window()), state.inner.stream_receive_window()) @@ -497,7 +493,6 @@ impl Connection { /// 32 bytes of keying material exported from the TLS session under `label` and `context`, /// or `None` before the handshake completes. - #[cfg(feature = "quic")] pub(crate) fn export_keying_material(&self, label: &[u8], context: &[u8]) -> Option<[u8; 32]> { self.0.state.lock().inner.export_keying_material(label, context) } @@ -516,13 +511,11 @@ impl Connection { } /// The wire counters the driver updates as it sends and receives. - #[cfg(feature = "quic")] pub(crate) fn wire(&self) -> moq_net::transport::Wire { self.0.shared.wire.clone() } /// The target the driver probes up to, or `None` when the congestion controller cannot probe. - #[cfg(feature = "quic")] pub(crate) fn probe(&self) -> Option { self.0.shared.probe.clone() } @@ -647,12 +640,8 @@ pub(crate) struct Shared { /// Number of live handles that can used to initiate or handle I/O; excludes the driver ref_count: AtomicUsize, /// Refreshed by every driver poll, so readers never wake the driver to sample. - /// - /// Only moq-net reads them, so a driver-only build skips the per-poll stats. - #[cfg(feature = "net")] wire: moq_net::transport::Wire, /// The session's probe target, read by every driver poll - #[cfg(feature = "net")] probe: Option, } diff --git a/rs/moq-tokio/src/quic/driver/endpoint.rs b/rs/moq-tokio/src/quic/driver/endpoint.rs index 9f2a8ac7458..9bd5846b0d0 100644 --- a/rs/moq-tokio/src/quic/driver/endpoint.rs +++ b/rs/moq-tokio/src/quic/driver/endpoint.rs @@ -95,10 +95,8 @@ pub struct Endpoint { } /// Observe an endpoint without keeping its socket or driver alive. -#[cfg(feature = "quic")] pub(crate) struct WeakEndpoint(std::sync::Weak); -#[cfg(feature = "quic")] impl WeakEndpoint { pub(crate) fn upgrade(&self) -> Option { let inner = self.0.upgrade()?; @@ -110,7 +108,6 @@ impl WeakEndpoint { } impl Endpoint { - #[cfg(feature = "quic")] pub(crate) fn downgrade(&self) -> WeakEndpoint { WeakEndpoint(Arc::downgrade(&self.inner.0)) } @@ -125,7 +122,6 @@ impl Endpoint { /// [`new`](Self::new), forwarding each packet whose QUIC-LB server ID names another server /// and accepting the packets those servers forward here. - #[cfg_attr(not(feature = "quic"), allow(dead_code, reason = "only the QUIC backend forwards"))] pub(crate) fn forwarding(config: Config, socket: impl Into, forward: Forward) -> Result { Self::start(config, socket.into(), Some(forward)) } @@ -1116,7 +1112,7 @@ struct PollProgress { keep_going: bool, } -#[cfg(all(test, any(unix, windows), feature = "_certs"))] +#[cfg(all(test, any(unix, windows)))] mod tests { use std::net::UdpSocket; diff --git a/rs/moq-tokio/src/quic/driver/forward.rs b/rs/moq-tokio/src/quic/driver/forward.rs index e18962d4645..eca0be259c0 100644 --- a/rs/moq-tokio/src/quic/driver/forward.rs +++ b/rs/moq-tokio/src/quic/driver/forward.rs @@ -8,7 +8,6 @@ //! //! Long headers are never forwarded: a client picks the destination ID of its handshake, so the //! handshake relies on the front end keeping a flow on one server. -#![cfg_attr(not(feature = "quic"), allow(dead_code, reason = "only the QUIC backend forwards"))] use std::{ collections::{HashMap, HashSet}, diff --git a/rs/moq-tokio/src/quic/driver/incoming.rs b/rs/moq-tokio/src/quic/driver/incoming.rs index f1a143fd8b1..4c0d169d9bb 100644 --- a/rs/moq-tokio/src/quic/driver/incoming.rs +++ b/rs/moq-tokio/src/quic/driver/incoming.rs @@ -21,7 +21,6 @@ impl Incoming { } /// Reject this incoming connection attempt - #[cfg(any(test, feature = "quic"))] pub(crate) fn refuse(mut self) { let state = self.0.take().unwrap(); state.endpoint.refuse(state.inner); diff --git a/rs/moq-tokio/src/quic/driver/mod.rs b/rs/moq-tokio/src/quic/driver/mod.rs index 1ae87088d29..49e8cc25f78 100644 --- a/rs/moq-tokio/src/quic/driver/mod.rs +++ b/rs/moq-tokio/src/quic/driver/mod.rs @@ -5,8 +5,7 @@ //! keep a prefix reliable, [`recv::Stream::poll_lease`] to hold receive credit until a message is //! complete, and [`connection::Connection::set_limits`] to change flow control on a live connection. //! -//! It needs no MoQ session: enable the `driver` feature and -//! `default-features = false` to build it without moq-net. The entry point is the +//! It needs no MoQ session. The entry point is the //! [`endpoint::Endpoint`], built from an [`endpoint::Config`] and a UDP socket it owns; //! [`endpoint::Endpoint::connect`] dials with a [`client::Config`]. //! @@ -67,7 +66,6 @@ pub(crate) use std::time::Duration; pub use moq_quic::{ConfigError, Limits, LimitsError, Rate, VarInt, client, crypto, server, stream, transport}; pub(crate) use moq_quic::{EcnCodepoint, Transmit}; -#[cfg(feature = "quic")] pub(crate) use crate::quic::driver::runtime::{Slot, wrap_udp_socket}; #[cfg(test)] diff --git a/rs/moq-tokio/src/quic/driver/recv.rs b/rs/moq-tokio/src/quic/driver/recv.rs index aa722aa69fa..df4fcfabbcb 100644 --- a/rs/moq-tokio/src/quic/driver/recv.rs +++ b/rs/moq-tokio/src/quic/driver/recv.rs @@ -89,7 +89,6 @@ impl Stream { } /// Poll a read without retaining the destination buffer. - #[cfg(feature = "quic")] pub(crate) fn poll_read_buf( &mut self, waiter: &kio::Waiter, @@ -202,7 +201,6 @@ impl Stream { } /// Stop with `code`, instead of code 0, if dropped before the end - #[cfg(feature = "quic")] pub(crate) fn set_drop_stop(&mut self, code: VarInt) { self.reader.drop_stop = code; } @@ -222,12 +220,10 @@ impl Stream { /// Poll form of [`Self::received_reset`]. It takes no bytes, so a lease in progress is /// left as it was. - #[cfg(feature = "quic")] pub(crate) fn poll_received_reset(&mut self, waiter: &kio::Waiter) -> Poll, Error>> { self.reader.poll_received_reset(waiter) } /// Observe FIN without consuming application bytes, including an empty stream's end. - #[cfg(feature = "quic")] pub(crate) fn poll_closed(&mut self, waiter: &kio::Waiter) -> Poll, Error>> { // A read that met the reset marks every byte read, so only the cached code still says how it ended. if let Some(code) = self.reader.reset { diff --git a/rs/moq-tokio/src/quic/driver/runtime/mod.rs b/rs/moq-tokio/src/quic/driver/runtime/mod.rs index 767c5c42880..5c8dfda55b8 100644 --- a/rs/moq-tokio/src/quic/driver/runtime/mod.rs +++ b/rs/moq-tokio/src/quic/driver/runtime/mod.rs @@ -137,7 +137,6 @@ impl Slot { } /// Whether [`Self::release`] closed the socket - #[cfg(feature = "quic")] pub(crate) fn is_released(&self) -> bool { self.socket.read().unwrap().is_none() } diff --git a/rs/moq-tokio/src/quic/driver/send.rs b/rs/moq-tokio/src/quic/driver/send.rs index aaccdbd8eab..24d23f63383 100644 --- a/rs/moq-tokio/src/quic/driver/send.rs +++ b/rs/moq-tokio/src/quic/driver/send.rs @@ -108,7 +108,6 @@ impl Stream { } /// Poll a write without retaining or copying the caller's buffer. - #[cfg(feature = "quic")] pub(crate) fn poll_write_buf(&mut self, waiter: &kio::Waiter, buf: &mut impl Buf) -> Poll> { self.half.poll_write(waiter, buf) } @@ -171,7 +170,6 @@ impl Stream { } /// Reset at `offset` with `code`, instead of at 0 with code 0, if dropped before `finish` - #[cfg(feature = "quic")] pub(crate) fn set_drop_reset(&mut self, offset: Option, code: VarInt) { if let Some(offset) = &offset { self.half.own(offset); @@ -196,20 +194,17 @@ impl Stream { } /// Whether the peer acknowledged every byte written so far - #[cfg(feature = "quic")] pub(crate) fn acknowledged(&self) -> bool { self.half.acknowledged() } /// How many leading bytes the peer acknowledged - #[cfg(feature = "quic")] pub(crate) fn acked_len(&self) -> u64 { self.half.acked_len() } /// Wait for the peer to acknowledge every byte written so far; pending forever once it /// never will - #[cfg(feature = "quic")] pub(crate) fn poll_all_acked(&self, waiter: &kio::Waiter) -> Poll<()> { self.half.poll_all_acked(waiter) } @@ -267,19 +262,16 @@ impl Finished { } /// Whether the peer acknowledged every byte written. See [`Stream::acknowledged()`]. - #[cfg(feature = "quic")] pub(crate) fn acknowledged(&self) -> bool { self.half.acknowledged() } /// How many leading bytes the peer acknowledged. See [`Stream::acked_len()`]. - #[cfg(feature = "quic")] pub(crate) fn acked_len(&self) -> u64 { self.half.acked_len() } /// Wait for every byte to be acknowledged. See [`Stream::poll_all_acked()`]. - #[cfg(feature = "quic")] pub(crate) fn poll_all_acked(&self, waiter: &kio::Waiter) -> Poll<()> { self.half.poll_all_acked(waiter) } @@ -395,7 +387,6 @@ impl Half { } /// Whether the peer acknowledged every byte written so far; never once reset or stopped. - #[cfg(feature = "quic")] fn acknowledged(&self) -> bool { let mut conn = self.stream.conn.state.lock(); let mut stream = conn.inner.send_stream(self.stream.id); @@ -404,7 +395,6 @@ impl Half { } /// How many leading bytes the peer acknowledged, each counted once. - #[cfg(feature = "quic")] fn acked_len(&self) -> u64 { let mut conn = self.stream.conn.state.lock(); conn.inner.send_stream(self.stream.id).acked_len() @@ -412,7 +402,6 @@ impl Half { /// Wait for the peer to acknowledge every byte written so far; pending forever once it /// never will, as after a reset or `STOP_SENDING`. - #[cfg(feature = "quic")] fn poll_all_acked(&self, waiter: &kio::Waiter) -> Poll<()> { let mut conn = self.stream.conn.state.lock(); let mut stream = conn.inner.send_stream(self.stream.id); diff --git a/rs/moq-tokio/src/quic/driver/tests.rs b/rs/moq-tokio/src/quic/driver/tests.rs index 6628712a9dc..85b00caf0a1 100755 --- a/rs/moq-tokio/src/quic/driver/tests.rs +++ b/rs/moq-tokio/src/quic/driver/tests.rs @@ -1,5 +1,3 @@ -#![cfg(feature = "_certs")] - use rind_rustls::default_provider; use std::{ diff --git a/rs/moq-tokio/src/quic/web/session.rs b/rs/moq-tokio/src/quic/web/session.rs index 2d85be34499..405c13ee837 100644 --- a/rs/moq-tokio/src/quic/web/session.rs +++ b/rs/moq-tokio/src/quic/web/session.rs @@ -1034,7 +1034,7 @@ fn webtransport_exporter_context(id: u64, label: &[u8], context: &[u8]) -> Optio Some(exporter) } -#[cfg(all(test, feature = "_certs"))] +#[cfg(test)] mod tests { use std::{ io::{self, IoSliceMut}, diff --git a/rs/moq-tokio/src/resolve.rs b/rs/moq-tokio/src/resolve.rs index 5fd76d8ce91..0d265caefa7 100644 --- a/rs/moq-tokio/src/resolve.rs +++ b/rs/moq-tokio/src/resolve.rs @@ -289,7 +289,6 @@ impl Candidates { /// are handed out anyway so the dial surfaces the OS error instead of a /// confusing "no DNS entries". See /// for the Windows failure this family matching originally fixed. - #[cfg(any(feature = "quic", test))] pub(crate) fn with_local(mut self, local: SocketAddr, dual_stack: bool) -> Self { self.local = Some((local, dual_stack)); self diff --git a/rs/moq-tokio/src/runtime.rs b/rs/moq-tokio/src/runtime.rs index 6005190242b..14fce772457 100644 --- a/rs/moq-tokio/src/runtime.rs +++ b/rs/moq-tokio/src/runtime.rs @@ -16,7 +16,6 @@ pub(crate) fn enter() -> Option> { } /// Where detached tasks run, captured once so tasks spawned later land beside the first. -#[cfg(any(feature = "driver", feature = "net"))] #[derive(Debug, Clone)] pub(crate) enum Spawner { /// The caller's tokio runtime, else the fallback. @@ -26,7 +25,6 @@ pub(crate) enum Spawner { Sim, } -#[cfg(any(feature = "driver", feature = "net"))] impl Spawner { /// The `kio::clock` simulator when called inside one, else the caller's runtime or the fallback. pub(crate) fn current() -> Self { @@ -52,7 +50,6 @@ impl Spawner { } /// Run `future` in the background with nobody to join it, where [`Spawner::current`] picks. -#[cfg(feature = "quic")] pub(crate) fn detach(future: F) where F: Future + Send + 'static, @@ -73,7 +70,6 @@ fn fallback() -> &'static tokio::runtime::Runtime { } /// Run `future` with [`enter`] held for each poll, since a poll may spawn or make timers. -#[cfg(any(feature = "net", feature = "jemalloc", feature = "mdns"))] pub(crate) async fn scope(future: F) -> F::Output { let mut future = std::pin::pin!(future); std::future::poll_fn(|cx| { @@ -84,7 +80,6 @@ pub(crate) async fn scope(future: F) -> F::Output { } /// Spawn `future` on the caller's runtime, else the fallback. -#[cfg(any(feature = "net", all(feature = "watch", feature = "_certs")))] pub(crate) fn spawn(future: F) -> tokio::task::JoinHandle where F: Future + Send + 'static, diff --git a/rs/moq-tokio/src/server.rs b/rs/moq-tokio/src/server.rs index 7544f476001..3c4e014e176 100644 --- a/rs/moq-tokio/src/server.rs +++ b/rs/moq-tokio/src/server.rs @@ -5,7 +5,7 @@ //! side is [`crate::client`]. use std::net; -#[cfg(any(test, all(feature = "uds", unix)))] +#[cfg(any(test, unix))] use std::path::PathBuf; use crate::{Error, Transport}; @@ -14,11 +14,8 @@ use url::Url; // Only the transports that finish their handshake in a spawned future need `.boxed()`; // the stream listeners hand back an already-built `Request`. -#[cfg(any(feature = "quic", feature = "websocket"))] use futures::FutureExt; -// The pending handshakes of the transports `Server` accepts itself; a session -// handed to `accept_with` is established by the caller, so a `qmux`-only build has none. -#[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", all(feature = "uds", unix)))] +// The pending handshakes of the transports `Server` accepts itself. use futures::{ future::BoxFuture, stream::{FuturesUnordered, StreamExt}, @@ -91,23 +88,16 @@ impl crate::listen::Config { /// /// When true and [`bind`](Self::bind) is unset, the server runs stream-only /// (no default QUIC listener). - #[allow(unused_mut, reason = "only the stream listener features set it")] fn has_stream_listener(&self) -> bool { - let mut has = false; - #[cfg(feature = "tcp")] - { - has |= self.tcp.bind.is_some(); + #[cfg(unix)] + if self.unix.bind.is_some() { + return true; } - #[cfg(all(feature = "uds", unix))] - { - has |= self.unix.bind.is_some(); - } - has + self.tcp.bind.is_some() } } /// Default bind address used when [`crate::listen::Config::bind`] is not set. -#[cfg(feature = "quic")] pub const DEFAULT_BIND: net::SocketAddr = net::SocketAddr::V6(net::SocketAddrV6::new(net::Ipv6Addr::UNSPECIFIED, 443, 0, 0)); @@ -130,7 +120,6 @@ 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(feature = "quic"), expect(dead_code, reason = "no QUIC backend is compiled in"))] Member(crate::listen::Socket), } @@ -141,17 +130,12 @@ impl Parts { } /// Whether the `tcp`/`unix` listeners should be opened. - #[cfg_attr( - not(any(feature = "tcp", all(feature = "uds", unix))), - expect(dead_code, reason = "no stream listener is compiled in") - )] fn streams(&self) -> bool { matches!(self, Self::All | Self::Streams) } /// This server's socket in a complete group, when it is a member of one. /// Consuming, because only one backend may own the serving handle. - #[cfg_attr(not(feature = "quic"), expect(dead_code, reason = "no QUIC backend is compiled in"))] fn member(self) -> Option { match self { Self::Member(member) => Some(member), @@ -173,7 +157,6 @@ impl Parts { #[non_exhaustive] pub struct Config { /// Shared served identity; `listen.tls` must be empty when this is set. - #[cfg(feature = "_certs")] pub tls: Option, /// Tracks accepted transports through their handshake and session lifetime. @@ -185,7 +168,6 @@ pub struct Config { pub quic: crate::quic::Config, /// A standalone WebSocket listener on a separate TCP port. - #[cfg(feature = "websocket")] pub websocket: Option, /// The origin published to every accepted session. @@ -199,17 +181,15 @@ pub struct Config { /// What the QUIC socket diverts from the shared port and drops; keep a clone to /// take its [`webrtc`](crate::quic::demux::Demux::webrtc) feed or read its counters. - #[cfg(feature = "quic")] pub demux: crate::quic::demux::Demux, /// Stream listeners the caller already holds, served in place of binding the /// configured addresses. - #[cfg(any(feature = "tcp", all(feature = "uds", unix)))] pub streams: Streams, /// The simulated host the QUIC endpoint binds on, at the configured bind port, in place of /// a UDP socket. For tests on `kio::clock::sim`; see [`crate::quic::driver::sim`]. - #[cfg(all(feature = "sim", feature = "quic"))] + #[cfg(feature = "sim")] pub sim: Option, } @@ -221,15 +201,13 @@ pub struct Config { /// `listen.unix.bind`), which says how to serve it; the socket replaces only the /// bind. A Unix socket's path belongs to whoever bound it, so a listener served /// from one never unlinks it. -#[cfg(any(feature = "tcp", all(feature = "uds", unix)))] #[derive(Debug, Default)] #[non_exhaustive] pub struct Streams { /// Served for `listen.tcp.bind`. Must be listening. - #[cfg(feature = "tcp")] pub tcp: Option, /// Served for `listen.unix.bind`. Must be listening. - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] pub unix: Option, } @@ -245,21 +223,17 @@ impl Config { } /// Copy the settings one QUIC worker owns. - #[cfg(feature = "quic")] pub(crate) fn worker(&self) -> Self { Self { listen: self.listen.clone(), - #[cfg(feature = "_certs")] tls: self.tls.clone(), quic: self.quic.clone(), - #[cfg(feature = "websocket")] websocket: None, publisher: self.publisher.clone(), subscriber: self.subscriber.clone(), stats: self.stats.clone(), admission: self.admission.clone(), demux: self.demux.clone(), - #[cfg(any(feature = "tcp", all(feature = "uds", unix)))] streams: Streams::default(), #[cfg(feature = "sim")] sim: self.sim.clone(), @@ -275,21 +249,15 @@ impl Config { pub struct Server { admission: moq_net::server::Admission, moq: moq_net::Server, - #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", all(feature = "uds", unix)))] versions: moq_net::Versions, - #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", all(feature = "uds", unix)))] /// Pending handshakes, each isolated: one panicking (`None`) must not end the listener. /// Each is boxed before `isolate` wraps it, so a debug build never holds a /// handshake's large state twice on the accept loop's stack. accept: FuturesUnordered>>>, - #[cfg(any(feature = "tcp", all(feature = "uds", unix)))] streams: StreamListeners, /// The `tls://` config another listener can serve, when a listen identity is loaded. - #[cfg(all(feature = "tcp", feature = "_certs"))] tls_stream: Option, - #[cfg(feature = "quic")] quic: Option, - #[cfg(feature = "websocket")] websocket: Option, } @@ -308,18 +276,14 @@ impl Server { admission, listen: config, quic, - #[cfg(feature = "_certs")] tls, - #[cfg(feature = "websocket")] websocket, publisher, subscriber, stats, - #[cfg(feature = "quic")] demux, - #[cfg(any(feature = "tcp", all(feature = "uds", unix)))] - streams: prebound, - #[cfg(all(feature = "sim", feature = "quic"))] + streams: prebound, + #[cfg(feature = "sim")] sim, } = config; @@ -335,7 +299,6 @@ impl Server { // gets the released spellings folded in too. config.validate()?; - #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", all(feature = "uds", unix)))] let versions = config.versions(); // Build a QUIC backend when `--listen` is set, or when nothing else @@ -346,7 +309,6 @@ impl Server { // a qmux session starts at it already. let window = std::num::NonZeroU64::new(quic.resolve().receive_window); // Every qmux session this server accepts starts at the same `[quic]` windows. - #[cfg(any(feature = "websocket", feature = "tcp", all(feature = "uds", unix)))] let resolved = quic.resolve(); let build_quic = parts.quic() && config.serves_quic(); @@ -356,45 +318,23 @@ impl Server { config.validate_stream_only()?; } // Read before the member is taken out below, which consumes `parts`. - #[cfg(any(feature = "tcp", all(feature = "uds", unix)))] let build_streams = parts.streams(); - // `parts.quic()` and not `build_quic`: a caller that asked for streams only - // is not asking for a backend, while leaving everything else configured is - // still the error it always was. - #[cfg(not(feature = "quic"))] - if config.bind.is_some() && parts.quic() { - return Err(Error::NoBackend("--listen requires the quic feature")); - } - #[cfg(not(feature = "quic"))] - if config.reset.secret.is_some() && parts.quic() { - return Err(Error::NoBackend("--listen-reset-secret requires the quic feature")); - } // The QUIC backend and a `tls://` listener verify client certificates; the // other qmux listeners (plaintext tcp/unix/websocket) never ask for one, so a // server with neither would ignore the CA or pinned peers. A caller opening // only the streams owns QUIC elsewhere. - #[cfg(feature = "tcp")] let tcp_tls = build_streams && config.tcp.bind.is_some() && config.tcp.tls == Some(true); - #[cfg(not(feature = "tcp"))] - let tcp_tls = false; let client_auth = !config.tls.root.is_empty() || config.tls.peers.is_some(); if parts.quic() && !build_quic && !tcp_tls && client_auth { return Err(Error::MtlsUnsupported); } - if parts.quic() && !tcp_tls && !config.tls.root.is_empty() { - #[cfg(not(feature = "quic"))] - return Err(Error::NoBackend("--listen-tls-root requires the quic feature")); - } - #[cfg(feature = "_certs")] let tls = { if tls.is_some() && config.tls.configured() { return Err(crate::tls::Error::ConflictingServe.into()); } - #[allow(unused_mut, reason = "only the stream listener features set it")] - let mut needed = cfg!(feature = "quic") && build_quic; - needed |= tcp_tls; + let needed = build_quic || tcp_tls; match (tls, needed) { // Mirrors `validate_stream_only`: an identity no listener serves is refused. // A streams-only caller owns QUIC elsewhere, which serves it. @@ -408,17 +348,14 @@ impl Server { (None, false) => None, } }; - #[cfg(feature = "_certs")] if parts.quic() && !build_quic && !tcp_tls && tls.as_ref().is_some_and(crate::tls::Serve::client_auth) { return Err(Error::MtlsUnsupported); } // The member is a serving handle released by a complete reuseport group, // so the backend may take it only once. - #[cfg(feature = "quic")] let member = parts.member(); - #[cfg(feature = "quic")] let quic = build_quic .then(|| { crate::quic::Server::new(crate::quic::Options { @@ -434,55 +371,47 @@ impl Server { .transpose()?; // Collect the configured stream listeners (at most one TCP, one Unix). - #[cfg(any(feature = "tcp", all(feature = "uds", unix)))] let mut stream_binds = Vec::new(); - #[cfg(any(feature = "tcp", all(feature = "uds", unix)))] let Streams { - #[cfg(feature = "tcp")] - tcp: mut prebound_tcp, - #[cfg(all(feature = "uds", unix))] + tcp: mut prebound_tcp, + #[cfg(unix)] unix: mut prebound_unix, } = prebound; - #[cfg(feature = "tcp")] if prebound_tcp.is_some() && !(build_streams && config.tcp.bind.is_some()) { return Err(Error::NoBackend("server::Config::streams.tcp needs --listen-tcp-bind")); } - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] if prebound_unix.is_some() && !(build_streams && config.unix.bind.is_some()) { return Err(Error::NoBackend( "server::Config::streams.unix needs --listen-unix-bind", )); } - #[cfg(feature = "tcp")] if let Some(addr) = config.tcp.bind.filter(|_| build_streams) { let tls = match config.tcp.tls == Some(true) { true => Some(TcpTls::new( &config, &versions, - #[cfg(feature = "_certs")] tls.clone().expect("TLS stream needs an identity"), )?), false => None, }; stream_binds.push(StreamBind::Tcp(addr, tls, prebound_tcp.take())); } - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] if let Some(path) = config.unix.bind.clone().filter(|_| build_streams) { stream_binds.push(StreamBind::Unix(path, prebound_unix.take())); } // `None` (or an all-empty allowlist) means the listener enforces nothing. - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] let unix_allow = (!config.unix.allow.is_empty()).then(|| config.unix.allow.clone()); - #[cfg(any(feature = "tcp", all(feature = "uds", unix)))] let streams = StreamListeners::new( stream_binds, stream_versions(&versions), resolved.clone(), - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] unix_allow, ); - #[cfg(all(feature = "tcp", feature = "_certs"))] let tls_stream = tls.map(|tls| TcpTls::new(&config, &versions, tls)).transpose()?; let mut moq = config.server().with_stats(stats); @@ -498,18 +427,12 @@ impl Server { Ok(Server { admission, - #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", all(feature = "uds", unix)))] accept: Default::default(), moq, - #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", all(feature = "uds", unix)))] versions, - #[cfg(any(feature = "tcp", all(feature = "uds", unix)))] streams, - #[cfg(all(feature = "tcp", feature = "_certs"))] tls_stream, - #[cfg(feature = "quic")] quic, - #[cfg(feature = "websocket")] websocket: websocket.map(|websocket| websocket.with_quic(&resolved)), }) } @@ -552,7 +475,6 @@ impl Server { /// /// `None` when this server loaded no listen TLS identity, as a stream-only /// server without `--listen-tcp-tls` does not. - #[cfg(all(feature = "tcp", feature = "_certs"))] pub fn tls_acceptor(&self) -> Option { let tls = self.tls_stream.as_ref()?; let server = self.moq.clone().with_versions(self.streams.versions.clone()); @@ -574,7 +496,6 @@ impl Server { /// /// Empty when no TLS-bearing backend is configured (e.g. a stream-only server). pub fn certificates(&self) -> crate::tls::Certificates { - #[cfg(feature = "quic")] if let Some(quic) = self.quic.as_ref() { return quic.certificates(); } @@ -582,13 +503,6 @@ impl Server { crate::tls::Certificates::empty() } - #[cfg(not(any(feature = "quic", feature = "websocket", feature = "tcp", all(feature = "uds", unix))))] - /// Fails, since no compiled transport is one this server listens on (a session - /// established elsewhere arrives through `Listener::accept_with`). - async fn accept_next(&mut self) -> crate::Result { - Err(Error::NoBackend("no listener to accept from")) - } - /// The accept-loop health of every listener this server owns that performs a real /// `accept(2)`: the `tcp`/`unix` stream listeners and, if one was set, /// [`Config::websocket`]. @@ -601,11 +515,7 @@ impl Server { /// Available before [`listen`](Self::listen), so an owner can register these with /// a metrics endpoint at startup even though the sockets bind there. pub fn accept_health(&self) -> Vec { - #[allow(unused_mut, reason = "only the stream listener features extend it")] - let mut health = Vec::new(); - #[cfg(any(feature = "tcp", all(feature = "uds", unix)))] - health.extend(self.streams.health.iter().cloned()); - #[cfg(feature = "websocket")] + let mut health = self.streams.health.clone(); health.extend(self.websocket.as_ref().map(|ws| ws.accept_health())); health } @@ -623,13 +533,8 @@ impl Server { /// leaves nothing bound: the partially built `Listener` drops here, closing /// whatever it opened. Build a fresh `Server` from the (cloneable) config to try /// again. - #[allow( - unused_mut, - reason = "`mut` is only needed to bind the stream listeners, which a QUIC-only build has none of" - )] pub async fn bind(mut self) -> crate::Result { crate::runtime::scope(async move { - #[cfg(any(feature = "tcp", all(feature = "uds", unix)))] self.streams.bind().await?; Ok(Listener { server: self }) }) @@ -651,90 +556,63 @@ impl Server { /// whatever it opened. Build a fresh `Server` from the (cloneable) config to try /// again. pub async fn listen(self) -> crate::Result { - #[cfg(not(any(feature = "tcp", all(feature = "uds", unix))))] - { - self.bind().await - } - #[cfg(any(feature = "tcp", all(feature = "uds", unix)))] - { - let mut listener = self.bind().await?; - // Accept immediately, so a dial can finish its handshake before the - // caller polls `accept`. `bind` leaves that until the first accept. - let server = listener - .server - .moq - .clone() - .with_versions(listener.server.streams.versions.clone()); - listener.server.streams.serve(&server, &listener.server.admission); - Ok(listener) - } + let mut listener = self.bind().await?; + // Accept immediately, so a dial can finish its handshake before the + // caller polls `accept`. `bind` leaves that until the first accept. + let server = listener + .server + .moq + .clone() + .with_versions(listener.server.streams.versions.clone()); + listener.server.streams.serve(&server, &listener.server.admission); + Ok(listener) } /// The body of [`Listener::accept`]. Stream accept loops start here if /// [`Server::bind`] left them stopped; [`Server::listen`] already started them. - #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", all(feature = "uds", unix)))] async fn accept_next(&mut self) -> crate::Result { // A `bind` (rather than `listen`) leaves the stream loops stopped so an // embedder can read the port before it is willing to take sessions. // Starting them here, on the first accept, is that moment. - #[cfg(any(feature = "tcp", all(feature = "uds", unix)))] - { - let server = self.moq.clone().with_versions(self.streams.versions.clone()); - self.streams.serve(&server, &self.admission); - } + let server = self.moq.clone().with_versions(self.streams.versions.clone()); + self.streams.serve(&server, &self.admission); loop { // The QUIC endpoint address, reported as a QUIC session's local side. - #[cfg(feature = "quic")] let local = self.local_addr().ok(); - #[cfg(feature = "quic")] let quic_tls = self.quic.as_ref().map(|quic| quic.tls.clone()); // tokio::select! does not support cfg directives on arms, so we need to create the futures here. // `Some(None)` once a configured endpoint stops, which only losing its // driver does while we accept. - #[cfg(feature = "quic")] let quic_accept = async { - #[cfg(feature = "quic")] if let Some(quic) = self.quic.as_mut() { return Some(quic.accept().await); } None }; - #[cfg(not(feature = "quic"))] - let quic_accept = async { None::<()> }; - #[cfg(feature = "websocket")] let ws_ref = self.websocket.as_ref(); - #[cfg(feature = "websocket")] let ws_accept = async { match ws_ref { Some(ws) => Some(ws.accept_pending().await), None => None, } }; - #[cfg(not(feature = "websocket"))] - let ws_accept = std::future::ready(None::<()>); - #[allow(unused_variables, reason = "a build without a transport feature never reads it")] let setup = Setup { admission: self.admission.clone(), server: self.moq.clone(), }; - #[allow(unused_variables, reason = "a build without a transport feature never reads it")] let versions = self.versions.clone(); // An absent transport resolves `None` rather than parking, so its arm is // disabled instead of holding the `select!` open. That is what lets `else` // mean "nothing is left that could accept" instead of "the one transport // nobody configured is still notionally pending". - #[cfg(any(feature = "tcp", all(feature = "uds", unix)))] let stream_accept = self.streams.recv(); - #[cfg(not(any(feature = "tcp", all(feature = "uds", unix))))] - let stream_accept = std::future::ready(None::>); tokio::select! { Some(request) = stream_accept => { - #[cfg(any(feature = "tcp", all(feature = "uds", unix)))] match request { Ok(request) => return Ok(request), // The process would keep its other listeners and silently drop @@ -747,60 +625,52 @@ impl Server { return Err(Error::Stopped); } } - #[cfg(not(any(feature = "tcp", all(feature = "uds", unix))))] - let _ = request; } - Some(_conn) = quic_accept => { - #[cfg(feature = "quic")] - { - // The process would keep its other listeners and silently drop - // QUIC, so stop accepting at all and let the owner fail loudly. - let Some(_conn) = _conn else { - self.shutdown().await; - return Err(Error::Accept(Transport::Quic)); - }; - let alpns = versions.alpns(); - let tls = quic_tls.expect("an accepting QUIC endpoint has its TLS"); - let deadline = setup.deadline(); - // Closed for drain: refuse so the peer redials elsewhere at once. - let Some(active) = setup.admission.enter() else { - _conn.refuse(); - continue; - }; - self.accept.push(crate::panic::isolate(async move { - // Accept the transport (capturing url + mTLS identity) and exchange the - // MoQ SETUP up front, so path/role are known before the caller authorizes - // (like the stream bindings). - let Accepted { session, url, identity, authority, mut link } = within(deadline, crate::quic::accept(_conn, alpns, tls)).await?; - link.local = local; - let under = Under::Quic(session.connection().clone()); - // Only WebTransport carries a request URL; raw QUIC puts the path in the SETUP. - let transport = match url { Some(_) => Transport::WebTransport, None => Transport::Quic }; - let incoming = Incoming { transport, url, link, authority, identity, deadline, active }; - Request::accept(&setup.server, session, under, incoming).await - }.boxed()).boxed()); - } + Some(conn) = quic_accept => { + // The process would keep its other listeners and silently drop + // QUIC, so stop accepting at all and let the owner fail loudly. + let Some(conn) = conn else { + self.shutdown().await; + return Err(Error::Accept(Transport::Quic)); + }; + let alpns = versions.alpns(); + let tls = quic_tls.expect("an accepting QUIC endpoint has its TLS"); + let deadline = setup.deadline(); + // Closed for drain: refuse so the peer redials elsewhere at once. + let Some(active) = setup.admission.enter() else { + conn.refuse(); + continue; + }; + self.accept.push(crate::panic::isolate(async move { + // Accept the transport (capturing url + mTLS identity) and exchange the + // MoQ SETUP up front, so path/role are known before the caller authorizes + // (like the stream bindings). + let Accepted { session, url, identity, authority, mut link } = within(deadline, crate::quic::accept(conn, alpns, tls)).await?; + link.local = local; + let under = Under::Quic(session.connection().clone()); + // Only WebTransport carries a request URL; raw QUIC puts the path in the SETUP. + let transport = match url { Some(_) => Transport::WebTransport, None => Transport::Quic }; + let incoming = Incoming { transport, url, link, authority, identity, deadline, active }; + Request::accept(&setup.server, session, under, incoming).await + }.boxed()).boxed()); } - Some(_pending) = ws_accept => { - #[cfg(feature = "websocket")] - { - // Upgrade and read the SETUP before handing the session over, so a slow - // peer doesn't stall the accept loop (spawned like the others). A failed - // `accept(2)` never reaches here, having been classified, counted, and - // warned about by the listener itself. - let local = self.websocket_local_addr(); - let deadline = setup.deadline(); - // Dropping the pending upgrade closes its socket. - let Some(active) = setup.admission.enter() else { - continue; - }; - self.accept.push(crate::panic::isolate(async move { - let (session, url, accepted) = within(deadline, _pending).await?; - let mut options = crate::websocket::Options::new(url, setup.server, active); - options.link = Link { remote: Some(accepted.remote), local, alpn: Some(accepted.protocol), ..Default::default() }; - accept_websocket(session, options, deadline).await - }.boxed()).boxed()); - } + Some(pending) = ws_accept => { + // Upgrade and read the SETUP before handing the session over, so a slow + // peer doesn't stall the accept loop (spawned like the others). A failed + // `accept(2)` never reaches here, having been classified, counted, and + // warned about by the listener itself. + let local = self.websocket_local_addr(); + let deadline = setup.deadline(); + // Dropping the pending upgrade closes its socket. + let Some(active) = setup.admission.enter() else { + continue; + }; + self.accept.push(crate::panic::isolate(async move { + let (session, url, accepted) = within(deadline, pending).await?; + let mut options = crate::websocket::Options::new(url, setup.server, active); + options.link = Link { remote: Some(accepted.remote), local, alpn: Some(accepted.protocol), ..Default::default() }; + accept_websocket(session, options, deadline).await + }.boxed()).boxed()); } Some(res) = self.accept.next() => { match res { @@ -825,7 +695,6 @@ impl Server { /// Errors with [`Error::NoBackend`] on a stream-only server, which has no /// QUIC listener. pub fn local_addr(&self) -> crate::Result { - #[cfg(feature = "quic")] if let Some(quic) = self.quic.as_ref() { return Ok(quic.local_addr()); } @@ -834,35 +703,27 @@ impl Server { } /// Closes the QUIC connections once this server has been handed away. - #[cfg(feature = "quic")] pub(crate) fn quic_closer(&self) -> Option { self.quic.as_ref().map(crate::quic::Server::closer) } /// The address the WebSocket listener from [`Config::websocket`] bound to, if one was set. - #[cfg(feature = "websocket")] pub fn websocket_local_addr(&self) -> Option { self.websocket.as_ref().and_then(|ws| ws.local_addr().ok()) } /// The body of [`Listener::close`]. async fn shutdown(&mut self) { - #[cfg(any(feature = "tcp", all(feature = "uds", unix)))] self.streams.shutdown().await; - #[cfg(feature = "quic")] if let Some(quic) = self.quic.take() { quic.shutdown().await; } - #[cfg(feature = "websocket")] - { - let _ = self.websocket.take(); - } + let _ = self.websocket.take(); } /// Close the QUIC connections without waiting for the socket, as a drop must. fn close(&mut self) { - #[cfg(feature = "quic")] if let Some(quic) = self.quic.as_ref() { quic.close(); } @@ -906,7 +767,6 @@ impl Listener { /// /// To have a drain wait for a session still being established, hold a guard from /// [`Self::admission`] until this call returns. - #[cfg(feature = "qmux")] pub async fn accept_with( &self, transport: Transport, @@ -922,7 +782,6 @@ impl Listener { /// The accepted connections a drain waits for, including any session a guard from it /// holds while it is established for [`Self::accept_with`]. - #[cfg(feature = "qmux")] pub fn admission(&self) -> &moq_net::server::Admission { &self.server.admission } @@ -944,7 +803,6 @@ impl Listener { /// sockets: what is queued on them is the successor's to accept. A handshake /// still in flight is dropped, and its client dials again. Later /// [`accept`](Self::accept) calls see no stream listener. - #[cfg(any(feature = "tcp", all(feature = "uds", unix)))] pub async fn close_streams(&mut self) { crate::runtime::scope(self.server.streams.shutdown()).await; } @@ -959,13 +817,11 @@ impl Listener { } /// The address the WebSocket listener from [`Config::websocket`] bound to, if one was set. - #[cfg(feature = "websocket")] pub fn websocket_local_addr(&self) -> Option { self.server.websocket_local_addr() } /// The address the TCP (qmux) listener bound to, if one was configured. - #[cfg(feature = "tcp")] pub fn tcp_local_addr(&self) -> Option { self.server.streams.tcp_local_addr } @@ -998,14 +854,12 @@ async fn serve_session(request: Request) -> crate::Result<()> { } /// The MoQ server an accepted connection handshakes against. -#[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", all(feature = "uds", unix)))] #[derive(Clone)] struct Setup { admission: moq_net::server::Admission, server: moq_net::Server, } -#[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", all(feature = "uds", unix)))] impl Setup { /// When a connection accepted now must finish accepting; see [`moq_net::Server::deadline`]. fn deadline(&self) -> Option { @@ -1013,7 +867,6 @@ impl Setup { } } -#[cfg(feature = "websocket")] pub(crate) async fn accept_websocket( session: qmux::Session, options: crate::websocket::Options, @@ -1036,7 +889,6 @@ pub(crate) async fn accept_websocket( /// /// Nothing is established yet that could carry a close code, so an expired /// handshake is dropped, which closes its connection. -#[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", all(feature = "uds", unix)))] pub(crate) async fn within( deadline: Option, handshake: impl Future>, @@ -1058,7 +910,6 @@ where /// A URL-less transport carries the request path in the moq-lite-05+ SETUP, so /// lite-05 is offered on top of the configured versions even when a custom set /// omits it. Older versions still work for clients that need no path. -#[cfg(any(feature = "tcp", all(feature = "uds", unix)))] fn stream_versions(base: &moq_net::Versions) -> moq_net::Versions { let mut versions: Vec = base.iter().copied().collect(); if let Ok(lite05) = "moq-lite-05".parse::() @@ -1070,26 +921,22 @@ fn stream_versions(base: &moq_net::Versions) -> moq_net::Versions { } /// A configured stream listener (`--listen-tcp-bind` / `--listen-unix-bind`). -#[cfg(any(feature = "tcp", all(feature = "uds", unix)))] enum StreamBind { /// With its TLS when the listener serves `tls://`, and the socket to serve /// when the caller bound it. - #[cfg(feature = "tcp")] Tcp(net::SocketAddr, Option, Option), /// With the socket to serve when the caller bound it. - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] Unix(PathBuf, Option), } /// The TLS a `--listen-tcp-tls` listener serves, reloading its certificate /// while this lives. -#[cfg(feature = "tcp")] struct TcpTls { config: std::sync::Arc, serve: crate::tls::Serve, } -#[cfg(all(feature = "tcp", feature = "_certs"))] impl TcpTls { // The same certificate resolver and client-certificate policy as the QUIC // listeners, so CA roots and pinned peers mean the same on `tls://`. @@ -1110,31 +957,19 @@ impl TcpTls { } } -#[cfg(all(feature = "tcp", not(feature = "_certs")))] -impl TcpTls { - /// Without a crypto provider there is no certificate to serve. - fn new(_config: &crate::listen::Config, _versions: &moq_net::Versions) -> crate::Result { - Err(Error::NoBackend("--listen-tcp-tls requires a crypto provider feature")) - } -} - /// A bound stream listener, before its accept loop is spawned. -#[cfg(any(feature = "tcp", all(feature = "uds", unix)))] enum BoundListener { - #[cfg(feature = "tcp")] Tcp(crate::tcp::Listener), - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] Unix(crate::unix::Listener), } -#[cfg(any(feature = "tcp", all(feature = "uds", unix)))] impl StreamBind { /// The name this listener reports its accept health under. fn name(&self) -> &'static str { match self { - #[cfg(feature = "tcp")] Self::Tcp(..) => "tcp", - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] Self::Unix(..) => "unix", } } @@ -1147,10 +982,8 @@ impl StreamBind { /// [`Listener::accept`] instead. Each loop feeds completed [`Request`]s back over /// a channel. The tasks own their listeners and in-flight handshakes, and are /// stopped when the [`Listener`] closes or drops, so no socket lingers. -#[cfg(any(feature = "tcp", all(feature = "uds", unix)))] struct StreamListeners { /// Keeps the TCP listener's TLS certificate reloading while it serves. - #[cfg(feature = "tcp")] _tcp_tls: Option, binds: Vec, /// One per entry in `binds`, in the same order, and created up front rather than @@ -1160,41 +993,37 @@ struct StreamListeners { versions: moq_net::Versions, /// The `[quic]` section each accepted session starts with. quic: crate::quic::Resolved, - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] unix_allow: Option, /// Bound sockets whose accept loops have not started. Empty once [`Self::serve`] /// runs, and when nothing was configured. pending: Vec, /// The address the TCP listener bound, once [`Self::bind`] has run. - #[cfg(feature = "tcp")] tcp_local_addr: Option, rx: Option>, tasks: Vec>, } -#[cfg(any(feature = "tcp", all(feature = "uds", unix)))] impl StreamListeners { fn new( binds: Vec, versions: moq_net::Versions, quic: crate::quic::Resolved, - #[cfg(all(feature = "uds", unix))] unix_allow: Option, + #[cfg(unix)] unix_allow: Option, ) -> Self { let health = binds .iter() .map(|bind| crate::accept::Health::new(bind.name())) .collect(); Self { - #[cfg(feature = "tcp")] _tcp_tls: None, binds, health, versions, quic, - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] unix_allow, pending: Vec::new(), - #[cfg(feature = "tcp")] tcp_local_addr: None, rx: None, tasks: Vec::new(), @@ -1215,7 +1044,6 @@ impl StreamListeners { for (bind, health) in self.binds.drain(..).zip(self.health.iter().cloned()) { let alpns = self.versions.alpns(); match bind { - #[cfg(feature = "tcp")] StreamBind::Tcp(addr, tls, prebound) => { if tls.is_none() && !addr.ip().is_loopback() { tracing::warn!(%addr, "tcp listener bound to a non-loopback address; qmux is UNENCRYPTED, ensure the network is trusted"); @@ -1238,7 +1066,7 @@ impl StreamListeners { self.tcp_local_addr = Some(local); pending.push(BoundListener::Tcp(listener)); } - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] StreamBind::Unix(path, prebound) => { let listener = match prebound { Some(listener) => crate::unix::Listener::from_std(listener, &path)?, @@ -1277,9 +1105,8 @@ impl StreamListeners { let (tx, rx) = tokio::sync::mpsc::channel(16); for listener in self.pending.drain(..) { let task = match listener { - #[cfg(feature = "tcp")] BoundListener::Tcp(listener) => spawn_tcp_loop(listener, setup.clone(), tx.clone()), - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] BoundListener::Unix(listener) => spawn_unix_loop(listener, setup.clone(), self.unix_allow.clone(), tx.clone()), }; self.tasks.push(task); @@ -1324,7 +1151,6 @@ impl StreamListeners { } } -#[cfg(any(feature = "tcp", all(feature = "uds", unix)))] impl Drop for StreamListeners { fn drop(&mut self) { // Stop the accept loops so their listeners (and bound sockets) are freed. @@ -1334,7 +1160,6 @@ impl Drop for StreamListeners { } } -#[cfg(feature = "tcp")] fn spawn_tcp_loop( listener: crate::tcp::Listener, setup: Setup, @@ -1374,7 +1199,7 @@ fn spawn_tcp_loop( }) } -#[cfg(all(feature = "uds", unix))] +#[cfg(unix)] fn spawn_unix_loop( listener: crate::unix::Listener, setup: Setup, @@ -1411,7 +1236,6 @@ fn spawn_unix_loop( /// What a transport learned while accepting a connection, before moq-net reads its SETUP: /// everything a [`Request`] reports besides the handshake itself. -#[cfg(feature = "_transport")] pub(crate) struct Incoming { pub transport: Transport, /// The request URL, on the transports that carry one (WebTransport, WebSocket). @@ -1424,7 +1248,6 @@ pub(crate) struct Incoming { pub active: moq_net::server::Admitted, } -#[cfg(any(test, feature = "qmux"))] impl Incoming { /// A connection with no facts beyond its transport. pub(crate) fn new( @@ -1445,21 +1268,17 @@ impl Incoming { } /// The connection [`Request::ok`] applies [`Request::with_quic_limits`] to. -#[cfg(feature = "_transport")] pub(crate) enum Under { /// A transport moq-tokio cannot widen beyond what moq-net's `set_limits` reaches. - #[cfg(all(test, feature = "websocket"))] + #[cfg(test)] Opaque, /// A raw QUIC or WebTransport connection. - #[cfg(feature = "quic")] Quic(crate::quic::driver::connection::Connection), /// A qmux session: WebSocket, `tcp://`, `tls://`, `unix://`, or one handed over with /// [`Listener::accept_with`]. - #[cfg(feature = "qmux")] Qmux(qmux::Session), } -#[cfg(feature = "tcp")] impl Incoming { /// A TCP session's facts. On `tls://` these are the SNI, and the client /// certificate the verifier of `tls` already accepted. @@ -1493,7 +1312,6 @@ impl Incoming { } /// Report the ALPN the connection's TLS handshake negotiated. - #[cfg(feature = "_certs")] pub(crate) fn with_alpn(mut self, alpn: Option) -> Self { self.link.alpn = alpn; self @@ -1501,7 +1319,6 @@ impl Incoming { } /// Read SETUP in the connection task and forward the resulting request. -#[cfg(any(feature = "tcp", all(feature = "uds", unix)))] async fn stream_request( session: qmux::Session, setup: &Setup, @@ -1519,7 +1336,6 @@ async fn stream_request( /// The transport-level facts a backend captures while accepting a connection, before the /// MoQ SETUP. Grouped so the shared accept loop builds a [`Request`] from named fields /// rather than a wide tuple. -#[cfg(feature = "quic")] pub(crate) struct Accepted { pub session: S, pub url: Option, @@ -1547,11 +1363,9 @@ pub struct Link { /// Changes one accepted QUIC connection's limits while its session runs, from /// [`Request::quic_limits`]. Cloning shares the connection. -#[cfg(feature = "quic")] #[derive(Clone)] pub struct QuicLimits(crate::quic::driver::connection::Connection); -#[cfg(feature = "quic")] impl QuicLimits { /// Update the connection's limits, as [`Request::with_quic_limits`] does before SETUP. /// @@ -1561,7 +1375,6 @@ impl QuicLimits { } } -#[cfg(feature = "quic")] impl std::fmt::Debug for QuicLimits { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("QuicLimits").finish_non_exhaustive() @@ -1634,7 +1447,6 @@ impl Request { } /// [`Self::accept`] over a qmux session. - #[cfg(feature = "qmux")] pub(crate) async fn accept_qmux( server: &moq_net::Server, session: qmux::Session, @@ -1686,11 +1498,9 @@ impl Request { /// A handle that changes this connection's QUIC limits while the session runs, such as /// bitrate caps that change after acceptance. `None` on a transport moq-quic does not /// drive (qmux streams). - #[cfg(feature = "quic")] pub fn quic_limits(&self) -> Option { match &self.under { Under::Quic(quic) => Some(QuicLimits(quic.clone())), - #[allow(unreachable_patterns, reason = "a QUIC-only build has no other connection")] _ => None, } } @@ -1725,9 +1535,8 @@ impl Request { } /// The receive window of the qmux session under this request. - #[cfg(all(test, any(feature = "websocket", feature = "tcp")))] + #[cfg(test)] pub(crate) fn qmux_window(&self) -> moq_net::transport::ReceiveWindow { - #[allow(irrefutable_let_patterns, reason = "a qmux-only build has no other connection")] let Under::Qmux(qmux) = &self.under else { panic!("a qmux session"); }; @@ -1745,11 +1554,9 @@ impl Request { let mut limits = self.quic_limits; let window = limits.receive_window.take(); match &self.under { - #[cfg(all(test, feature = "websocket"))] + #[cfg(test)] Under::Opaque => {} - #[cfg(feature = "quic")] Under::Quic(quic) => quic.set_limits(limits).expect("validated by with_quic_limits"), - #[cfg(feature = "qmux")] Under::Qmux(qmux) => { if let Err(err) = qmux.set_limits(limits) { self.handshake.close(moq_net::SessionError::Internal.into()); @@ -1915,14 +1722,13 @@ mod tests { /// A dead loop's channel closes before its handle resolves; that close must not /// read as a clean stop, or `accept` would disable the stream arm and hang. - #[cfg(any(feature = "tcp", all(feature = "uds", unix)))] #[tokio::test] async fn a_closed_channel_still_reports_the_dead_loop() { let mut streams = StreamListeners::new( Vec::new(), Default::default(), Default::default(), - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] None, ); let (tx, rx) = tokio::sync::mpsc::channel(1); @@ -1935,14 +1741,7 @@ mod tests { assert!(matches!(died, Some(Err(err)) if err.is_panic())); } - #[cfg(all(not(feature = "quic"), feature = "_certs"))] - #[test] - fn no_quic_backend_needs_no_served_identity() { - Server::new(Config::default()).expect("an absent QUIC backend must not load a TLS identity"); - } - /// A shared identity on a plaintext-only server would be dropped silently. - #[cfg(all(feature = "tcp", feature = "_certs"))] #[tokio::test] async fn a_shared_identity_needs_a_tls_listener() { let tls = crate::tls::Listen { @@ -1958,7 +1757,6 @@ mod tests { } /// The windows `[quic]` configures, smaller than its defaults. - #[cfg(any(feature = "quic", feature = "tcp"))] fn small_quic() -> crate::quic::Config { crate::quic::Config { receive_window: Some(moq_net::transport::MIN_RECEIVE_WINDOW * 2), @@ -1969,7 +1767,6 @@ mod tests { /// A `tcp://` session starts at the server's `[quic]` windows rather than the defaults, /// before anything admits it. - #[cfg(feature = "tcp")] #[tokio::test] async fn an_accepted_qmux_session_starts_at_the_configured_windows() { const TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10); @@ -2005,7 +1802,7 @@ mod tests { /// predecessor, are served in place of binding: a session dialed before the server /// existed is accepted off the queue. Closing the streams then leaves the caller's /// sockets listening and the Unix path in place, for whoever serves them next. - #[cfg(all(feature = "tcp", feature = "uds", unix))] + #[cfg(unix)] #[tokio::test] async fn held_stream_sockets_are_served_and_left_to_their_holder() { kio::clock::host_time(); // real sockets @@ -2059,7 +1856,6 @@ mod tests { } /// A held socket with no listener configured for it would be served by nothing. - #[cfg(feature = "tcp")] #[test] fn a_held_stream_socket_needs_its_listener() { let mut config = Config::default(); @@ -2068,13 +1864,13 @@ mod tests { } /// A millisecond track: the frames written here carry timestamps. - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] fn timed() -> moq_net::track::Info { moq_net::track::Info::default().with_timescale(moq_net::Timescale::MILLI) } /// The next route and whether it is active. - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] async fn next_update(announced: &mut moq_net::announce::Consumer) -> Option<(moq_net::announce::Announce, bool)> { loop { return match announced.next().await? { @@ -2090,7 +1886,6 @@ mod tests { /// The second handshake must finish while the first peer is still stalled. /// Reading the first server bytes proves it reached the handshake before we /// connect the second peer; EOF would mean its handshake already failed. - #[cfg(feature = "tcp")] #[tokio::test] async fn tcp_stalled_handshake_does_not_block_accept() { use futures::FutureExt; @@ -2131,7 +1926,6 @@ mod tests { /// A drain that closed admission refuses at accept instead of starting a /// handshake it would then cut off. - #[cfg(feature = "tcp")] #[tokio::test] async fn tcp_closed_activity_refuses_at_accept() { let admission = moq_net::server::Admission::default(); @@ -2163,7 +1957,7 @@ mod tests { /// A refused peer must be closed without exchanging even the qmux preface. /// Use our real kernel credentials and change only the configured allowlist. - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] #[tokio::test] async fn unix_allowlist_precedes_negotiation() { use tokio::io::AsyncReadExt; @@ -2220,7 +2014,7 @@ mod tests { } } - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] #[tokio::test] async fn unix_stalled_handshake_does_not_block_accept() { use futures::FutureExt; @@ -2266,7 +2060,6 @@ mod tests { /// all gone. Time pauses only once the socket I/O is done (a paused runtime /// waiting on the kernel would skip ahead to qmux's own handshake timeout), so /// a leaked task leaves the runtime idle and fires the 1s timeout first. - #[cfg(feature = "tcp")] #[tokio::test] async fn tcp_stop_aborts_stalled_handshake() { use tokio::io::AsyncReadExt; @@ -2293,7 +2086,7 @@ mod tests { assert!(matches!(closed, Ok(None)), "stalled handshake outlived its accept loop"); } - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] #[tokio::test] async fn unix_stop_aborts_stalled_handshake() { use tokio::io::AsyncReadExt; @@ -2324,7 +2117,6 @@ mod tests { /// A qmux session pair over an in-memory WebSocket, so a handshake can run on a /// paused clock. - #[cfg(feature = "websocket")] async fn session_pair() -> (qmux::Session, qmux::Session) { const ALPN: &str = "qmux-01.moq-lite-06"; let (client, server) = tokio::io::duplex(64 * 1024); @@ -2336,7 +2128,6 @@ mod tests { } /// HTTP connection facts and the admission guard survive the upgraded-socket handoff. - #[cfg(feature = "websocket")] #[tokio::test(start_paused = true)] async fn upgraded_websocket_preserves_request_metadata() { use moq_net::transport::poll::{SendOptions, SendStream as _, Session as _}; @@ -2379,7 +2170,6 @@ mod tests { /// An embedder may poll the deadline from outside any tokio runtime. A SETUP that is /// already buffered resolves the handshake before its timer starts, so the timer /// first starts here and still needs a runtime. - #[cfg(feature = "websocket")] #[test] fn expired_polls_outside_a_runtime() { use moq_net::transport::poll::{SendOptions, SendStream as _, Session as _}; @@ -2419,7 +2209,6 @@ mod tests { assert!(request.poll_expired(&kio::Waiter::noop()).is_pending()); } - #[cfg(feature = "websocket")] #[tokio::test(start_paused = true)] async fn upgraded_websocket_refuses_setup_path_presence() { use moq_net::transport::poll::{SendOptions, SendStream as _, Session as _}; @@ -2461,7 +2250,6 @@ mod tests { /// With `setup` it is a moq-transport peer whose bidi SETUP stream delivers those /// bytes and then never grants credit for the reply. Without it, it never opens /// anything, while a bidi stream it opens itself records what is written. - #[cfg(feature = "websocket")] #[derive(Clone)] struct Scripted { alpn: &'static str, @@ -2470,7 +2258,6 @@ mod tests { closed: std::sync::Arc>>, } - #[cfg(feature = "websocket")] impl Scripted { fn new(alpn: &'static str) -> Self { Self { @@ -2483,12 +2270,10 @@ mod tests { } /// The scripted peer never fails, only parks, so its error is never built. - #[cfg(feature = "websocket")] #[derive(Debug, Clone, thiserror::Error)] #[error("scripted peer error")] struct ScriptedError; - #[cfg(feature = "websocket")] impl moq_net::transport::Error for ScriptedError { fn session_error(&self) -> Option<(u32, String)> { None @@ -2496,12 +2281,10 @@ mod tests { } /// Records every write, or accepts none when stalled. - #[cfg(feature = "websocket")] struct ScriptedSend { written: std::sync::Arc>>, stalled: bool, } - #[cfg(feature = "websocket")] impl moq_net::transport::poll::SendStream for ScriptedSend { type Error = ScriptedError; type Group = moq_net::transport::poll::Ungrouped; @@ -2529,11 +2312,9 @@ mod tests { } /// Delivers data once, then parks. - #[cfg(feature = "websocket")] struct ScriptedRecv { data: Option, } - #[cfg(feature = "websocket")] impl moq_net::transport::poll::Chunks for ScriptedRecv { type Error = ScriptedError; fn poll_read_chunk( @@ -2553,7 +2334,6 @@ mod tests { fn stop(&mut self, _: u32) {} } - #[cfg(feature = "websocket")] impl moq_net::transport::poll::Session for Scripted { type SendStream = ScriptedSend; type RecvStream = moq_net::transport::poll::Buffered; @@ -2627,7 +2407,6 @@ mod tests { } /// A timeout past the clock's range waits forever instead of panicking on accept. - #[cfg(feature = "websocket")] #[tokio::test] async fn unreachable_timeout_has_no_deadline() { let setup = Setup { @@ -2638,7 +2417,6 @@ mod tests { } /// A peer that never sends SETUP is refused at the deadline, and told why. - #[cfg(feature = "websocket")] #[tokio::test(start_paused = true)] async fn stalled_setup_is_closed_at_the_deadline() { let peer = Scripted::new("moq-lite-06"); @@ -2663,7 +2441,6 @@ mod tests { /// Answering SETUP is part of the handshake: a peer that sends its SETUP but /// never grants credit for the reply is refused at the same /// deadline, rather than held open by keep-alives, and the session counts it. - #[cfg(feature = "websocket")] #[tokio::test(start_paused = true)] async fn stalled_setup_reply_is_closed_at_the_deadline() { // Record a real CLIENT_SETUP offering only lite-02, whose reply waits for @@ -2719,7 +2496,6 @@ mod tests { /// The deadline bounds only the handshake: a session that finished in time /// stays open past it. - #[cfg(feature = "websocket")] #[tokio::test(start_paused = true)] async fn completed_setup_outlives_the_deadline() { use moq_net::transport::poll::Session as _; @@ -2759,7 +2535,6 @@ mod tests { /// A WebSocket peer that never sends its upgrade request holds up only itself. /// Real sockets, so this runs on the wall clock. - #[cfg(feature = "websocket")] #[tokio::test] async fn websocket_stalled_upgrade_does_not_block_accept() { let ws = crate::websocket::Listener::bind("127.0.0.1:0".parse().unwrap()) @@ -2819,7 +2594,6 @@ mod tests { /// startup, which is exactly when a metrics endpoint is assembled. A stream-only /// node would then publish no accept counters for the only sockets on it that can /// fail. - #[cfg(feature = "tcp")] #[test] fn accept_health_covers_stream_listeners_before_they_bind() { let mut config = crate::listen::Config::default(); @@ -2842,7 +2616,7 @@ mod tests { /// stays held by a server that never serves. Binding everything before spawning /// anything is what makes that release immediate rather than whenever an aborted /// task happens to be dropped. - #[cfg(all(feature = "tcp", feature = "uds", unix))] + #[cfg(unix)] #[tokio::test] async fn a_failed_listen_binds_nothing() { // A path that cannot be a socket, so the unix bind fails after the tcp one @@ -2889,7 +2663,7 @@ mod tests { /// [`moq_net::Server`]. [`Server::serve_publish`] sets the publisher there /// rather than on the request, so a session that handshakes against any other /// server accepts and then serves nothing. - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] #[tokio::test] async fn unix_listener_serves_the_configured_publisher() { kio::clock::host_time(); // a real Unix socket @@ -2985,7 +2759,6 @@ mod tests { let _ = std::fs::remove_file(&path); } - #[cfg(feature = "tcp")] #[tokio::test] async fn a_panicked_accept_loop_ends_its_listener() { let mut config = crate::listen::Config::default(); @@ -3018,7 +2791,6 @@ mod tests { /// Closing a listener must release its TCP socket before returning. Reusing it /// afterwards is unrepresentable: `listen` consumes the `Server` and `close` /// consumes the `Listener`. - #[cfg(feature = "tcp")] #[tokio::test] async fn close_releases_stream_listener_socket() { let mut config = crate::listen::Config::default(); @@ -3042,7 +2814,6 @@ mod tests { /// Closing a listener must release its UDP socket before returning, even while /// an accepted session still holds its QUIC connection, so a restart can rebind /// the port at once. - #[cfg(feature = "quic")] #[tokio::test] async fn close_releases_quic_socket() { let config = crate::listen::Config { @@ -3074,7 +2845,6 @@ mod tests { /// A QUIC connection holds back its receive window until the request is admitted, and /// `ok` opens the `[quic]` window, or the one the request names, before SETUP OK. - #[cfg(feature = "quic")] #[tokio::test] async fn admission_opens_the_held_back_quic_window() { let wider = std::num::NonZeroU64::new(moq_net::transport::MIN_RECEIVE_WINDOW * 4).unwrap(); @@ -3123,7 +2893,6 @@ mod tests { /// A QUIC endpoint that stops under a live listener fails `accept` and the /// `serve_*` loop built on it, instead of reading as a clean stop. - #[cfg(feature = "quic")] #[tokio::test] async fn a_stopped_quic_endpoint_fails_accept() { let config = crate::listen::Config { @@ -3165,7 +2934,6 @@ mod tests { /// A client CA or pinned peers on a stream-only server are refused unless a /// `tls://` listener verifies them: the plaintext stream listeners never ask /// for a client certificate. - #[cfg(feature = "tcp")] #[tokio::test] async fn client_auth_without_a_tls_listener_is_rejected() { let dir = tempfile::tempdir().unwrap(); @@ -3201,89 +2969,14 @@ mod tests { // A `tls://` listener verifies it. config.tcp.tls = Some(true); config.tls.generate = vec!["localhost".into()]; - #[cfg(feature = "_certs")] config .init(Default::default()) .expect("tls:// verifies client certificates"); - #[cfg(not(feature = "_certs"))] - assert!(matches!(config.init(Default::default()), Err(Error::NoBackend(_)))); } } - /// An explicit QUIC bind cannot be honored without a QUIC backend. - #[cfg(not(feature = "quic"))] - #[test] - fn quic_bind_without_a_quic_backend_is_rejected() { - let config = crate::listen::Config { - bind: Some("127.0.0.1:0".parse().unwrap()), - ..Default::default() - }; - - assert!(matches!( - Config { - listen: config, - ..Default::default() - } - .init(), - Err(Error::NoBackend(_)) - )); - } - - /// A reset secret on the default QUIC listener would never be read without a - /// QUIC backend. - #[cfg(not(feature = "quic"))] - #[test] - fn reset_secret_without_a_quic_backend_is_rejected() { - let mut config = crate::listen::Config::default(); - config.reset.secret = Some("reset.key".into()); - - assert!(matches!( - Config { - listen: config, - ..Default::default() - } - .init(), - Err(Error::NoBackend(reason)) if reason.starts_with("--listen-reset-secret") - )); - } - - /// A client CA on the default QUIC listener names the missing backend, not a - /// stream-only server the caller never configured. - #[cfg(not(feature = "quic"))] - #[test] - fn client_ca_without_a_quic_backend_is_rejected() { - let config = crate::listen::Config { - tls: crate::tls::Listen { - root: vec!["ca.pem".into()], - ..Default::default() - }, - ..Default::default() - }; - - assert!(matches!( - Config { - listen: config, - ..Default::default() - } - .init(), - Err(Error::NoBackend(_)) - )); - } - - /// A QUIC-only server reports nothing. It multiplexes over one UDP socket and - /// never calls `accept`, so a zero counter would be a watch that cannot fire. - #[cfg(all(feature = "quic", not(feature = "tcp")))] - #[test] - fn accept_health_is_empty_without_a_stream_listener() { - let server = crate::listen::Config::default() - .init(Default::default()) - .expect("quic server"); - assert!(server.accept_health().is_empty()); - } - /// `certificates()` must stay readable with no runtime entered (no guard /// escapes to the caller). - #[cfg(feature = "quic")] #[tokio::test] async fn certificates_expose_generated_fingerprints() { let mut config = crate::listen::Config { @@ -3302,7 +2995,7 @@ mod tests { /// A stream-only server has no TLS backend, so there's nothing to pin. This /// must report empty rather than panic. - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] #[tokio::test] async fn certificates_are_empty_without_a_tls_backend() { let dir = tempfile::tempdir().unwrap(); @@ -3361,7 +3054,7 @@ mod tests { ); } - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] #[test] fn stream_listener_config_parses() { let config: crate::listen::Config = toml::from_str( @@ -3386,7 +3079,7 @@ uid = [1001, 1002] assert!(config.has_explicit_bind()); } - #[cfg(all(feature = "uds", unix))] + #[cfg(unix)] #[test] fn stream_only_config_has_no_quic() { // A unix listener with no `--listen` is stream-only. diff --git a/rs/moq-tokio/src/sim.rs b/rs/moq-tokio/src/sim.rs index 51d1cac163f..061d42a692a 100644 --- a/rs/moq-tokio/src/sim.rs +++ b/rs/moq-tokio/src/sim.rs @@ -1,4 +1,4 @@ -//! Test support, enabled by the `sim` and `net` features: a network inside the process, for +//! Test support, enabled by the `sim` feature: a network inside the process, for //! tests on `kio::clock::sim`. //! //! A [`Client`](crate::Client) given a [`Network`] opens no sockets: each dial becomes a diff --git a/rs/moq-tokio/src/tcp.rs b/rs/moq-tokio/src/tcp.rs index f8afde9ac33..6e14b5f4be9 100644 --- a/rs/moq-tokio/src/tcp.rs +++ b/rs/moq-tokio/src/tcp.rs @@ -243,7 +243,6 @@ async fn connect_addrs( /// /// From [`crate::Server::tls_acceptor`]: the listen TLS identity, offering the /// same `qmux-01.` ALPNs as a [`Listener`] serving `tls://`. -#[cfg(feature = "_certs")] #[derive(Clone)] pub struct TlsAcceptor { config: std::sync::Arc, @@ -253,7 +252,6 @@ pub struct TlsAcceptor { server: moq_net::Server, } -#[cfg(feature = "_certs")] impl TlsAcceptor { pub(crate) fn new( config: std::sync::Arc, diff --git a/rs/moq-tokio/src/tls.rs b/rs/moq-tokio/src/tls.rs index 2937ffb6dd5..6801c6ef696 100644 --- a/rs/moq-tokio/src/tls.rs +++ b/rs/moq-tokio/src/tls.rs @@ -8,18 +8,15 @@ //! Certificates, keys, and custom root CAs loaded from disk are hot reloaded for //! new handshakes. [`Certificates`] reads the current served set back out. -#[cfg(all(feature = "watch", feature = "_certs"))] use crate::abort::AbortOnDrop; use crate::crypto; use rustls::pki_types::pem::PemObject; use rustls::pki_types::{CertificateDer, PrivateKeyDer, ServerName, UnixTime}; -#[cfg(feature = "_certs")] use std::fmt; use std::path::{Path, PathBuf}; use std::sync::{Arc, RwLock}; use std::{fs, io}; -#[cfg(feature = "_certs")] use rustls::pki_types::PrivatePkcs8KeyDer; /// Errors loading or generating TLS certificates and keys. @@ -157,7 +154,6 @@ pub enum Error { Rustls(#[from] rustls::Error), /// The mTLS client-certificate verifier couldn't be built from the configured roots. - #[cfg(feature = "_certs")] #[error("failed to build client certificate verifier")] ClientVerifier(#[source] rustls::server::VerifierBuilderError), @@ -166,13 +162,11 @@ pub enum Error { ServerVerifier(#[source] rustls::client::VerifierBuilderError), /// Generating a self-signed certificate failed. - #[cfg(feature = "_certs")] #[error("failed to generate a self-signed certificate: {0}")] Rcgen(String), /// A client certificate chain held more candidate paths than certificate path /// building allows, so its lineage could not be traced in full. - #[cfg(feature = "_certs")] #[error("the client certificate chain is too complex to trace: {0}")] Lineage(String), @@ -186,7 +180,6 @@ pub enum Error { Deprecated(crate::cli::Deprecated), } -#[cfg(feature = "_certs")] crate::error::from_message! { rcgen::Error => Rcgen, } @@ -254,13 +247,11 @@ fn load_key_pair( // ── Certified ─────────────────────────────────────────────────────── /// A certificate chain and its rustls signing key. -#[cfg(feature = "_certs")] pub(crate) struct Certified { /// The chain and its rustls signer, in leaf-first order. pub rustls: Arc, } -#[cfg(feature = "_certs")] impl Certified { /// Load `chain` and `key`, building the rustls signer and keeping the DER. pub(crate) fn new( @@ -282,7 +273,6 @@ impl Certified { } } -#[cfg(feature = "_certs")] impl fmt::Debug for Certified { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { // Never derive: the DER private key would print in full. @@ -307,14 +297,12 @@ impl fmt::Debug for Certified { /// Set it on [`Listen::identity`] to serve it and [`Connect::identity`] to /// present it. Generated in memory and never written to disk, so it lasts as /// long as the process and a restart is a new principal. -#[cfg(feature = "_certs")] #[derive(Clone)] pub struct Identity { key: Arc, fingerprint: String, } -#[cfg(feature = "_certs")] impl Identity { /// Generate a fresh identity, valid for `hostnames`. /// @@ -344,7 +332,6 @@ impl Identity { } } -#[cfg(feature = "_certs")] impl fmt::Debug for Identity { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { formatter @@ -355,11 +342,9 @@ impl fmt::Debug for Identity { } /// Presents one fixed client certificate whenever a server asks for one. -#[cfg(any(feature = "_certs", not(feature = "watch")))] #[derive(Debug)] struct IdentityResolver(Arc); -#[cfg(any(feature = "_certs", not(feature = "watch")))] impl rustls::client::ResolvesClientCert for IdentityResolver { fn resolve( &self, @@ -380,13 +365,11 @@ impl rustls::client::ResolvesClientCert for IdentityResolver { /// /// A rewrite that is briefly missing, malformed, or mismatched (the certificate /// replaced before its key) keeps the previous pair until the files agree again. -#[cfg(feature = "watch")] #[derive(Debug)] struct ReloadingClientCert { inner: Reloading, } -#[cfg(feature = "watch")] impl ReloadingClientCert { fn new( provider: crypto::Provider, @@ -402,7 +385,6 @@ impl ReloadingClientCert { } } -#[cfg(feature = "watch")] impl rustls::client::ResolvesClientCert for ReloadingClientCert { fn resolve( &self, @@ -463,7 +445,6 @@ 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), @@ -555,7 +536,6 @@ pub struct Connect { /// generates its identity at startup rather than loading one from disk. /// Setting both is an error. Not settable from the CLI or a config file, /// since it never exists on disk. - #[cfg(feature = "_certs")] #[usage(skip)] #[serde(skip)] pub identity: Option, @@ -563,7 +543,7 @@ pub struct Connect { /// PEM file containing the client certificate chain for mTLS. /// /// Only certificates are extracted; any private keys in the file are ignored. - /// Must be paired with `--connect-tls-key`. With the `watch` feature, both files + /// Must be paired with `--connect-tls-key`. Both files /// are hot reloaded for new connections, retaining the last valid pair while a /// rotation is missing, malformed, or mismatched. Dialing `http://`, `ws://`, /// `tcp://`, or `unix://` with a client certificate fails, since none can present it. @@ -761,13 +741,11 @@ impl CustomRoots { }) } - #[cfg(feature = "watch")] fn load(&self) -> Result>> { read_roots(&self.paths) } /// Only a build that reloads has a second set of roots to install. - #[cfg(feature = "watch")] fn replace(&self, roots: Vec>) { *self.current.write().unwrap_or_else(std::sync::PoisonError::into_inner) = roots; } @@ -780,7 +758,6 @@ impl CustomRoots { } } -#[cfg(feature = "watch")] struct ReloadState { current: RwLock>, build: Box Result> + Send + Sync>, @@ -791,7 +768,6 @@ struct ReloadState { serial: std::sync::Mutex<()>, } -#[cfg(feature = "watch")] impl ReloadState { fn reload(&self) { let _serial = self.serial.lock().unwrap_or_else(std::sync::PoisonError::into_inner); @@ -828,14 +804,12 @@ impl ReloadState { } /// A verifier or client certificate replaced after its files change. -#[cfg(feature = "watch")] struct Reloading { state: Arc>, // Holds the OS watcher alive for exactly as long as the TLS config. _watcher: notify::RecommendedWatcher, } -#[cfg(feature = "watch")] impl Reloading { fn new( paths: &[PathBuf], @@ -866,7 +840,6 @@ impl Reloading { } } -#[cfg(feature = "watch")] impl std::fmt::Debug for Reloading { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("Reloading") @@ -1052,13 +1025,11 @@ impl Connect { /// plaintext fetch, and there is nothing to bootstrap when verification is /// disabled. With CA roots (the default), `http://` is the deliberate /// per-connection way to pin a self-signed relay, so it is allowed. - #[cfg(feature = "quic")] pub(crate) fn allows_http_bootstrap(&self) -> bool { self.fingerprint.is_empty() && !self.insecure.unwrap_or_default() } /// Whether a dial presents an mTLS client certificate. - #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", feature = "uds"))] pub(crate) fn has_client_cert(&self) -> bool { self.identity.is_some() || self.cert.is_some() } @@ -1089,9 +1060,8 @@ impl Connect { if let Some(name) = &self.host_name { server_name(name)?; } - let reloadable = cfg!(feature = "watch") - && (self.cert.is_some() - || matches!(&verification, Verification::Roots { custom, .. } if !custom.paths.is_empty())); + let reloadable = self.cert.is_some() + || matches!(&verification, Verification::Roots { custom, .. } if !custom.paths.is_empty()); // Allow TLS 1.2 in addition to 1.3 for WebSocket compatibility. // QUIC always negotiates TLS 1.3 regardless of this setting. @@ -1140,7 +1110,6 @@ impl Connect { ) -> Result> { let initial = Self::build_root_server_verifier(&custom.current(), system, &provider)?; - #[cfg(feature = "watch")] if !custom.paths.is_empty() { let paths = custom.paths.clone(); let reload = custom.clone(); @@ -1210,7 +1179,6 @@ impl Connect { &self, builder: rustls::ConfigBuilder, ) -> Result { - #[cfg(feature = "_certs")] if let Some(identity) = &self.identity { if self.cert.is_some() || self.key.is_some() { return Err(Error::ConflictingClientAuth); @@ -1228,10 +1196,7 @@ impl Connect { let provider = builder.crypto_provider().clone(); let initial = load_key_pair(&provider, &cert, &key)?; - #[cfg(feature = "watch")] let resolver = Arc::new(ReloadingClientCert::new(provider, cert, key, initial)?); - #[cfg(not(feature = "watch"))] - let resolver = Arc::new(IdentityResolver(initial)); Ok(builder.with_client_cert_resolver(resolver)) } @@ -1242,7 +1207,6 @@ impl Connect { /// Valid for two weeks starting yesterday: WebTransport refuses anything longer, /// and the backdating absorbs clock drift between two hosts that have never /// agreed on a time source. -#[cfg(feature = "_certs")] fn generate(provider: &crypto::Provider, hostnames: &[String]) -> Result { let key_pair = rind_rcgen::KeyPair::generate(&rcgen::PKCS_ECDSA_P256_SHA256)?; @@ -1348,7 +1312,6 @@ pub struct Listen { /// The programmatic alternative to `generate`, for a peer that hands the same /// identity to [`Connect::identity`] so both roles share one fingerprint. Not /// settable from the CLI or a config file, since it never exists on disk. - #[cfg(feature = "_certs")] #[usage(skip)] #[serde(skip)] pub identity: Option, @@ -1448,42 +1411,29 @@ impl Listen { /// /// File-backed certificates reload on the caller's Tokio runtime, else the fallback, /// which must outlive every listener using the result. - #[cfg(feature = "_certs")] pub fn load(&self) -> Result { self.refuse_deprecated()?; let provider = crypto::provider()?; let certs = Arc::new(ServeCerts::new(provider.clone())); certs.load_certs(self)?; let ClientAuth { verifier, roots } = self.client_auth(provider)?; - #[cfg(feature = "watch")] let reload = Reload::spawn(certs.clone(), self.clone())?; Ok(Serve(Arc::new(Serving { certs, resolver: None, verifier, roots, - #[cfg(feature = "watch")] _reload: reload, }))) } - #[cfg(all(feature = "_certs", feature = "_transport"))] pub(crate) fn configured(&self) -> bool { !self.cert.is_empty() || !self.key.is_empty() || !self.generate.is_empty() || !self.root.is_empty() || self.peers.is_some() - || { - #[cfg(feature = "_certs")] - { - self.identity.is_some() - } - #[cfg(not(feature = "_certs"))] - { - false - } - } + || { self.identity.is_some() } } /// The released spellings in use, each paired with what replaced it. @@ -1534,7 +1484,6 @@ impl Listen { /// Gated with the rest of the serving side rather than with `watch`: a pinned /// [`peers`](Self::peers) set changes while the process runs whether or not /// anything is reloading from disk. - #[cfg(feature = "_certs")] pub(crate) fn disable_resumption(&self, tls: &mut rustls::ServerConfig) { if !self.root.is_empty() || self.peers.is_some() { tls.session_storage = Arc::new(rustls::server::NoServerSessionStorage {}); @@ -1563,7 +1512,6 @@ impl Listen { /// The one place the TLS listeners agree on what mTLS means here, so a new /// mode lands once rather than in each of them: pinned [`peers`](Self::peers), /// else optional CA-rooted [`root`](Self::root), else nothing. - #[cfg(feature = "_certs")] pub(crate) fn client_auth(&self, provider: crypto::Provider) -> Result { if let Some(peers) = &self.peers { // Pinning replaces the chain rather than adding to it, so a caller that @@ -1584,13 +1532,11 @@ impl Listen { } /// Build the optional-client-auth verifier, reloading configured roots in place. - #[cfg(feature = "_certs")] fn client_verifier(&self, provider: crypto::Provider) -> Result { self.refuse_deprecated()?; let roots = ClientRoots::default(); let initial = Self::build_client_verifier(&self.root, &provider, &roots)?; - #[cfg(feature = "watch")] let verifier = { let paths = self.root.clone(); let reload_paths = paths.clone(); @@ -1601,8 +1547,6 @@ impl Listen { })?; Arc::new(verifier) }; - #[cfg(not(feature = "watch"))] - let verifier = initial; Ok(ClientAuth { verifier: Some(verifier), @@ -1611,7 +1555,6 @@ impl Listen { } /// Build a verifier from the root files, adding them to `roots` once it builds. - #[cfg(feature = "_certs")] fn build_client_verifier( paths: &[PathBuf], provider: &crypto::Provider, @@ -1634,13 +1577,9 @@ impl Listen { /// certificate handling the QUIC listeners use: on-disk `cert`/`key` pairs, /// `generate` self-signed certs, and optional mTLS `root` client CAs. /// - /// Available whenever a crypto provider is compiled in, so a build with no - /// QUIC backend at all can still terminate TLS. - /// /// `alpn` sets the advertised ALPN protocols (e.g. /// `vec![b"h2".to_vec(), b"http/1.1".to_vec()]`); pass an empty list for a /// protocol like RTMPS that doesn't use ALPN. - #[cfg(feature = "_certs")] pub fn server_config(&self, alpn: Vec>) -> Result> { self.refuse_deprecated()?; let provider = crypto::provider()?; @@ -1669,23 +1608,19 @@ impl Listen { /// A rotation swaps one complete snapshot: handshakes that already resolved the /// old certificate finish with it, and a partial or invalid replacement keeps the /// last valid snapshot serving. -#[cfg(feature = "_certs")] #[derive(Clone, Debug)] pub struct Serve(Arc); -#[cfg(feature = "_certs")] #[derive(Debug)] struct Serving { certs: Arc, resolver: Option>, verifier: Option>, roots: ClientRoots, - #[cfg(feature = "watch")] _reload: Reload, } /// A listener's client-certificate verifier and the roots behind it. -#[cfg(feature = "_certs")] #[derive(Default)] pub(crate) struct ClientAuth { pub(crate) verifier: Option>, @@ -1700,11 +1635,9 @@ pub(crate) struct ClientAuth { /// verified against. Listing an old root is never wrong: lineage names a root only /// when the leaf provably descends from it. The set grows only with the /// operator's own root files. -#[cfg(feature = "_certs")] #[derive(Clone, Debug, Default)] struct ClientRoots(Arc]>>>); -#[cfg(feature = "_certs")] impl ClientRoots { fn current(&self) -> Arc<[CertificateDer<'static>]> { self.0.read().unwrap_or_else(std::sync::PoisonError::into_inner).clone() @@ -1719,7 +1652,6 @@ impl ClientRoots { } } -#[cfg(feature = "_certs")] impl rustls::server::ResolvesServerCert for Serving { fn resolve(&self, hello: rustls::server::ClientHello<'_>) -> Option> { // Keeping this owner in the TLS config also keeps its reload watcher alive. @@ -1730,7 +1662,6 @@ impl rustls::server::ResolvesServerCert for Serving { } } -#[cfg(feature = "_certs")] impl Serve { /// Serve this resolver's current certificate with the listen policy's client authentication. /// @@ -1738,24 +1669,19 @@ impl Serve { /// usual verification and reload behavior. External certificates have no reported fingerprints. pub fn resolver(resolver: Arc, policy: &Listen) -> Result { policy.refuse_deprecated()?; - #[cfg(feature = "_certs")] let in_memory = policy.identity.is_some(); - #[cfg(not(feature = "_certs"))] - let in_memory = false; if !policy.cert.is_empty() || !policy.key.is_empty() || !policy.generate.is_empty() || in_memory { return Err(Error::ConflictingResolver); } let provider = crypto::provider()?; let certs = Arc::new(ServeCerts::new(provider.clone())); let ClientAuth { verifier, roots } = policy.client_auth(provider)?; - #[cfg(feature = "watch")] let reload = Reload::spawn(certs.clone(), policy.clone())?; Ok(Self(Arc::new(Serving { certs, resolver: Some(resolver), verifier, roots, - #[cfg(feature = "watch")] _reload: reload, }))) } @@ -1798,7 +1724,6 @@ impl Serve { } } - #[cfg(feature = "_transport")] pub(crate) fn client_auth(&self) -> bool { self.0.verifier.is_some() } @@ -1814,13 +1739,12 @@ impl Serve { pub struct PeerIdentity { chain: Vec>, /// Every root the accepting listener had trusted when it built this. - #[cfg(feature = "_certs")] roots: Arc<[CertificateDer<'static>]>, } impl PeerIdentity { /// A chain with no listener roots behind it. - #[cfg(all(test, feature = "_transport"))] + #[cfg(test)] pub(crate) fn from_chain(chain: Vec>) -> Self { Self { chain, @@ -1880,7 +1804,6 @@ impl PeerIdentity { /// /// Fails when the chain is empty or exhausts path building's fixed budget of /// signature checks, which a chain a CA issued never comes near. - #[cfg(feature = "_certs")] pub fn lineage(&self) -> Result> { use std::cell::RefCell; @@ -1967,14 +1890,9 @@ impl PeerIdentity { } } -/// The certificates a server is currently serving. -/// -/// The chains themselves are kept only where a resolver picks between them per -/// SNI, so a build without server-side certificate handling carries fingerprints -/// alone. +/// The certificates a server is currently serving, and their fingerprints. #[derive(Debug, Default)] pub(crate) struct Info { - #[cfg(feature = "_certs")] pub(crate) certs: Vec>, pub(crate) fingerprints: Vec, } @@ -1995,7 +1913,6 @@ 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())), @@ -2025,7 +1942,6 @@ impl Certificates { .map(|cert| hex::encode(crypto::sha256(cert.as_ref()))) .collect(); Ok(Self::new(Arc::new(RwLock::new(Info { - #[cfg(feature = "_certs")] certs: Vec::new(), fingerprints, })))) @@ -2045,13 +1961,11 @@ impl Certificates { } /// Delegates each server-certificate check to the latest valid root verifier. -#[cfg(feature = "watch")] #[derive(Debug)] struct ReloadingServerVerifier { inner: Reloading, } -#[cfg(feature = "watch")] impl ReloadingServerVerifier { fn new( paths: &[PathBuf], @@ -2064,7 +1978,6 @@ impl ReloadingServerVerifier { } } -#[cfg(feature = "watch")] impl rustls::client::danger::ServerCertVerifier for ReloadingServerVerifier { fn verify_server_cert( &self, @@ -2107,13 +2020,11 @@ impl rustls::client::danger::ServerCertVerifier for ReloadingServerVerifier { } /// Delegates each client-certificate check to the latest valid root verifier. -#[cfg(all(feature = "watch", feature = "_certs"))] #[derive(Debug)] struct ReloadingClientVerifier { inner: Reloading, } -#[cfg(all(feature = "watch", feature = "_certs"))] impl ReloadingClientVerifier { fn new( paths: &[PathBuf], @@ -2126,7 +2037,6 @@ impl ReloadingClientVerifier { } } -#[cfg(all(feature = "watch", feature = "_certs"))] impl rustls::server::danger::ClientCertVerifier for ReloadingClientVerifier { fn offer_client_auth(&self) -> bool { self.inner.current().offer_client_auth() @@ -2226,21 +2136,18 @@ impl rustls::client::danger::ServerCertVerifier for NoCertificateVerification { /// The mirror of [`FingerprintVerifier`] on the accept side, with one difference /// that matters: the allowed set is read per handshake rather than fixed when the /// listener was built, because a mesh learns its members while it runs. -#[cfg(feature = "_certs")] #[derive(Debug)] pub(crate) struct PeerVerifier { provider: crypto::Provider, peers: Peers, } -#[cfg(feature = "_certs")] impl PeerVerifier { pub fn new(provider: crypto::Provider, peers: Peers) -> Self { Self { provider, peers } } } -#[cfg(feature = "_certs")] impl rustls::server::danger::ClientCertVerifier for PeerVerifier { fn root_hint_subjects(&self) -> &[rustls::DistinguishedName] { // Self-signed identities chain to nothing, so there is no issuer to hint at. @@ -2348,7 +2255,6 @@ impl rustls::client::danger::ServerCertVerifier for FingerprintVerifier { } #[cfg(test)] -#[cfg(feature = "quic")] mod tests { #[tokio::test] async fn resolved_config_keeps_reload_owner_alive() { @@ -2430,7 +2336,6 @@ mod tests { } /// Outside a runtime, file-backed certificates still reload, on the fallback runtime. - #[cfg(feature = "watch")] #[test] fn loading_outside_a_runtime_watches_on_the_fallback() { let dir = tempfile::tempdir().unwrap(); @@ -2460,7 +2365,6 @@ mod tests { .expect("file-backed certificates reload on the fallback runtime"); } - #[cfg(feature = "watch")] #[tokio::test] async fn an_unwatchable_identity_refuses_startup() { let dir = tempfile::tempdir().unwrap(); @@ -2529,7 +2433,6 @@ mod tests { use super::*; use rustls::client::danger::ServerCertVerifier; use rustls::pki_types::ServerName; - #[cfg(feature = "watch")] use rustls::server::danger::ClientCertVerifier; fn self_signed() -> CertificateDer<'static> { @@ -2565,7 +2468,6 @@ mod tests { ); } - #[cfg(feature = "quic")] #[test] fn peer_expiry_saturates_to_the_wall_range() { let last = kio::clock::Wall::UNIX_EPOCH.saturating_add(std::time::Duration::MAX); @@ -2690,7 +2592,6 @@ mod tests { /// keeps its task, an OS directory watch, and the certificate keys alive for the /// rest of the process. The `Arc` is the observable half: while the task lives it /// holds one, so a `Weak` that still upgrades is a watcher that never stopped. - #[cfg(all(feature = "watch", feature = "quic"))] #[tokio::test] async fn dropping_the_reload_guard_stops_the_watcher() { let key = rind_rcgen::KeyPair::generate(&rcgen::PKCS_ECDSA_P256_SHA256).unwrap(); @@ -2841,7 +2742,6 @@ mod tests { /// A resumed handshake skips certificate verification, so a listener with a /// live peer set must disable resumption for removals to take effect. - #[cfg(all(feature = "watch", feature = "quic"))] #[test] fn removed_peers_cannot_resume() { let server_identity = Identity::generate(["localhost"]).unwrap(); @@ -2875,7 +2775,6 @@ mod tests { } /// A plain-TLS embedder receives a working config from the shared identity. - #[cfg(feature = "quic")] #[tokio::test] async fn served_config_handshakes() { let server = Listen { @@ -2895,7 +2794,6 @@ mod tests { /// Every config built from one identity asks an external resolver per handshake, /// so a certificate it swaps in reaches each listener without a rebuild. - #[cfg(all(feature = "watch", feature = "quic"))] #[tokio::test] async fn external_resolver_answers_every_handshake() { #[derive(Debug)] @@ -2925,7 +2823,6 @@ mod tests { } /// The external certificate source must retain the listener's live peer allowlist. - #[cfg(all(feature = "watch", feature = "quic"))] #[test] fn external_resolver_retains_live_client_auth() { #[derive(Debug)] @@ -2967,7 +2864,6 @@ mod tests { } /// An external resolver retains CA verification of presented client certificates. - #[cfg(all(feature = "watch", feature = "quic"))] #[tokio::test] async fn external_resolver_retains_client_roots() { let (ca, server_cert, server_key, client_cert, client_key) = signed_certificates(); @@ -3288,7 +3184,6 @@ mod tests { (file, path) } - #[cfg(all(feature = "watch", feature = "quic"))] fn signed_certificates() -> ( String, CertificateDer<'static>, @@ -3340,7 +3235,6 @@ mod tests { ) } - #[cfg(all(feature = "watch", feature = "quic"))] fn handshake_kinds( client: Arc, server: Arc, @@ -3372,7 +3266,6 @@ mod tests { panic!("TLS handshake did not settle"); } - #[cfg(all(feature = "watch", feature = "quic"))] #[test] fn reloadable_roots_disable_session_resumption() { use std::io::Write; @@ -3444,7 +3337,6 @@ mod tests { /// Write a fresh self-signed client certificate and its key as `cert.pem` and /// `key.pem` in `dir`, returning both paths. - #[cfg(all(feature = "watch", feature = "quic"))] fn write_client_pair(dir: &Path, name: &str) -> (PathBuf, PathBuf) { let signing = rind_rcgen::KeyPair::generate(&rcgen::PKCS_ECDSA_P256_SHA256).unwrap(); let mut params = rcgen::CertificateParams::new(vec![name.to_string()]).unwrap(); @@ -3459,7 +3351,6 @@ mod tests { (cert, key) } - #[cfg(all(feature = "watch", feature = "quic"))] #[test] fn client_certificate_reloads_for_new_handshakes() { // A dedicated directory, not `/tmp`: see `reloadable_client_roots_disable_server_resumption`. @@ -3505,7 +3396,6 @@ mod tests { assert!(matches!(error, Error::LoadKey { .. }), "{error:?}"); } - #[cfg(all(feature = "watch", feature = "quic"))] #[test] fn reloadable_client_roots_disable_server_resumption() { let (ca_a, server_cert, server_key, client_cert, client_key) = signed_certificates(); @@ -3584,7 +3474,6 @@ mod tests { assert!(handshake_kinds(reloadable_client, reloadable).is_err()); } - #[cfg(all(feature = "watch", feature = "quic"))] #[test] fn custom_roots_reload_for_new_client_and_server_handshakes() { let (ca_a, server_a, _, client_a, _) = signed_certificates(); @@ -3655,7 +3544,6 @@ mod tests { } /// A root file holding several CAs trusts every one of them, not only the first. - #[cfg(all(feature = "watch", feature = "quic"))] #[test] fn a_root_bundle_is_loaded_whole() { let (unrelated, _, _, _, _) = signed_certificates(); @@ -3710,7 +3598,6 @@ mod tests { // ── ServeCerts ────────────────────────────────────────────────────── -#[cfg(feature = "_certs")] #[derive(Debug)] pub(crate) struct ServeCerts { pub info: Arc>, @@ -3719,7 +3606,6 @@ pub(crate) struct ServeCerts { generated: RwLock>>, } -#[cfg(feature = "_certs")] impl ServeCerts { pub fn new(provider: crypto::Provider) -> Self { Self { @@ -3735,10 +3621,7 @@ impl ServeCerts { } // An in-memory identity is a certificate source like the other two, so a // listener configured with only that one still has something to serve. - #[cfg(feature = "_certs")] let in_memory = config.identity.is_some(); - #[cfg(not(feature = "_certs"))] - let in_memory = false; if config.cert.is_empty() && config.generate.is_empty() && !in_memory { return Err(Error::NoCertSource); } @@ -3755,7 +3638,6 @@ impl ServeCerts { certs.push(self.generated(&config.generate)?); } - #[cfg(feature = "_certs")] if let Some(identity) = &config.identity { certs.push(identity.certified()); } @@ -3833,7 +3715,6 @@ impl ServeCerts { } } -#[cfg(feature = "_certs")] impl rustls::server::ResolvesServerCert for ServeCerts { fn resolve(&self, client_hello: rustls::server::ClientHello<'_>) -> Option> { Some(self.select(client_hello.server_name())?.rustls.clone()) @@ -3848,7 +3729,6 @@ impl rustls::server::ResolvesServerCert for ServeCerts { /// its own, so a listener that goes away without this leaves the task, the keys it /// holds, and an OS directory watch behind. An embedder that builds listeners /// repeatedly in one process would accumulate all three. -#[cfg(all(feature = "watch", feature = "_certs"))] #[derive(Debug)] pub(crate) struct Reload { /// Named for the drop alone: nothing reads it, and losing it stops the watcher. @@ -3856,7 +3736,6 @@ pub(crate) struct Reload { _task: Option, } -#[cfg(all(feature = "watch", feature = "_certs"))] impl Reload { /// Start watching the file-backed pairs in `config`, if it has any. /// @@ -3899,7 +3778,6 @@ impl Reload { /// Reacting to the filesystem means cert-manager, Kubernetes secret mounts, and /// `mv`-into-place rotate certs with no external signal. [`Reload::spawn`] owns /// registering the watch and is the only caller. -#[cfg(all(feature = "watch", feature = "_certs"))] async fn reload_certs(mut watcher: crate::watch::Files, certs: Arc, tls_config: Listen) { loop { watcher.changed().await; @@ -4003,7 +3881,6 @@ mod legacy_tests { /// The accept side, where a dropped `--server-tls-root` takes the mTLS client /// CAs with it and leaves the listener accepting unauthenticated peers. /// moq-cli's `export hls` flattens this type directly, so it is a live path. - #[cfg(feature = "quic")] #[test] fn the_server_builders_refuse_a_released_spelling() { let tls = parse(&["--server-tls-root", "/tmp/ca.pem"]).listen; diff --git a/rs/moq-tokio/src/websocket.rs b/rs/moq-tokio/src/websocket.rs index 535dd36fe21..b1090e6f999 100644 --- a/rs/moq-tokio/src/websocket.rs +++ b/rs/moq-tokio/src/websocket.rs @@ -192,7 +192,6 @@ fn won_key(url: &Url) -> Result<(String, u16)> { } /// Forget that WebSocket won for `url`, giving QUIC its head start again. -#[cfg(feature = "quic")] pub(crate) fn forget(url: &Url) { if let Ok(key) = won_key(url) { WEBSOCKET_WON.lock().unwrap().remove(&key); @@ -200,13 +199,13 @@ pub(crate) fn forget(url: &Url) { } /// Record that WebSocket won for `url`, as a fallback dial that lands does. -#[cfg(all(test, feature = "quic"))] +#[cfg(test)] pub(crate) fn remember(url: &Url) { WEBSOCKET_WON.lock().unwrap().insert(won_key(url).unwrap()); } /// Whether the next dial to `url` skips QUIC's head start. -#[cfg(all(test, feature = "quic"))] +#[cfg(test)] pub(crate) fn won(url: &Url) -> bool { won_key(url).is_ok_and(|key| WEBSOCKET_WON.lock().unwrap().contains(&key)) } @@ -325,9 +324,7 @@ pub struct Resolved { pub delay: time::Duration, } -/// The fallback arm of the QUIC-vs-WebSocket race, so only compiled when there is a -/// QUIC dial to race against. A WebSocket-only build calls [`connect`] directly. -#[cfg(feature = "quic")] +/// The fallback arm of the QUIC-vs-WebSocket race. pub(crate) async fn race_handle( config: &Config, tls: &rustls::ClientConfig, diff --git a/rs/moq-tokio/src/worker/group.rs b/rs/moq-tokio/src/worker/group.rs index 1dc6936b920..4b9a0fea430 100644 --- a/rs/moq-tokio/src/worker/group.rs +++ b/rs/moq-tokio/src/worker/group.rs @@ -259,7 +259,6 @@ mod tests { use super::*; #[test] - #[cfg(feature = "tcp")] fn stream_bind_does_not_suppress_worker_quic() { let mut listen = crate::listen::Config::default(); listen.tcp.bind = Some("127.0.0.1:0".parse().unwrap()); diff --git a/rs/moq-tokio/src/worker/mod.rs b/rs/moq-tokio/src/worker/mod.rs index 5b908f0901d..3192e0fe10e 100644 --- a/rs/moq-tokio/src/worker/mod.rs +++ b/rs/moq-tokio/src/worker/mod.rs @@ -20,10 +20,8 @@ // Everything but the knobs: a group binds and serves QUIC, so it needs a backend // to bind with. -#[cfg(feature = "quic")] mod group; -#[cfg(feature = "quic")] pub use group::{Group, Member, Spawner, Workers}; /// How many QUIC workers to run, and whether to pin them. diff --git a/rs/moq-tokio/tests/integration/backend.rs b/rs/moq-tokio/tests/integration/backend.rs index f5ee32f7e4e..1ae7ed34820 100644 --- a/rs/moq-tokio/tests/integration/backend.rs +++ b/rs/moq-tokio/tests/integration/backend.rs @@ -10,7 +10,6 @@ fn timed() -> moq_net::track::Info { const TIMEOUT: Duration = Duration::from_secs(10); /// Inputs for [`connect_test`]. -#[cfg(feature = "quic")] struct ConnectTest<'a> { /// URL scheme to dial (`moqt` for raw QUIC, `https` for WebTransport). scheme: &'a str, @@ -39,7 +38,6 @@ struct ConnectTest<'a> { /// /// Dials `localhost`, so the client sends an SNI. Use [`no_sni_test`] to cover /// the SNI-less path. -#[cfg(feature = "quic")] async fn backend_test(scheme: &str) { connect_test(ConnectTest { scheme, @@ -60,7 +58,6 @@ async fn backend_test(scheme: &str) { /// Raw QUIC (`moqt`/`moql`) has no request URI, so the whole request target has to /// ride the SETUP; WebTransport carries it in the CONNECT URL instead. Either way the /// server reports the same route and query through [`moq_tokio::server::Request`]. -#[cfg(feature = "quic")] async fn path_test(scheme: &str) { connect_test(ConnectTest { scheme, @@ -80,7 +77,6 @@ async fn path_test(scheme: &str) { /// in the server name). Raw QUIC has no in-band request URL, so this exercises /// the accept path with an empty server name, which must still establish rather /// than reject. Binds the loopback IP directly to avoid dual-stack flakiness. -#[cfg(feature = "quic")] async fn no_sni_test(scheme: &str) { connect_test(ConnectTest { scheme, @@ -98,7 +94,6 @@ async fn no_sni_test(scheme: &str) { /// Publish a broadcast on the server bound to `bind`, subscribe on a client that /// dials `authority`, and verify the data arrives over the requested scheme. -#[cfg(feature = "quic")] async fn connect_test(config: ConnectTest<'_>) { let ConnectTest { scheme, @@ -227,7 +222,6 @@ async fn connect_test(config: ConnectTest<'_>) { /// Write a self-signed PEM cert + key for `name` to `dir`, prefixed by `stem`. /// /// Returns the two paths, in the order the `cert` and `key` lists want them. -#[cfg(feature = "quic")] fn write_self_signed(dir: &std::path::Path, stem: &str, name: &str) -> (std::path::PathBuf, std::path::PathBuf) { use std::io::Write; @@ -263,7 +257,6 @@ fn write_self_signed(dir: &std::path::Path, stem: &str, name: &str) -> (std::pat /// when the server picked the certificate the SNI asked for. Without SNI /// selection every client would get the first configured certificate, so the /// `alt.localhost` pin below would never match. -#[cfg(feature = "quic")] async fn sni_test() { let dir = tempfile::tempdir().expect("tempdir"); let (first_cert, first_key) = write_self_signed(dir.path(), "first", "localhost"); @@ -320,7 +313,6 @@ async fn sni_test() { } /// A generated certificate joins the file-backed ones rather than replacing them. -#[cfg(feature = "quic")] async fn cert_sources_test() { let dir = tempfile::tempdir().expect("tempdir"); let (cert, key) = write_self_signed(dir.path(), "server", "localhost"); @@ -345,7 +337,6 @@ async fn cert_sources_test() { /// Rotate the certificate files under a running listener and assert the served /// set follows, without the listener being rebuilt. -#[cfg(feature = "quic")] async fn reload_test() { let logs = crate::Logs::capture(); let dir = tempfile::tempdir().expect("tempdir"); @@ -391,7 +382,6 @@ async fn reload_test() { /// Generate a CA, a server cert + key, and a client cert + key (all PEM, the /// leaf certs signed by the CA) written to a tempdir. Returns the dir plus the /// five paths so the caller can wire them into the TLS configs. -#[cfg(feature = "quic")] fn generate_mtls_certs() -> (tempfile::TempDir, MtlsPaths) { use rcgen::{BasicConstraints, CertificateParams, DnType, ExtendedKeyUsagePurpose, IsCa, Issuer, KeyUsagePurpose}; use rind_rcgen::KeyPair; @@ -464,7 +454,6 @@ fn generate_mtls_certs() -> (tempfile::TempDir, MtlsPaths) { } /// Filesystem paths to the PEM material produced by [`generate_mtls_certs`]. -#[cfg(feature = "quic")] struct MtlsPaths { ca: std::path::PathBuf, server_cert: std::path::PathBuf, @@ -475,7 +464,6 @@ struct MtlsPaths { /// Connect with a client certificate signed by a CA the server trusts, and /// assert the server observes the validated peer certificate via mTLS. -#[cfg(feature = "quic")] async fn mtls_test(scheme: &str, reject: bool) { let (_dir, paths) = generate_mtls_certs(); @@ -552,7 +540,6 @@ async fn mtls_test(scheme: &str, reject: bool) { /// A client that closes before its runtime stops tells the server at once, instead of /// leaving it to the idle timeout, which is what a process exiting on a signal does. -#[cfg(feature = "quic")] #[tokio::test] async fn quic_client_close_reaches_server() { // An idle timeout inside TIMEOUT would hide a lost close. @@ -613,7 +600,6 @@ async fn quic_client_close_reaches_server() { /// A client that finishes its track and closes before its runtime stops still delivers /// the queued group and the track's finish, retaining its token-only grant through the drain. -#[cfg(feature = "quic")] #[tokio::test] async fn quic_client_close_drains_finished_track() { // Several congestion windows, so the token must cover data still in flight @@ -754,7 +740,6 @@ async fn quic_client_close_drains_finished_track() { /// A GOAWAY leaves the old session serving its subscriptions after the replacement /// connects, and a close then drains that predecessor too rather than dropping it. -#[cfg(feature = "quic")] #[tokio::test] async fn quic_client_close_drains_migrated_predecessor() { // Several congestion windows, so it is still in flight when the close starts. @@ -902,7 +887,6 @@ async fn quic_client_close_drains_migrated_predecessor() { /// A close cuts a predecessor that cannot drain off at its handover deadline, /// rather than holding it for the full one second close window. -#[cfg(feature = "quic")] #[tokio::test] async fn quic_client_close_keeps_predecessor_handover() { let quic = moq_tokio::quic::Config::default(); @@ -1009,61 +993,51 @@ async fn quic_client_close_keeps_predecessor_handover() { ); } -#[cfg(feature = "quic")] #[tokio::test] async fn quic_raw_quic() { backend_test("moqt").await; } -#[cfg(feature = "quic")] #[tokio::test] async fn quic_raw_quic_no_sni() { no_sni_test("moqt").await; } -#[cfg(feature = "quic")] #[tokio::test] async fn quic_raw_quic_path() { path_test("moqt").await; } -#[cfg(feature = "quic")] #[tokio::test] async fn quic_raw_quic_moql_path() { path_test("moql").await; } -#[cfg(feature = "quic")] #[tokio::test] async fn quic_webtransport_path() { path_test("https").await; } -#[cfg(feature = "quic")] #[tokio::test] async fn quic_webtransport() { backend_test("https").await; } -#[cfg(feature = "quic")] #[tokio::test] async fn quic_mtls() { mtls_test("https", false).await; } -#[cfg(feature = "quic")] #[tokio::test] async fn quic_sni_certificate() { sni_test().await; } -#[cfg(feature = "quic")] #[tokio::test] async fn quic_cert_sources() { cert_sources_test().await; } -#[cfg(feature = "quic")] #[tokio::test] async fn quic_cert_reload() { reload_test().await; @@ -1076,7 +1050,7 @@ async fn quic_cert_reload() { /// /// Both ends write into one directory, so this covers the client and server paths /// at once. Each endpoint writes one file. -#[cfg(all(feature = "qlog", feature = "quic"))] +#[cfg(feature = "qlog")] async fn qlog_test(scheme: &str) -> Vec { let dir = tempfile::tempdir().expect("failed to create tempdir"); @@ -1129,7 +1103,7 @@ async fn qlog_test(scheme: &str) -> Vec { traces } -#[cfg(all(feature = "qlog", feature = "quic"))] +#[cfg(feature = "qlog")] #[tokio::test] async fn quic_qlog() { let traces = qlog_test("moqt").await; @@ -1161,7 +1135,6 @@ async fn connect_once( /// /// The size is the point: a frame that fits inside one window would pass whether or /// not the setting ever reached the backend. -#[cfg(feature = "quic")] async fn window_test(scheme: &str) { let mut quic = moq_tokio::quic::Config::default(); quic.receive_window = Some(moq_net::transport::MIN_RECEIVE_WINDOW); @@ -1184,7 +1157,6 @@ async fn window_test(scheme: &str) { .await; } -#[cfg(feature = "quic")] #[tokio::test] async fn quic_windows() { window_test("moqt").await; diff --git a/rs/moq-tokio/tests/integration/close_code.rs b/rs/moq-tokio/tests/integration/close_code.rs index 08016bcc581..640c3ec4bfd 100644 --- a/rs/moq-tokio/tests/integration/close_code.rs +++ b/rs/moq-tokio/tests/integration/close_code.rs @@ -3,8 +3,6 @@ //! Each case runs several fresh connections, since the losses this guards against were //! races between the peer's close and whatever the transport reported next. -#![cfg(all(feature = "quic", feature = "websocket"))] - use std::time::Duration; const CODE: u16 = 4011; diff --git a/rs/moq-tokio/tests/integration/datagram_delivery.rs b/rs/moq-tokio/tests/integration/datagram_delivery.rs index d5b69e90f7e..7cf9f87adec 100644 --- a/rs/moq-tokio/tests/integration/datagram_delivery.rs +++ b/rs/moq-tokio/tests/integration/datagram_delivery.rs @@ -6,8 +6,6 @@ //! the work: the in-memory `session_delivery_datagram` benchmark owns protocol CPU, which //! here would mix with QUIC, the shaper and the kernel. -#![cfg(feature = "quic")] - use std::{sync::Arc, time::Duration}; use bytes::Bytes; diff --git a/rs/moq-tokio/tests/integration/fresh_port.rs b/rs/moq-tokio/tests/integration/fresh_port.rs index a12929352e1..3be61089859 100644 --- a/rs/moq-tokio/tests/integration/fresh_port.rs +++ b/rs/moq-tokio/tests/integration/fresh_port.rs @@ -1,5 +1,4 @@ //! A permanently dropped UDP flow must not strand a reconnecting client. -#![cfg(feature = "quic")] use std::{ collections::{HashMap, HashSet}, @@ -100,10 +99,7 @@ fn client(bind: SocketAddr) -> Client { config.timeout = Some(DIAL.into()); config.backoff.initial = Some(Duration::ZERO.into()); config.backoff.timeout = Some(Duration::ZERO.into()); - #[cfg(feature = "websocket")] - { - config.websocket.enabled = Some(false); - } + config.websocket.enabled = Some(false); config.init(Default::default()).unwrap() } diff --git a/rs/moq-tokio/tests/integration/migrate.rs b/rs/moq-tokio/tests/integration/migrate.rs index 6a094e5be93..b2aff6d1d91 100644 --- a/rs/moq-tokio/tests/integration/migrate.rs +++ b/rs/moq-tokio/tests/integration/migrate.rs @@ -1,8 +1,6 @@ //! A GOAWAY migration closes the old session once nothing flows on it, rather than holding //! it to the handover cap. -#![cfg(feature = "tcp")] - use std::time::Duration; /// The only version whose routes carry the epoch that lets a subscription resume across diff --git a/rs/moq-tokio/tests/integration/receive_credit.rs b/rs/moq-tokio/tests/integration/receive_credit.rs index ac225ca2361..05682f7b3e8 100644 --- a/rs/moq-tokio/tests/integration/receive_credit.rs +++ b/rs/moq-tokio/tests/integration/receive_credit.rs @@ -10,8 +10,6 @@ //! Some runs go through a bufferbloated path instead of loopback, so a sender held back by //! a slow link and a deep queue is shown not to look like a stuck window. -#![cfg(feature = "quic")] - use std::{process::Stdio, sync::Arc, time::Duration}; use bytes::Bytes; diff --git a/rs/moq-tokio/tests/integration/reconnect.rs b/rs/moq-tokio/tests/integration/reconnect.rs index 482c51ef086..9ddba9e8531 100644 --- a/rs/moq-tokio/tests/integration/reconnect.rs +++ b/rs/moq-tokio/tests/integration/reconnect.rs @@ -3,8 +3,6 @@ //! Dials over plain TCP (`tcp://`): no TLS material and no QUIC handshake, so the assertions are //! about the loop rather than about how a particular backend connects. -#![cfg(feature = "tcp")] - use std::time::Duration; /// A client whose reconnect loop escalates fast enough to assert on inside a test. diff --git a/rs/moq-tokio/tests/integration/reset_secret.rs b/rs/moq-tokio/tests/integration/reset_secret.rs index 1384fcaddd2..979cc50003d 100644 --- a/rs/moq-tokio/tests/integration/reset_secret.rs +++ b/rs/moq-tokio/tests/integration/reset_secret.rs @@ -5,8 +5,6 @@ //! The predecessor "crashes" by dropping its runtime, which stops every task before //! it can send a CONNECTION_CLOSE, and the successor binds the same port. -#![cfg(feature = "quic")] - use std::{path::PathBuf, sync::Arc, time::Duration}; use moq_tokio::quic::driver; diff --git a/rs/moq-tokio/tests/integration/runtime.rs b/rs/moq-tokio/tests/integration/runtime.rs index 949b3dc938a..4b0f14ae158 100644 --- a/rs/moq-tokio/tests/integration/runtime.rs +++ b/rs/moq-tokio/tests/integration/runtime.rs @@ -5,7 +5,7 @@ //! runtime, so each poll that needs tokio has to find the fallback itself. //! //! Unix with the default transports, since it reads one broadcast over each of them. -#![cfg(all(unix, feature = "quic", feature = "websocket", feature = "uds"))] +#![cfg(unix)] use futures::executor::block_on; diff --git a/rs/moq-tokio/tests/integration/sim.rs b/rs/moq-tokio/tests/integration/sim.rs index bbdb6550330..a4adf06dbc7 100644 --- a/rs/moq-tokio/tests/integration/sim.rs +++ b/rs/moq-tokio/tests/integration/sim.rs @@ -6,8 +6,6 @@ //! bottleneck runs below the track's bitrate behind a deep but finite queue, and the run checks //! that the queue overflowed, so the congestion loss came from the sender filling it. -#![cfg(feature = "quic")] - use std::{net::SocketAddr, sync::Arc, time::Duration}; use kio::clock::Instant; diff --git a/rs/moq-tokio/tests/integration/sim_client.rs b/rs/moq-tokio/tests/integration/sim_client.rs index 5702ffd604f..da48dff1418 100644 --- a/rs/moq-tokio/tests/integration/sim_client.rs +++ b/rs/moq-tokio/tests/integration/sim_client.rs @@ -3,8 +3,6 @@ //! dial, from the Happy Eyeballs race through the reconnect loop, runs with no sockets and no //! host clock. -#![cfg(feature = "quic")] - use std::{ net::{IpAddr, Ipv4Addr, SocketAddr}, time::Duration, diff --git a/rs/moq-tokio/tests/integration/stream_code.rs b/rs/moq-tokio/tests/integration/stream_code.rs index d6ef659383a..24ada662720 100644 --- a/rs/moq-tokio/tests/integration/stream_code.rs +++ b/rs/moq-tokio/tests/integration/stream_code.rs @@ -6,8 +6,6 @@ //! subscription it never made with STOP_SENDING, and the client reads that code off the //! wire. moq-transport codes take the same raw session. -#![cfg(feature = "quic")] - use std::{sync::Arc, time::Duration}; use moq_tokio::quic::driver; diff --git a/rs/moq-tokio/tests/integration/tokens.rs b/rs/moq-tokio/tests/integration/tokens.rs index e3883fa87ed..9589e83817e 100644 --- a/rs/moq-tokio/tests/integration/tokens.rs +++ b/rs/moq-tokio/tests/integration/tokens.rs @@ -2,8 +2,6 @@ //! negotiated version carries one, and in the URL query where it might not. A refused //! credential is dialed again only once the client has a new one. -#![cfg(feature = "quic")] - use std::{sync::Arc, time::Duration}; /// What the server saw on one handshake. diff --git a/rs/moq-tokio/tests/integration/worker.rs b/rs/moq-tokio/tests/integration/worker.rs index fded5d28bf4..4c42809dfe6 100644 --- a/rs/moq-tokio/tests/integration/worker.rs +++ b/rs/moq-tokio/tests/integration/worker.rs @@ -3,7 +3,7 @@ //! Linux-only, because the mode is: every worker binds the listen address with //! `SO_REUSEPORT`, and no other platform load-balances a unicast UDP port across //! the group. -#![cfg(all(target_os = "linux", feature = "quic"))] +#![cfg(target_os = "linux")] use std::net::UdpSocket; @@ -174,10 +174,7 @@ async fn stopping_the_group_closes_its_sessions() { let mut connect = moq_tokio::connect::Config::default(); connect.tls.fingerprint = fingerprints; - #[cfg(feature = "websocket")] - { - connect.websocket.enabled = Some(false); - } + connect.websocket.enabled = Some(false); // Far past the wait below, so only a close on the wire can end the session. let mut quic = moq_tokio::quic::Config::default(); quic.idle_timeout = Some((std::time::Duration::from_secs(600)).into()); @@ -773,7 +770,6 @@ async fn dropping_the_group_with_work_in_flight_stops() { } /// Every member's next fresh handshake uses the fingerprint exposed by the group. -#[cfg(feature = "watch")] #[tokio::test] async fn rotated_identity_reaches_every_worker() { let _ = rind_rustls::default_provider().unwrap().install_default(); @@ -825,10 +821,7 @@ async fn rotated_identity_reaches_every_worker() { // Fresh client endpoints make independent handshakes, without session resumption. let mut config = moq_tokio::connect::Config::default(); config.tls.fingerprint = expected.clone(); - #[cfg(feature = "websocket")] - { - config.websocket.enabled = Some(false); - } + config.websocket.enabled = Some(false); let client = config.init(Default::default()).unwrap().with_reconnect(false); let url: url::Url = format!("https://{addr}/").parse().unwrap(); let session = client diff --git a/rs/moq-transcode/Cargo.toml b/rs/moq-transcode/Cargo.toml index 70b66307606..9dd47d690e9 100644 --- a/rs/moq-transcode/Cargo.toml +++ b/rs/moq-transcode/Cargo.toml @@ -49,7 +49,7 @@ criterion = { package = "bench-harness", path = "../bench-harness" } # `join_all`, so the ladder bench feeds every rung at once like the rung tasks do. futures = { workspace = true } kio = { workspace = true, features = ["manual", "runtime", "sim"] } -moq-tokio = { path = "../moq-tokio", default-features = false, features = ["quic", "websocket"] } +moq-tokio = { path = "../moq-tokio" } # The tests encode with OpenH264, the one encoder a GPU-less host has, so they # turn it on without making it a default of the library. moq-video = { path = "../moq-video", features = ["openh264"] } diff --git a/rs/moq-uring/Cargo.toml b/rs/moq-uring/Cargo.toml index 8edbf67bb63..cf980f733b5 100644 --- a/rs/moq-uring/Cargo.toml +++ b/rs/moq-uring/Cargo.toml @@ -76,7 +76,7 @@ libc = { workspace = true } moq-shaper = { path = "../moq-shaper" } # The control-message fuzz target's input format, which its tests replay. moq-sock = { path = "../moq-sock", features = ["fuzz"] } -moq-tokio = { path = "../moq-tokio", default-features = false, features = ["quic"] } +moq-tokio = { path = "../moq-tokio" } # Tests run workers on a manual clock. moq-uring = { path = ".", features = ["_manual"] } nix = { workspace = true } diff --git a/rs/moq-uring/README.md b/rs/moq-uring/README.md index 90f2e9272d3..c87490ca67f 100644 --- a/rs/moq-uring/README.md +++ b/rs/moq-uring/README.md @@ -93,7 +93,7 @@ Building without default features leaves the `quic` module out entirely. just rs uring ``` -`moq-relay` enables it with `--features io-uring`. +`moq-relay` always builds it on Linux and serves from it with `--runtime-io-uring`. The `qlog` feature turns on moq-quic's capture support. It writes one file per endpoint on the accept side and per dial on the connect side. diff --git a/rs/moq-webrtc/Cargo.toml b/rs/moq-webrtc/Cargo.toml index 70584906837..eeb7ec127e9 100644 --- a/rs/moq-webrtc/Cargo.toml +++ b/rs/moq-webrtc/Cargo.toml @@ -72,7 +72,7 @@ x509-cert = { workspace = true } [dev-dependencies] # The tests host their broadcasts on `origin::spawn`, and dial a session over TCP. -moq-tokio = { workspace = true, features = ["net", "tcp"] } +moq-tokio = { workspace = true } # The vendored stack's tests replay RTP captures. pcap-file = { workspace = true } serde_json = { workspace = true } diff --git a/rs/qmux/Cargo.toml b/rs/qmux/Cargo.toml index 675faa1cea7..130e1a16728 100644 --- a/rs/qmux/Cargo.toml +++ b/rs/qmux/Cargo.toml @@ -13,30 +13,24 @@ keywords = ["quic", "qmux", "websocket", "tcp", "multiplexing"] categories = ["network-programming", "asynchronous"] [features] -default = ["tls", "wss"] -tcp = ["tokio/net"] -tls = ["tcp", "dep:tokio-rustls", "dep:rustls"] -uds = ["tokio/net"] -ws = ["dep:tokio-tungstenite", "dep:futures"] # Exposes the `fuzz/` harness's target body and seeds through the `fuzz` module. -fuzz = ["tcp", "ws", "kio/sim", "tokio/io-util"] -wss = ["ws", "dep:rustls-native-certs", "dep:rustls", "tokio-tungstenite/rustls-tls-native-roots"] +fuzz = ["kio/sim", "tokio/io-util"] [dependencies] bytes = { workspace = true } -futures = { workspace = true, optional = true } +futures = { workspace = true } kio = { workspace = true, features = ["runtime"] } # rind's rustls provider and the `UnsupportedCpu` error the transport crates share. moq-crypto = { workspace = true, features = ["provider"] } moq-net = { workspace = true } # The stream state machine, shared with QUIC. `mux` drives it over a reliable transport. moq-quic = { workspace = true, features = ["mux"] } -rustls = { version = "0.23", default-features = false, optional = true } -rustls-native-certs = { workspace = true, optional = true } +rustls = { version = "0.23", default-features = false } +rustls-native-certs = { workspace = true } thiserror = { workspace = true } -tokio = { workspace = true } -tokio-rustls = { workspace = true, optional = true } -tokio-tungstenite = { workspace = true, features = ["connect", "handshake"], optional = true } +tokio = { workspace = true, features = ["net"] } +tokio-rustls = { workspace = true } +tokio-tungstenite = { workspace = true, features = ["connect", "handshake", "rustls-tls-native-roots"] } # `poll_read_buf`, which reads into a `BytesMut` without zeroing it first. tokio-util = { workspace = true, features = ["io"] } tracing = { workspace = true } @@ -66,22 +60,9 @@ name = "fuzz-seeds" path = "examples/fuzz-seeds.rs" required-features = ["fuzz"] -[[example]] -name = "interop-client" -required-features = ["tcp", "ws"] - -[[example]] -name = "interop-server" -required-features = ["tcp", "ws"] - -[[example]] -name = "bench" -required-features = ["tls", "wss"] - [[bench]] name = "receive" harness = false -required-features = ["tcp", "ws"] [lints] workspace = true diff --git a/rs/qmux/README.md b/rs/qmux/README.md index 8b4051b084b..9d94d1dcf6c 100644 --- a/rs/qmux/README.md +++ b/rs/qmux/README.md @@ -14,11 +14,9 @@ Every constructor returns the session with its `Driver`: one future that owns th socket, reads and writes it, and runs the session's timers. Spawn it on any executor, such as `tokio::spawn`; qmux spawns nothing and needs no Tokio runtime. -The default features are `tls` and `wss`. Opt into `tcp`, `uds`, or `ws` for the -corresponding unencrypted transport, or disable defaults when supplying your own. -Unix sockets require a Unix host. +Every transport is always compiled in; the `uds` module exists only on a Unix host. See the [API reference](https://docs.rs/qmux) and the [client and server examples](https://github.com/moq-dev/moq/tree/main/rs/qmux/examples). -`just rs test --manifest-path rs/qmux/Cargo.toml --features tcp,ws` runs its +`just rs test --manifest-path rs/qmux/Cargo.toml` runs its protocol tests and compatibility checks with qmux 0.6.3. diff --git a/rs/qmux/src/config.rs b/rs/qmux/src/config.rs index 568721dc07a..d15556452f8 100644 --- a/rs/qmux/src/config.rs +++ b/rs/qmux/src/config.rs @@ -114,7 +114,6 @@ impl Config { } /// This config with the out-of-band negotiation's outcome applied. - #[cfg(any(feature = "tls", feature = "ws"))] pub(crate) fn with_negotiated(self, version: Version, protocol: Option) -> Self { Self { version, diff --git a/rs/qmux/src/error.rs b/rs/qmux/src/error.rs index 47edb84a54d..92ad7d6e2f4 100644 --- a/rs/qmux/src/error.rs +++ b/rs/qmux/src/error.rs @@ -103,7 +103,6 @@ pub enum Error { UnsupportedCpu(#[from] moq_crypto::cpu::UnsupportedCpu), /// The WebSocket failed. - #[cfg(feature = "ws")] #[error(transparent)] WebSocket(WebSocketError), @@ -169,25 +168,21 @@ impl From for Error { } /// A WebSocket failure, opaque so the WebSocket implementation is not part of this API. -#[cfg(feature = "ws")] #[derive(Clone, Debug)] pub struct WebSocketError(Arc); -#[cfg(feature = "ws")] impl std::fmt::Display for WebSocketError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { self.0.fmt(f) } } -#[cfg(feature = "ws")] impl std::error::Error for WebSocketError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { self.0.source() } } -#[cfg(feature = "ws")] impl Error { /// Classify a WebSocket failure. pub(crate) fn websocket(err: tokio_tungstenite::tungstenite::Error) -> Self { @@ -226,7 +221,7 @@ impl moq_net::transport::Error for Error { } } -#[cfg(all(test, feature = "ws"))] +#[cfg(test)] mod tests { use super::*; use tokio_tungstenite::tungstenite::{self, http}; diff --git a/rs/qmux/src/lib.rs b/rs/qmux/src/lib.rs index df1de5e58a0..5646d3852f2 100644 --- a/rs/qmux/src/lib.rs +++ b/rs/qmux/src/lib.rs @@ -18,13 +18,13 @@ //! //! Everything tied to a specific transport lives in that transport's module: //! -//! | Module | Entry point | Feature | -//! | --- | --- | --- | -//! | `tcp` | `tcp::connect`, `tcp::accept` | `tcp` | -//! | `uds` | `uds::connect`, `uds::accept` | `uds` (Unix only) | -//! | `tls` | `tls::Client`, `tls::Server` | `tls` | -//! | `ws` | `ws::Client`, `ws::Server`, `ws::Upgraded` | `ws` | -//! | [`transport`] | [`transport::Transport`] | | +//! | Module | Entry point | +//! | --- | --- | +//! | [`tcp`] | [`tcp::connect`], [`tcp::accept`] | +//! | `uds` (Unix only) | `uds::connect`, `uds::accept` | +//! | [`tls`] | [`tls::Client`], [`tls::Server`] | +//! | [`ws`] | [`ws::Client`], [`ws::Server`], [`ws::Upgraded`] | +//! | [`transport`] | [`transport::Transport`] | //! //! For anything the built-in modules don't cover, wrap an //! [`AsyncRead`](tokio::io::AsyncRead) + [`AsyncWrite`](tokio::io::AsyncWrite) byte stream @@ -32,7 +32,6 @@ //! [`Session::connect`] / [`Session::accept`]. // ALPN/subprotocol negotiation is only used by the TLS and WebSocket transports. -#[cfg(any(feature = "tls", feature = "ws"))] mod alpn; mod config; mod driver; @@ -42,32 +41,28 @@ mod session; mod socket; /// Test support for the `fuzz/` harness: the target body and its seeds. -#[cfg(all(any(test, feature = "fuzz"), feature = "tcp", feature = "ws"))] +#[cfg(any(test, feature = "fuzz"))] pub mod fuzz; /// The transport abstraction, and the byte-stream implementation. pub mod transport; /// Plain TCP transport. -#[cfg(feature = "tcp")] pub mod tcp; /// Unix domain socket transport. -#[cfg(all(unix, feature = "uds"))] +#[cfg(unix)] pub mod uds; /// TLS over TCP transport. -#[cfg(feature = "tls")] pub mod tls; /// WebSocket transport. -#[cfg(feature = "ws")] pub mod ws; pub use config::{Config, Protocol}; pub use driver::Driver; pub use error::Error; -#[cfg(feature = "ws")] pub use error::WebSocketError; pub use moq_quic::connection::mux::Version; pub use moq_quic::{Limits, LimitsError}; @@ -77,5 +72,4 @@ pub use socket::TcpStats; pub use socket::{SharedSocketStats, SocketStats}; /// The largest frame draft-00 accepts, header included -#[cfg(any(feature = "tcp", all(unix, feature = "uds"), feature = "ws"))] const MAX_FRAME_SIZE: usize = 16384; diff --git a/rs/qmux/src/protocol.rs b/rs/qmux/src/protocol.rs index cb067ae065a..f170bd19801 100644 --- a/rs/qmux/src/protocol.rs +++ b/rs/qmux/src/protocol.rs @@ -1,13 +1,6 @@ use crate::Error; /// Validate that a protocol name contains only valid HTTP token characters (tchar). -#[cfg_attr( - not(any(feature = "ws", feature = "tcp", all(unix, feature = "uds"))), - expect( - dead_code, - reason = "only the byte-stream and WebSocket transports negotiate a protocol" - ) -)] pub(crate) fn validate_protocol(protocol: &str) -> Result<(), Error> { if protocol.is_empty() { return Err(Error::InvalidProtocol(protocol.to_string())); diff --git a/rs/qmux/src/session.rs b/rs/qmux/src/session.rs index 79b6f303fb9..cb94a3840f7 100644 --- a/rs/qmux/src/session.rs +++ b/rs/qmux/src/session.rs @@ -145,7 +145,6 @@ pub struct Session { /// The application protocol, cached at establishment so `protocol()` can borrow it. protocol: Option, /// What the TLS handshake learned about the peer, on a session over TLS. - #[cfg(feature = "tls")] pub(crate) tls: Option>, } @@ -198,7 +197,6 @@ impl Session { _guard: Arc::new(Guard(inner.clone())), inner: inner.clone(), protocol: config.negotiated_protocol(), - #[cfg(feature = "tls")] tls: None, }; Ok((session, Driver::new(inner, transport))) @@ -875,5 +873,5 @@ impl std::fmt::Debug for RecvLease<'_> { } } -#[cfg(all(test, any(feature = "tcp", all(unix, feature = "uds"))))] +#[cfg(test)] mod tests; diff --git a/rs/qmux/src/session/tests.rs b/rs/qmux/src/session/tests.rs index 73cd05434d0..f15d2eddbd5 100644 --- a/rs/qmux/src/session/tests.rs +++ b/rs/qmux/src/session/tests.rs @@ -574,7 +574,6 @@ async fn datagrams_need_records() { } /// A keep-alive that would expire before the first Pong could return is refused. -#[cfg(feature = "ws")] #[tokio::test] async fn websocket_keep_alive_needs_room_for_a_pong() { use tokio_tungstenite::{WebSocketStream, tungstenite::protocol::Role}; @@ -596,7 +595,6 @@ async fn websocket_keep_alive_needs_room_for_a_pong() { /// A sender that never runs out of output still sends its WebSocket keep-alive Pings, so /// a peer that has no keep-alive and sends nothing back does not let it time out. -#[cfg(feature = "ws")] #[tokio::test(start_paused = true)] async fn websocket_keep_alive_runs_during_continuous_output() { use tokio_tungstenite::{WebSocketStream, tungstenite::protocol::Role}; diff --git a/rs/qmux/src/transport.rs b/rs/qmux/src/transport.rs index b59c4453399..b0aaea8617f 100644 --- a/rs/qmux/src/transport.rs +++ b/rs/qmux/src/transport.rs @@ -69,15 +69,10 @@ pub trait Transport { } } -#[cfg(any(feature = "tcp", all(unix, feature = "uds")))] mod stream; -#[cfg(any(feature = "tcp", all(unix, feature = "uds")))] pub use stream::Stream; -#[cfg(any(feature = "tcp", all(unix, feature = "uds")))] pub(crate) use stream::build as build_stream_session; -#[cfg(feature = "ws")] mod websocket; // Public for `Driver>`, though callers never need to name it. -#[cfg(feature = "ws")] pub(crate) use websocket::WsTransport; diff --git a/rs/qmux/src/ws.rs b/rs/qmux/src/ws.rs index 648283a33c6..12ef88a8a53 100644 --- a/rs/qmux/src/ws.rs +++ b/rs/qmux/src/ws.rs @@ -174,7 +174,6 @@ pub struct Client { require_protocol: bool, keep_alive: Option, session: Config, - #[cfg(feature = "wss")] tls: Option>, } @@ -230,7 +229,6 @@ impl Client { } /// Dial `wss://` URLs with this TLS policy instead of the platform's root store. - #[cfg(feature = "wss")] pub fn with_tls(mut self, tls: std::sync::Arc) -> Self { self.tls = Some(tls); self @@ -267,7 +265,6 @@ impl Client { let ws_config = capped(&self.session); // `true` disables Nagle: records are already batched, see `Server::accept`. - #[cfg(feature = "wss")] let (ws_stream, response) = { let connector = match ( &self.tls, @@ -303,11 +300,6 @@ impl Client { .map_err(Error::websocket)? }; - #[cfg(not(feature = "wss"))] - let (ws_stream, response) = tokio_tungstenite::connect_async_with_config(request, Some(ws_config), true) - .await - .map_err(Error::websocket)?; - let negotiated = response .headers() .get(http::header::SEC_WEBSOCKET_PROTOCOL) diff --git a/rs/qmux/tests/interop.rs b/rs/qmux/tests/interop.rs index e1637f072b5..c5fa1716f78 100644 --- a/rs/qmux/tests/interop.rs +++ b/rs/qmux/tests/interop.rs @@ -5,8 +5,6 @@ //! to need credit updates each way, a bidirectional echo, a reset code each way, a datagram //! each way where records carry them, and an application close. -#![cfg(any(feature = "tcp", all(unix, feature = "uds")))] - use bytes::{Bytes, BytesMut}; use moq_net::transport::poll::{RecvStream as _, SendOptions, SendStream as _, Session as _}; use qmux::{Protocol, Session, Version}; diff --git a/rs/workspace-hack/Cargo.toml b/rs/workspace-hack/Cargo.toml index 478af714887..f3d2b0980e8 100644 --- a/rs/workspace-hack/Cargo.toml +++ b/rs/workspace-hack/Cargo.toml @@ -96,7 +96,6 @@ toml_parser = { version = "1" } tower = { version = "0.5", default-features = false, features = ["make", "util"] } tracing-core = { version = "0.1" } tracing-subscriber = { version = "0.3", features = ["env-filter", "local-time"] } -tungstenite = { version = "0.30", default-features = false, features = ["__rustls-tls", "handshake"] } typenum = { version = "1", default-features = false, features = ["const-generics"] } url = { version = "2", features = ["serde"] } usage-argv = { version = "7", default-features = false, features = ["complete", "diagnostics", "help-advanced"] } @@ -185,7 +184,6 @@ toml_parser = { version = "1" } tower = { version = "0.5", default-features = false, features = ["make", "util"] } tracing-core = { version = "0.1" } tracing-subscriber = { version = "0.3", features = ["env-filter", "local-time"] } -tungstenite = { version = "0.30", default-features = false, features = ["__rustls-tls", "handshake"] } typenum = { version = "1", default-features = false, features = ["const-generics"] } url = { version = "2", features = ["serde"] } usage-argv = { version = "7", default-features = false, features = ["complete", "diagnostics", "help-advanced"] } diff --git a/sh/dispatch.sh b/sh/dispatch.sh index 95b0271996e..ae088020653 100755 --- a/sh/dispatch.sh +++ b/sh/dispatch.sh @@ -417,7 +417,7 @@ step() { check:carla_bridge) run just carla bridge-check ;; check:bench) run python3 bench/compare.test.py - run bash sh/local.sh cargo check --locked --package moq-relay --package moq-bench --features moq-relay/io-uring + run bash sh/local.sh cargo check --locked --package moq-relay --package moq-bench ;; check:quest) run bash sh/quest.sh check ;; check:audio_quality) run just test audio-quality --replays --enforce ;; diff --git a/sh/gh/nightly.test.py b/sh/gh/nightly.test.py index b207f52b37c..565095bb10e 100644 --- a/sh/gh/nightly.test.py +++ b/sh/gh/nightly.test.py @@ -40,7 +40,7 @@ def run_features(self, failures=(), nested=False, leaks=(), recipe="features"): sys.exit(1) if call[0] == 'just': if os.environ['FEATURE_NESTED'] == '1' and args[1] in ( - 'net-features', 'quic-features', 'crypto-key', 'tokio-features', 'media-features', + 'net-features', 'quic-features', 'crypto-key', 'media-features', 'coroutines', ): sys.exit(subprocess.call([os.environ['FEATURE_REAL_JUST'], *args])) @@ -111,7 +111,7 @@ def test_nested_feature_checks_continue_after_compile_failures(self): passed, expected = self.run_features(nested=True) self.assertEqual(passed.returncode, 0, passed.stderr) failures = [] - for package in ("kio", "moq-net", "moq-quic", "moq-crypto", "moq-tokio", "moq-video"): + for package in ("kio", "moq-net", "moq-quic", "moq-crypto", "moq-video"): failures.append( next(call for call in expected if call[0] == "cargo" and call[1] != "tree" and package in call) ) @@ -119,7 +119,7 @@ def test_nested_feature_checks_continue_after_compile_failures(self): self.assertNotEqual(failed.returncode, 0) self.assertEqual(calls, expected) summary = "\n".join(line for line in failed.stderr.splitlines() if line.startswith("checks: failed: ")) - for package in ("kio", "moq-net", "moq-quic", "moq-crypto", "moq-tokio", "moq-video"): + for package in ("kio", "moq-net", "moq-quic", "moq-crypto", "moq-video"): self.assertIn(package, summary) self.assertIn("checks: just rs coroutines", failed.stdout) diff --git a/sh/rs/select.sh b/sh/rs/select.sh index db7084687ce..a07f5ae95c8 100755 --- a/sh/rs/select.sh +++ b/sh/rs/select.sh @@ -203,9 +203,6 @@ case "$action" in features+=(moq-video/capture moq-audio/capture moq-audio/playback) fi if wants moq-cli; then features+=(moq-cli/play moq-cli/openh264); fi - # The relay's io_uring listener, Linux-only. A moq-uring change selects - # the relay too, as its dependent. - if [[ "$(uname -s)" == Linux ]] && wants moq-relay; then features+=(moq-relay/io-uring); fi # Cargo skips a target whose `required-features` are off without a word, # and a crate alone in the selection (a bench-only change, or moq-boy, # whose one target is its binary) has no dependent to turn them on. Turn diff --git a/sh/rs/select.test.py b/sh/rs/select.test.py index 5a32f0797ee..1af43d14170 100644 --- a/sh/rs/select.test.py +++ b/sh/rs/select.test.py @@ -13,7 +13,6 @@ FUZZ_CRATES = ("moq-net", "moq-quic", "moq-mux", "moq-rtmp", "moq-sock", "moq-uring") FUZZ_EXCLUDES = " ".join(f"--exclude {crate}-fuzz" for crate in FUZZ_CRATES) DEVICE_FEATURES = "moq-video/capture moq-audio/capture moq-audio/playback moq-cli/play moq-cli/openh264" -LINUX = os.uname().sysname == "Linux" def target_features(): @@ -74,7 +73,7 @@ def selected(self, *paths, action="lint", github_actions=False): return calls.read_text().splitlines() if calls.exists() else [] def test_nextest_launcher_selects_workspace(self): - features = [*DEVICE_FEATURES.split(), *(["moq-relay/io-uring"] if LINUX else [])] + features = DEVICE_FEATURES.split() features += [feature for feature in target_features() if feature not in features] for github_actions in (False, True): for action in ("check", "check-test", "lint", "test"): @@ -87,8 +86,7 @@ def test_nextest_launcher_selects_workspace(self): ) selected = self.selected("sh/rs/nextest.sh") # The gate's lint runs no extra target or feature builds. - for recipe in ("uring-check", "capture"): - self.assertNotIn(f"rs {recipe}", selected) + self.assertNotIn("rs capture", selected) def test_cargo_configuration_selects_workspace(self): for path in (".cargo/config.toml", ".cargo/config"): @@ -181,15 +179,12 @@ def test_device_features_join_the_one_test_build(self): calls = self.selected("rs/moq-audio/src/lib.rs", action="test") self.assertIn("--package moq-video --package moq-audio", calls[0]) - def test_io_uring_joins_the_linux_test_build(self): - for path in ("rs/moq-uring/src/lib.rs", "rs/moq-relay/src/lib.rs", "rs/moq-net/src/lib.rs"): + def test_io_uring_changes_test_the_relay(self): + for path in ("rs/moq-uring/src/lib.rs", "rs/moq-relay/src/lib.rs"): with self.subTest(path=path): calls = self.selected(path, action="test") self.assertEqual(len(calls), 1, calls) - self.assertEqual(" moq-relay/io-uring" in calls[0], LINUX, calls) - if path == "rs/moq-uring/src/lib.rs": - self.assertIn("/rs/moq-uring#", calls[0]) - self.assertNotIn("moq-relay/io-uring", self.selected("rs/moq-cli/src/main.rs", action="test")[0]) + self.assertIn("/rs/moq-relay#", calls[0]) def test_net_session_tests_follow_the_library(self): for path in ("rs/moq-net/src/lib.rs", "rs/moq-json/src/lib.rs", "rs/moq-net-tests/tests/integration/main.rs"): diff --git a/sh/rs/tokio-features.sh b/sh/rs/tokio-features.sh deleted file mode 100755 index 9d9ff69ea14..00000000000 --- a/sh/rs/tokio-features.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env bash -# Compile moq-tokio by itself at the feature extremes and as a bare QUIC driver; -# --all also isolates each transport permutation. The default-feature -# build is already in the ordinary gate, which can hide missing feature gates -# through unification. -set -euo pipefail - -if [[ "${GITHUB_ACTIONS:-}" != true && "${LOCAL_SUPERVISED:-}" != 1 ]]; then - exec bash "$(dirname "$0")/../local.sh" bash "$0" "$@" -fi - -all=0 -if [[ $# == 1 && $1 == --all ]]; then - all=1 -elif [[ $# != 0 ]]; then - echo 'usage: just rs tokio-features [--all]' >&2 - exit 2 -fi - -cd "$(git rev-parse --show-toplevel)" -# shellcheck source=sh/checks.sh -source "$(dirname "${BASH_SOURCE[0]}")/../checks.sh" - -run cargo clippy --locked -p moq-tokio --no-default-features -- -D warnings -run cargo clippy --locked -p moq-tokio --all-features -- -D warnings - -# The QUIC driver is public API for applications without a MoQ session, so its -# build must not reach moq-net, the MoQ backend's dependencies, or another QUIC stack. -driver=(--no-default-features --features "driver") -targets=(--tests) -if ((all)); then targets=(--all-targets); fi -run cargo clippy --locked -p moq-tokio "${targets[@]}" "${driver[@]}" -- -D warnings -driver_dependencies() { - graph=$(cargo tree --locked -p moq-tokio -e normal --prefix none "${driver[@]}") || return - if leaked=$(grep -E '^(moq-net|reqwest|notify|quinn[a-z-]*|noq[a-z-]*|web-transport[a-z-]*) ' <<<"$graph"); then - echo "rs: moq-tokio's driver build must not depend on:" >&2 - sort -u <<<"$leaked" >&2 - return 1 - fi -} -run driver_dependencies -# Every isolated permutation, which `just rs features` asks for. -if ((all)); then - for feature in net qmux quic tcp uds websocket; do - run cargo clippy --locked -p moq-tokio --no-default-features --features "$feature" -- -D warnings - done -fi - -# Crypto support alone must not make a transport-less server load a QUIC identity. -run bash sh/rs/nextest.sh cargo nextest run --locked -p moq-tokio --lib \ - --no-default-features --features tcp \ - -E 'test(no_quic_backend_needs_no_served_identity)' -finish From 7a009b779353624871b7599fd8e6b93c66c4f9f0 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 15 Nov 2026 07:36:57 -0800 Subject: [PATCH 3/7] ci: drop the moq-tokio feature test and gate ts on moq-uring Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release-gate.yml | 1 + sh/rs/select.test.py | 13 ------------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/.github/workflows/release-gate.yml b/.github/workflows/release-gate.yml index 9ae28ad624e..f142bc20785 100644 --- a/.github/workflows/release-gate.yml +++ b/.github/workflows/release-gate.yml @@ -258,6 +258,7 @@ jobs: - "rs/moq-srt/**" - "rs/moq-stats/**" - "rs/moq-tokio/**" + - "rs/moq-uring/**" - "rs/moq-webrtc/**" - "rs/qmux/**" - "Cargo.toml" diff --git a/sh/rs/select.test.py b/sh/rs/select.test.py index 1af43d14170..b8645392532 100644 --- a/sh/rs/select.test.py +++ b/sh/rs/select.test.py @@ -474,19 +474,6 @@ def test_net_rejects_async_from_test_dependencies(self): calls = self.trace("net", net_features=f'moq-net feature "{feature}"', expected_returncode=1) self.assertTrue(all(call.startswith("tree ") for call in calls), calls) - def test_tokio_keeps_extremes_and_transport_contracts(self): - boundary = self.trace("tokio") - exhaustive = self.trace("tokio", "--all") - self.assertEqual(sum(call.startswith("clippy ") for call in boundary), 3) - self.assertEqual(sum(call.startswith("clippy ") for call in exhaustive), 9) - self.assertTrue(any(" --tests " in call for call in boundary)) - self.assertFalse(any(" --all-targets " in call for call in boundary)) - self.assertTrue(any(" --all-targets " in call for call in exhaustive)) - self.assertEqual( - [call for call in boundary if not call.startswith("clippy ")], - [call for call in exhaustive if not call.startswith("clippy ")], - ) - def test_media_keeps_dependency_contracts_and_vpx_tests(self): boundary = self.trace("media") exhaustive = self.trace("media", "--all") From 7e481d66e372ebed11e8bd0866a28dd9f65a76bd Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 15 Nov 2026 08:11:55 -0800 Subject: [PATCH 4/7] fix: keep the QUIC-only accept health test and drop a stale comment Co-Authored-By: Claude Opus 5.5 --- rs/moq-relay/src/relay.rs | 2 -- rs/moq-tokio/src/server.rs | 13 +++++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/rs/moq-relay/src/relay.rs b/rs/moq-relay/src/relay.rs index a621fde49be..25496ee8b87 100644 --- a/rs/moq-relay/src/relay.rs +++ b/rs/moq-relay/src/relay.rs @@ -746,8 +746,6 @@ impl Relay { } } }; - // No group to run, so this leg never resolves and the shared accept loop - // below decides the `select!` on its own. let has_workers = workers.is_some(); diff --git a/rs/moq-tokio/src/server.rs b/rs/moq-tokio/src/server.rs index 3c4e014e176..86ba46fea38 100644 --- a/rs/moq-tokio/src/server.rs +++ b/rs/moq-tokio/src/server.rs @@ -2975,6 +2975,19 @@ mod tests { } } + /// A server with no stream listener reports nothing. QUIC multiplexes over one UDP + /// socket and never calls `accept`, so a zero counter would be a watch that cannot fire. + #[tokio::test] + async fn accept_health_is_empty_without_a_stream_listener() { + let mut config = crate::listen::Config { + bind: Some("[::]:0".parse().unwrap()), + ..Default::default() + }; + config.tls.generate = vec!["localhost".into()]; + let server = config.init(Default::default()).expect("quic server"); + assert!(server.accept_health().is_empty()); + } + /// `certificates()` must stay readable with no runtime entered (no guard /// escapes to the caller). #[tokio::test] From 1dc95cfb4ed0f1678952c39263528f732837b349 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 15 Nov 2026 12:24:54 -0800 Subject: [PATCH 5/7] docs: Unix sockets are Unix-only in the crate table Co-Authored-By: Claude Opus 5.5 --- doc/lib/rs/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/lib/rs/index.md b/doc/lib/rs/index.md index 2f6006415de..207337a41a0 100644 --- a/doc/lib/rs/index.md +++ b/doc/lib/rs/index.md @@ -25,8 +25,8 @@ missing required CPU feature before starting transport cryptography. | --- | --- | | [moq-net](/lib/rs/moq-net) | The pub/sub layer: sessions, origins, broadcasts, tracks, groups, frames. Transport-agnostic. | | [moq-pattern](https://docs.rs/moq-pattern) | Path patterns such as `room/**`. Re-exported by moq-net and moq-auth. | -| [moq-tokio](https://docs.rs/moq-tokio) | Connects and listens over QUIC, WebTransport, WebSocket, TCP, or Unix sockets, from config or CLI flags, and runs MoQ over a qmux session established elsewhere. Its `quic::driver` is a Tokio QUIC stack, with rind cryptography, for applications without MoQ. | -| [qmux](https://docs.rs/qmux) | QUIC streams, datagrams, and flow control over TCP, TLS, WebSocket, and Unix sockets, on moq-quic's state machine. | +| [moq-tokio](https://docs.rs/moq-tokio) | Connects and listens over QUIC, WebTransport, WebSocket, TCP, or Unix sockets (Unix only), from config or CLI flags, and runs MoQ over a qmux session established elsewhere. Its `quic::driver` is a Tokio QUIC stack, with rind cryptography, for applications without MoQ. | +| [qmux](https://docs.rs/qmux) | QUIC streams, datagrams, and flow control over TCP, TLS, WebSocket, and Unix sockets (Unix only), on moq-quic's state machine. | | [moq-sock](https://docs.rs/moq-sock) | Socket binding and CPU pinning for thread-per-core listeners. | | [moq-uring](https://docs.rs/moq-uring) | Experimental Linux io\_uring server for moq-lite. | | [hang](/lib/rs/hang) | The media layer: catalog, containers, ordered frame delivery. | From 7d5302964ee3440a1e9e748b9a084fe39687d3e6 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 15 Nov 2026 15:10:58 -0800 Subject: [PATCH 6/7] test(moq-relay): the io_uring bitrate tests run on host time They pace a real relay on real sockets, so they opt out of KIO_DENY_HOST_TIMERS as rs/AGENTS.md asks, now that every Linux build compiles them. Co-Authored-By: Claude Opus 5.5 --- rs/moq-relay/tests/integration/bitrate_caps.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/rs/moq-relay/tests/integration/bitrate_caps.rs b/rs/moq-relay/tests/integration/bitrate_caps.rs index 4822967639a..3e0a5669311 100644 --- a/rs/moq-relay/tests/integration/bitrate_caps.rs +++ b/rs/moq-relay/tests/integration/bitrate_caps.rs @@ -338,6 +338,7 @@ mod uring { const HOST: IpAddr = IpAddr::V4(Ipv4Addr::UNSPECIFIED); async fn relay() -> Option<(Relay, u16, tempfile::TempDir)> { + kio::clock::host_time(); // a real relay on real sockets, paced in real time let _ = rind_rustls::default_provider().unwrap().install_default(); match moq_uring::Worker::new(Default::default()) { Ok(_) => {} From b28d4a62ae9d22bcad9475fb9795ac891d358ed7 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 15 Nov 2026 15:11:00 -0800 Subject: [PATCH 7/7] refactor(moq-tokio): a Client always holds its QUIC backend The Option was for builds without the quic feature, which no longer exist, so its None branches were dead. Co-Authored-By: Claude Opus 5.5 --- rs/moq-tokio/src/client.rs | 57 +++++++++++++++----------------------- 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/rs/moq-tokio/src/client.rs b/rs/moq-tokio/src/client.rs index 3f6b061e7eb..4f0026ebce2 100644 --- a/rs/moq-tokio/src/client.rs +++ b/rs/moq-tokio/src/client.rs @@ -72,7 +72,7 @@ pub struct Client { tls_host_name: Option, /// Only the TLS-based dials read this; the plaintext qmux transports have none. tls: rustls::ClientConfig, - quic: Option, + quic: crate::quic::Client, /// The settings each qmux dial starts from: the `[quic]` windows and stream count, so a /// qmux session takes the same per-session numbers as a QUIC one. qmux: qmux::Config, @@ -134,7 +134,7 @@ impl Client { Some(host) => crate::quic::Client::simulated(&config, &quic, host), None => crate::quic::Client::new(&config, &quic), }; - let quic = Some(quic?); + let quic = quic?; let versions = config.versions(); // Read before the struct literal below moves fields out of `config`. @@ -299,7 +299,7 @@ impl Client { return false; } // An explicitly closed QUIC endpoint cannot open another socket. - let quic = self.quic.as_ref().is_some_and(|quic| !quic.is_closed()); + let quic = !self.quic.is_closed(); #[cfg(feature = "sim")] if self.simulated() { return quic && simulated_scheme(scheme); @@ -318,13 +318,11 @@ impl Client { /// Whether QUIC binds on a simulated host, where no other transport can dial. #[cfg(feature = "sim")] fn simulated(&self) -> bool { - self.quic.as_ref().is_some_and(crate::quic::Client::is_simulated) + self.quic.is_simulated() } pub(crate) fn fresh_port(&mut self) -> crate::Result<()> { - if let Some(quic) = &mut self.quic { - quic.fresh_port()?; - } + self.quic.fresh_port()?; Ok(()) } @@ -342,9 +340,7 @@ impl Client { /// Only the QUIC endpoint is closed. WebSocket, TCP, and UDS sessions end when their /// [`Connection`] is dropped (the kernel closes the socket on exit). pub async fn close(self) { - if let Some(quic) = self.quic { - quic.close().await; - } + self.quic.close().await; } /// Connect to the configured [`connect.url`](crate::connect::Config::url) URL, publishing @@ -445,7 +441,7 @@ impl Client { /// Whether a session dialed at `url` over `transport` sits on the WebSocket fallback of /// a race QUIC could win, so it should probe QUIC. pub(crate) fn on_fallback(&self, url: &Url, transport: crate::Transport) -> bool { - transport == crate::Transport::WebSocket && self.quic.is_some() && matches!(url.scheme(), "http" | "https") + transport == crate::Transport::WebSocket && matches!(url.scheme(), "http" | "https") } /// Reach one probe of a [`Connection`]'s policy over QUIC alone, with no WebSocket @@ -468,11 +464,7 @@ impl Client { Ok(Dialed::new(connect_session(&moq, session).await?, transport)) })); } - let quic = self - .quic - .as_ref() - .ok_or(Error::NoBackend("a probe needs the QUIC backend"))?; - let session = quic.connect(&client.tls, addr, &client.versions).await?; + let session = self.quic.connect(&client.tls, addr, &client.versions).await?; Ok(Box::pin(async move { Ok(Dialed::new(connect_session(&moq, session).await?, transport)) })) @@ -529,25 +521,22 @@ impl Client { return self.connect_websocket(&moq, addr).await; } - if let Some(quic) = self.quic.as_ref() { - let quic_addr = addr.clone(); - let quic_handle = async { - quic.connect(&self.tls, quic_addr, &self.versions) - .await - .map_err(Error::from) - }; - - // A simulated host has no TCP for the fallback to race. - if !quic.is_simulated() { - return self.race_moq_connect(&moq, addr, quic_handle).await; - } + let quic_addr = addr.clone(); + let quic_handle = async { + self.quic + .connect(&self.tls, quic_addr, &self.versions) + .await + .map_err(Error::from) + }; - let session = quic_handle.await?; - let session = connect_session(&moq, session).await?; - return Ok(Dialed::new(session, quic_transport(&url))); + // A simulated host has no TCP for the fallback to race. + if !self.quic.is_simulated() { + return self.race_moq_connect(&moq, addr, quic_handle).await; } - return self.connect_websocket(&moq, addr).await; + let session = quic_handle.await?; + let session = connect_session(&moq, session).await?; + Ok(Dialed::new(session, quic_transport(&url))) } /// Connect over WebSocket alone. @@ -1178,7 +1167,7 @@ mod tests { // The same race `connect_inner` runs, except the fallback dials its own port, // as plain ws:// so the listener above can answer without TLS. - let quic = client.quic.clone().unwrap(); + let quic = client.quic.clone(); let (tls, versions) = (client.tls.clone(), client.versions.clone()); let quic_addr: crate::connect::Addr = Url::parse(&format!("https://localhost:{quic_port}")).unwrap().into(); let ws_addr: crate::connect::Addr = Url::parse(&format!("http://localhost:{ws_port}")).unwrap().into(); @@ -1275,7 +1264,7 @@ mod tests { let client = client.with_subscriber(sub_origin); let dialer = client.clone(); let quic = Box::pin(async move { - let quic = dialer.quic.as_ref().expect("QUIC backend"); + let quic = &dialer.quic; let session = quic.connect(&dialer.tls, quic_addr, &dialer.versions).await?; connected.send(()).expect("fallback listener alive"); Ok::<_, crate::Error>(session)