From 1c622907d87634df598c5fe229ea8bb453832205 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 16 Nov 2026 05:27:06 -0800 Subject: [PATCH 1/4] chore(quest): claim quest/m2/transport-names.md Quest-Claim: 20b3543671334076 From 0a05a90a9f21bb8de55d1f0ba639b6c4baa92c9d Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 16 Nov 2026 06:09:12 -0800 Subject: [PATCH 2/4] feat!: a TLS stream link reports tls, and @moq/qmux has one stream limit A tls:// dial and the TLS stream acceptor report Transport::Tls in moq-tokio, moq-auth, the relay's auth request, moq-ffi and every binding, and @moq/auth parses "tls". @moq/qmux takes one maxStreams for each direction. Co-Authored-By: Claude Sonnet 5.5 --- dart/moq_ffi/lib/src/moq.dart | 6 +- doc/bin/relay/auth.md | 11 ++- go/wrapper/server.go | 2 + js/auth/api/index.api.md | 5 ++ js/auth/src/contract.ts | 2 +- js/auth/src/interop.test.ts | 6 ++ js/net/src/connection/connect.ts | 3 +- js/net/src/integration.test.ts | 12 +-- js/net/src/open.test.ts | 6 +- js/qmux/api/index.api.md | 3 +- js/qmux/src/session.test.ts | 34 ++++++-- js/qmux/src/session.ts | 17 ++-- quest/m2/README.md | 3 +- quest/m2/transport-names.md | 87 ------------------- quest/m2/unused-api/transport.md | 5 +- rs/moq-auth/src/request.rs | 15 +++- rs/moq-cli/src/main.rs | 6 +- rs/moq-ffi/src/server.rs | 4 + rs/moq-relay/src/auth.rs | 11 ++- .../tests/integration/auth_lifetime.rs | 24 +++++ rs/moq-tokio/src/client.rs | 2 +- rs/moq-tokio/src/server.rs | 2 +- rs/moq-tokio/src/tcp.rs | 5 +- rs/moq-tokio/src/transport.rs | 3 + 24 files changed, 135 insertions(+), 139 deletions(-) delete mode 100644 quest/m2/transport-names.md diff --git a/dart/moq_ffi/lib/src/moq.dart b/dart/moq_ffi/lib/src/moq.dart index 74bbb704978..4858ffdaa06 100644 --- a/dart/moq_ffi/lib/src/moq.dart +++ b/dart/moq_ffi/lib/src/moq.dart @@ -8691,7 +8691,7 @@ class FfiConverterMoqCompression { } } -enum MoqTransport { quic, webSocket, tcp, unix, webTransport } +enum MoqTransport { quic, webSocket, tcp, tls, unix, webTransport } class FfiConverterMoqTransport { static LiftRetVal read(Uint8List buf) { @@ -8704,8 +8704,10 @@ class FfiConverterMoqTransport { case 3: return LiftRetVal(MoqTransport.tcp, 4); case 4: - return LiftRetVal(MoqTransport.unix, 4); + return LiftRetVal(MoqTransport.tls, 4); case 5: + return LiftRetVal(MoqTransport.unix, 4); + case 6: return LiftRetVal(MoqTransport.webTransport, 4); default: throw UniffiInternalError( diff --git a/doc/bin/relay/auth.md b/doc/bin/relay/auth.md index 5b349af46b9..4e9b5b1467c 100644 --- a/doc/bin/relay/auth.md +++ b/doc/bin/relay/auth.md @@ -398,9 +398,10 @@ subscribe = [] ## Auth server -Upgrade auth servers before relays when adopting the `webtransport` transport value. +Upgrade auth servers before relays when adopting the `webtransport` or `tls` transport value. WebTransport sessions report `webtransport`; native QUIC sessions report `quic`. -Older auth servers reject the new value. Updated Rust and JavaScript auth parsers +`tls://` sessions report `tls`; plaintext `tcp://` sessions report `tcp`. +Older auth servers reject the new values. Updated Rust and JavaScript auth parsers map future transport names to `unknown`, which your policy should handle explicitly. `moq auth serve` is the reference auth server, answering the contract above. @@ -496,8 +497,10 @@ so count sessions only on the others. See The plaintext TCP and Unix-socket listeners are admitted exactly like QUIC: the path and query ride the `SETUP` (`tcp://127.0.0.1:4444/room?jwt=...`) and -reach the auth server with `transport` set to `tcp` or `unix`. A Unix socket -can also require a specific uid, gid, or pid: +reach the auth server with `transport` set to `tcp` or `unix`. A `tls://` link +(below) reports `tls`, so a policy keyed on `transport == "tcp"` for cluster +links over TLS now sees `"tls"`. A Unix socket can also require a specific uid, +gid, or pid: ```toml [listen.unix] diff --git a/go/wrapper/server.go b/go/wrapper/server.go index b445052e8d6..2128000b689 100644 --- a/go/wrapper/server.go +++ b/go/wrapper/server.go @@ -19,6 +19,8 @@ const ( TransportWebSocket = ffi.MoqTransportWebSocket // TransportTCP is a session that arrived over a plaintext TCP connection. TransportTCP = ffi.MoqTransportTcp + // TransportTLS is a session that arrived over a TCP connection inside TLS (a tls:// link). + TransportTLS = ffi.MoqTransportTls // TransportUnix is a session that arrived over a Unix domain socket. TransportUnix = ffi.MoqTransportUnix // TransportWebTransport is a session that arrived over WebTransport (HTTP/3). diff --git a/js/auth/api/index.api.md b/js/auth/api/index.api.md index b59c4964e38..a0126ef8af3 100644 --- a/js/auth/api/index.api.md +++ b/js/auth/api/index.api.md @@ -665,6 +665,7 @@ export const RequestSchema: ZodMiniDiscriminatedUnion<[ZodMiniObject<{ rtmp: "rtmp"; srt: "srt"; tcp: "tcp"; + tls: "tls"; unix: "unix"; unknown: "unknown"; webrtc: "webrtc"; @@ -705,6 +706,7 @@ export const RequestSchema: ZodMiniDiscriminatedUnion<[ZodMiniObject<{ rtmp: "rtmp"; srt: "srt"; tcp: "tcp"; + tls: "tls"; unix: "unix"; unknown: "unknown"; webrtc: "webrtc"; @@ -745,6 +747,7 @@ export const RequestSchema: ZodMiniDiscriminatedUnion<[ZodMiniObject<{ rtmp: "rtmp"; srt: "srt"; tcp: "tcp"; + tls: "tls"; unix: "unix"; unknown: "unknown"; webrtc: "webrtc"; @@ -791,6 +794,7 @@ export const RequestSchema: ZodMiniDiscriminatedUnion<[ZodMiniObject<{ rtmp: "rtmp"; srt: "srt"; tcp: "tcp"; + tls: "tls"; unix: "unix"; unknown: "unknown"; webrtc: "webrtc"; @@ -851,6 +855,7 @@ export const TransportSchema: ZodMiniPipe, ZodMiniCatch { expect(request.reason).toBe("invalid"); }); + test("parse the stream link transports from Rust", () => { + for (const transport of ["tcp", "tls"] as const) { + expect(RequestSchema.parse({ ...JSON.parse(RUST_REQUEST), transport }).transport).toBe(transport); + } + }); + test("parse gateway transports and stable end reasons from Rust", () => { for (const transport of ["rtmp", "srt", "webrtc"] as const) { for (const reason of ["narrowed", "shutdown"]) { diff --git a/js/net/src/connection/connect.ts b/js/net/src/connection/connect.ts index a2a8fc12ad1..4efff39f141 100644 --- a/js/net/src/connection/connect.ts +++ b/js/net/src/connection/connect.ts @@ -556,8 +556,7 @@ async function dialRace( protocols: offered.alpns, versions: Object.fromEntries(offered.alpns.map((alpn) => [alpn, QMUX[alpn] ?? null])), config: { - maxStreamsBidi: maxStreams, - maxStreamsUni: maxStreams, + maxStreams, receiveWindow: BigInt(props.websocket?.receiveWindow ?? DEFAULT_RECEIVE_WINDOW), streamReceiveWindow: BigInt( props.websocket?.streamReceiveWindow ?? DEFAULT_STREAM_RECEIVE_WINDOW, diff --git a/js/net/src/integration.test.ts b/js/net/src/integration.test.ts index b1ae87bc172..b3881b832dc 100644 --- a/js/net/src/integration.test.ts +++ b/js/net/src/integration.test.ts @@ -2928,9 +2928,10 @@ test.each([Lite.ALPN_06, Lite.ALPN_07_WIP, Ietf.ALPN.DRAFT_22])( 30_000, ); -// A qmux session pair negotiating `protocol` over an in-memory socket, each side granting the other -// `maxStreamsUni` unidirectional streams. -function qmuxPair(protocol: string, maxStreamsUni: bigint): { client: Qmux; server: Qmux } { +// A qmux session pair negotiating `protocol` over an in-memory socket, the client letting the server +// open `maxStreams` streams of each kind. The client opens every bidirectional stream, so a small limit +// bounds only the server's group streams. +function qmuxPair(protocol: string, maxStreams: bigint): { client: Qmux; server: Qmux } { const socket = (readable: ReadableStream, writable: WritableStream) => { const closed = Promise.withResolvers<{ closeCode: number; reason: string }>(); return { @@ -2945,9 +2946,8 @@ function qmuxPair(protocol: string, maxStreamsUni: bigint): { client: Qmux; serv new TransformStream({ transform: (chunk, c) => c.enqueue(chunk.slice()) }); const up = pipe(); const down = pipe(); - const config = { idleTimeout: null, maxStreamsUni }; - const client = new Qmux(socket(down.readable, up.writable), { config }); - const server = Qmux.accept(socket(up.readable, down.writable), { config }); + const client = new Qmux(socket(down.readable, up.writable), { config: { idleTimeout: null, maxStreams } }); + const server = Qmux.accept(socket(up.readable, down.writable), { config: { idleTimeout: null } }); return { client, server }; } diff --git a/js/net/src/open.test.ts b/js/net/src/open.test.ts index c4513f1f187..e235009ee3f 100644 --- a/js/net/src/open.test.ts +++ b/js/net/src/open.test.ts @@ -10,8 +10,8 @@ import { Writer } from "./stream.ts"; const version = Version.DRAFT_07; const never = new Promise(() => {}); -// A qmux session pair over an in-memory socket, the server granting `maxStreamsUni`. -function qmuxPair(maxStreamsUni?: bigint): { client: WebTransport; server: WebTransport } { +// A qmux session pair over an in-memory socket, the server granting `maxStreams`. +function qmuxPair(maxStreams?: bigint): { client: WebTransport; server: WebTransport } { const socket = (readable: ReadableStream, writable: WritableStream) => { const closed = Promise.withResolvers<{ closeCode: number; reason: string }>(); return { @@ -28,7 +28,7 @@ function qmuxPair(maxStreamsUni?: bigint): { client: WebTransport; server: WebTr const down = pipe(); const config = { idleTimeout: null }; const client = new Qmux(socket(down.readable, up.writable), { config }); - const server = Qmux.accept(socket(up.readable, down.writable), { config: { ...config, maxStreamsUni } }); + const server = Qmux.accept(socket(up.readable, down.writable), { config: { ...config, maxStreams } }); return { client, server }; } diff --git a/js/qmux/api/index.api.md b/js/qmux/api/index.api.md index eda6aa58d5a..9d8e34afb17 100644 --- a/js/qmux/api/index.api.md +++ b/js/qmux/api/index.api.md @@ -16,8 +16,7 @@ export interface Config { idleTimeout?: Duration | null; maxDatagramFrameSize?: bigint | null; maxRecordSize?: bigint; - maxStreamsBidi?: bigint; - maxStreamsUni?: bigint; + maxStreams?: bigint; receiveWindow?: bigint; streamReceiveWindow?: bigint; } diff --git a/js/qmux/src/session.test.ts b/js/qmux/src/session.test.ts index eebe9c0c3e1..3684998b6d9 100644 --- a/js/qmux/src/session.test.ts +++ b/js/qmux/src/session.test.ts @@ -628,7 +628,7 @@ describe("Session integration (scripted peer)", () => { // The peer may open any index under its credit, implicitly opening every // lower one. Tracking each skipped index would let one tiny frame make us // allocate (and loop) once per stream below it. - const { session, peer } = connect({ maxStreamsUni: 1n << 40n }); + const { session, peer } = connect({ maxStreams: 1n << 40n }); peer.send({ type: "transport_parameters", params: peerParams() }); await session.ready; @@ -922,8 +922,10 @@ describe("Session integration (scripted peer)", () => { { receiveWindow: null }, { receiveWindow: "64" }, { streamReceiveWindow: 64 }, - { maxStreamsBidi: null }, - { maxStreamsUni: 1 }, + { maxStreams: null }, + { maxStreams: 1 }, + { maxStreamsBidi: 1n }, + { maxStreamsUni: 1n }, { maxRecordSize: null }, { maxDatagramFrameSize: 64 }, { maxData: 64n }, @@ -957,6 +959,20 @@ describe("Session integration (scripted peer)", () => { session.close(); }); + test("one maxStreams is advertised for both directions", async () => { + const { session, peer } = connect({ maxStreams: 7n }); + await started(peer); + await waitFor(() => peer.has("transport_parameters")); + const frame = peer + .received() + .find( + (frame): frame is Frame.TransportParameters => frame.type === "transport_parameters", + ) as Frame.TransportParameters; + expect(frame.params.initialMaxStreamsBidi).toBe(7n); + expect(frame.params.initialMaxStreamsUni).toBe(7n); + session.close(); + }); + test("disabled config uses null and invalid durations fail before opening", () => { // A plain number is the old millisecond config, refused rather than misread. for (const value of [ @@ -979,7 +995,7 @@ describe("Session integration (scripted peer)", () => { test("config values that don't fit a varint are refused up front", () => { (globalThis as { WebSocketStream?: unknown }).WebSocketStream = FakePeer; expect(() => new Session("https://example/test", { config: { receiveWindow: -1n } })).toThrow("VarInt"); - expect(() => new Session("https://example/test", { config: { maxStreamsBidi: VarInt.MAX + 1n } })).toThrow( + expect(() => new Session("https://example/test", { config: { maxStreams: VarInt.MAX + 1n } })).toThrow( "VarInt", ); }); @@ -1853,7 +1869,7 @@ describe("Session integration (scripted peer)", () => { // immediately observable. This is the reproduction from issue #299: the peer // sends a full stream plus FIN while the application never reads the acceptor. const { session, peer } = connect({ - maxStreamsUni: 1n, + maxStreams: 1n, receiveWindow: 100n, streamReceiveWindow: 100n, }); @@ -1891,7 +1907,7 @@ describe("Session integration (scripted peer)", () => { }); test("accepted active streams do not recycle stream-count credit", async () => { - const { session, peer } = connect({ maxStreamsUni: 1n }); + const { session, peer } = connect({ maxStreams: 1n }); peer.send({ type: "transport_parameters", params: peerParams() }); await session.ready; @@ -1916,7 +1932,7 @@ describe("Session integration (scripted peer)", () => { const id = Stream.Id.create(0n, Stream.Dir.Bi, true); async function accept() { - const { session, peer } = connect({ maxStreamsBidi: 1n }); + const { session, peer } = connect({ maxStreams: 1n }); peer.send({ type: "transport_parameters", params: peerParams() }); await session.ready; peer.send({ type: "stream", id, data: new Uint8Array([1]), fin: false }); @@ -2028,7 +2044,7 @@ describe("Session integration (scripted peer)", () => { // slot returns as soon as both halves are done on the wire. describe("a refused peer stream returns its stream-count credit", () => { test("uni, once the peer finishes it", async () => { - const { session, peer } = connect({ maxStreamsUni: 1n }); + const { session, peer } = connect({ maxStreams: 1n }); peer.send({ type: "transport_parameters", params: peerParams() }); await session.ready; await session.incomingUnidirectionalStreams.cancel(); @@ -2040,7 +2056,7 @@ describe("Session integration (scripted peer)", () => { }); test("bidi, resetting our send half, once the peer finishes its own", async () => { - const { session, peer } = connect({ maxStreamsBidi: 1n }); + const { session, peer } = connect({ maxStreams: 1n }); peer.send({ type: "transport_parameters", params: peerParams() }); await session.ready; await session.incomingBidirectionalStreams.cancel(); diff --git a/js/qmux/src/session.ts b/js/qmux/src/session.ts index e6c4b6b6253..3be3e589e9f 100644 --- a/js/qmux/src/session.ts +++ b/js/qmux/src/session.ts @@ -29,10 +29,8 @@ export type SendStreamOptions = WebTransportSendStreamOptions & { /** Configuration for a QMux session. */ export interface Config { - /** Max concurrent bidirectional streams the peer can open. */ - maxStreamsBidi?: bigint; - /** Max concurrent unidirectional streams the peer can open. */ - maxStreamsUni?: bigint; + /** Max concurrent streams the peer can open, in each direction. */ + maxStreams?: bigint; /** Connection-level receive window in bytes. */ receiveWindow?: bigint; /** Receive window in bytes for every stream. */ @@ -54,8 +52,7 @@ export interface Config { } const DEFAULT_CONFIG: Required = { - maxStreamsBidi: 100n, - maxStreamsUni: 100n, + maxStreams: 100n, receiveWindow: 1_048_576n, streamReceiveWindow: 262_144n, idleTimeout: Duration.secs(30), @@ -104,8 +101,8 @@ function configToTransportParams(config: Required): TransportParams { initialMaxStreamDataBidiLocal: config.streamReceiveWindow, initialMaxStreamDataBidiRemote: config.streamReceiveWindow, initialMaxStreamDataUni: config.streamReceiveWindow, - initialMaxStreamsBidi: config.maxStreamsBidi, - initialMaxStreamsUni: config.maxStreamsUni, + initialMaxStreamsBidi: config.maxStreams, + initialMaxStreamsUni: config.maxStreams, // Clamp to maxRecordSize so we never advertise a datagram larger than our // record layer accepts. maxDatagramFrameSize: @@ -783,8 +780,8 @@ export class Session implements WebTransport { // Receive limits are version-independent. const notify = () => this.#scheduler?.notify(); this.#recvData = new Window(this.#ourParams.initialMaxData, notify); - this.#recvBiLimit = new StreamLimit(this.#config.maxStreamsBidi, notify); - this.#recvUniLimit = new StreamLimit(this.#config.maxStreamsUni, notify); + this.#recvBiLimit = new StreamLimit(this.#config.maxStreams, notify); + this.#recvUniLimit = new StreamLimit(this.#config.maxStreams, notify); const ready = Promise.withResolvers(); this.ready = ready.promise; diff --git a/quest/m2/README.md b/quest/m2/README.md index 42df4d4cfa6..6efa8938507 100644 --- a/quest/m2/README.md +++ b/quest/m2/README.md @@ -46,8 +46,7 @@ removal, a rename, or a wire, catalog, or format change that is free until cut waits on by name; [congestion names](/quest/m2/congestion-names.md); [config names](/quest/m2/relay-config-names.md), [the two dial keys](/quest/m2/relay-connect-keys.md), and - [the 0.14 leftovers](/quest/m2/relay-014-leftovers.md); - [transport names](/quest/m2/transport-names.md); and + [the 0.14 leftovers](/quest/m2/relay-014-leftovers.md); and [stats names](/quest/m2/stats-old-names.md). - **Auth and crypto.** [Grants](/quest/m2/auth-grants.md), [claims](/quest/m2/auth-claims.md), and diff --git a/quest/m2/transport-names.md b/quest/m2/transport-names.md deleted file mode 100644 index a3c7cb56c89..00000000000 --- a/quest/m2/transport-names.md +++ /dev/null @@ -1,87 +0,0 @@ -# [S] A TLS stream link reports tls, and @moq/qmux has one stream limit - -## Goal - -A session over `tls://` reports its transport as `tls`, in -`moq_tokio::Transport`, in `moq_auth::Transport`, in the auth request an -endpoint receives, and in the bindings, so an auth server, a log line, and -the relay's own checks can tell an encrypted stream link from plaintext -`tcp://`. `@moq/qmux` takes one `maxStreams`, applied to each direction, as -Rust's `Limits::max_streams` and `@moq/net`'s `websocket.maxStreams` already -do. - -## Plan - -Decided 2026-11-16 (maintainer, /quest-plan of the pre-cut audit): - -- ✅ Add `Tls` to both `Transport` enums and report it for `tls://` - (rejected: only fixing the moq-tokio doc that says "plaintext"). Both - enums are non-exhaustive, so the variant is additive in Rust, but - changing what an existing link reports moves every policy and metric - keyed on `"tcp"`. That is cheapest before the name is announced. -- ✅ `@moq/qmux` takes a single `maxStreams` (rejected: also nesting its - windows under `limits` to mirror Rust; keeping the bidirectional and - unidirectional pair). -- LAN discovery stays in moq-tokio: the audit proposed moving - `moq_tokio::mdns` into moq-relay, and the maintainer did not take it. - Don't reopen it without a new reason, such as a measured build cost. - -Facts found by the audit: - -- `moq_tokio::Transport::Tcp` is documented "A plaintext TCP connection - using qmux framing" (`rs/moq-tokio/src/transport.rs:11-12`), yet a - `tls://` dial returns it (`rs/moq-tokio/src/client.rs:496-506`) and the - accept side reports it for every stream link - (`rs/moq-tokio/src/server.rs:1298`). `moq_auth::Transport::Tcp` says - "plaintext or TLS" (`rs/moq-auth/src/request.rs:186-187`). -- The relay maps one enum onto the other (`rs/moq-relay/src/auth.rs:1288`), - so an auth endpoint sees `"tcp"` for an mTLS cluster link unless a client - certificate happens to be attached. `moq`'s `is_public_transport` - (`rs/moq-cli/src/main.rs:226-231`) treats `Tcp` as always public. -- The strings are a contract: `Transport::as_str` - (`rs/moq-tokio/src/transport.rs:22-33`), the serde names in moq-auth - (`rs/moq-auth/src/request.rs:212`), `js/auth/src/contract.ts:35`, and - `MoqTransport` in moq-ffi (`rs/moq-ffi/src/server.rs:449`). -- `@moq/qmux`'s `Config` has `maxStreamsBidi` and `maxStreamsUni` - (`js/qmux/src/session.ts:33-35`, `js/qmux/api/index.api.md:19-20`). Its - one consumer sets both from one number - (`js/net/src/connection/connect.ts:549-560`), and Rust has one - `Limits::max_streams` (`rs/moq-quic/src/limits.rs:21`). - The package moves into this repository at this cut, so the rename rides - a break it already has. -- `ws://` and `wss://` share `WebSocket` in the same way. Not picked: a - WebSocket's TLS belongs to the HTTP server in front of it, which the relay - often cannot see. - -For the PR: - -- Add `Tls`, spelled `"tls"`, to `moq_tokio::Transport` and - `moq_auth::Transport`. Report it from the `tls://` dial and from the TLS - branch of the stream acceptor. Fix the `Tcp` docs to say plaintext in both - crates. Extend the relay's mapping and `is_public_transport` (a TLS link - is public the same way plaintext TCP is; say so in its doc). -- Mirror it in `@moq/auth`'s contract enum and in `MoqTransport` with every - wrapper. If [open-set selectors](/quest/m2/ffi-open-selectors.md) has - landed, `MoqTransport` is already an object and this adds a constructor. -- Grep for consumers of the `"tcp"` string: relay metrics labels - (`rs/moq-relay/src/internal.rs` uses `"tcp"` for the listener, which - stays, since the listener is one TCP port), stats labels, `doc/bin/relay`, - and `doc/concept/transport.md`. The auth docs get a line: a server keying - policy on `transport == "tcp"` for cluster links over TLS now sees `"tls"`. -- `@moq/qmux`: one `maxStreams?: bigint` on `Config` and its default; delete - the pair; `@moq/net` passes it once. Update `js/qmux/api/index.api.md`, - the README, and the migration note. -- Tests: a `tls://` session reports `tls` on both ends and in the auth - request; a `tcp://` session still reports `tcp`; `@moq/qmux` advertises - the one limit for both directions. - -Public API: additive in Rust (`Transport::Tls` on two non-exhaustive -enums) and a new binding selector; breaking for `@moq/qmux` -(`maxStreamsBidi` and `maxStreamsUni` become `maxStreams`). Behaviour: the -transport string for `tls://` changes from `tcp` to `tls` in auth requests -and logs. Wire: none. - -## Related - -- [Open-set selectors in the bindings](/quest/m2/ffi-open-selectors.md) - makes `MoqTransport` able to grow without a break -- [The unused transport API](/quest/m2/unused-api/transport.md) - removes `Transport::WebRtc` from the same enum diff --git a/quest/m2/unused-api/transport.md b/quest/m2/unused-api/transport.md index ae2bd01daac..4895c43b250 100644 --- a/quest/m2/unused-api/transport.md +++ b/quest/m2/unused-api/transport.md @@ -100,8 +100,8 @@ moq-webrtc's `p2p` and moq-relay's `stun` features went in [moq-dev/moq#8771](https://github.com/moq-dev/moq/pull/8771). The [API review](/quest/m3/release/api-review.md) still lists all three. -Left alone, with the reason: `moq_tokio::mdns` stays where it is (see -[transport names](/quest/m2/transport-names.md)); plaintext `tcp://` and +Left alone, with the reason: `moq_tokio::mdns` stays where it is (the maintainer declined moving it into +moq-relay; reopen only with a new reason, such as a measured build cost); plaintext `tcp://` and `unix://` are small and a same-host sidecar is a plausible use; kio's `PushError` and `Queue::poll_push_with` have no outside caller but belong to a foundation crate whose surface is otherwise tight. @@ -117,6 +117,5 @@ methods. The bindings are unchanged. Wire: none. ## Related -- [Transport names](/quest/m2/transport-names.md) - adds `Tls` to the enum item 3 trims - [Congestion control by algorithm name](/quest/m2/congestion-names.md) - removes `quic::Config::controller`, the other unused transport hook - [A runtime-free QUIC driver](/quest/m4/quic-sansio-driver.md) - rebuilds the modules item 1 hides diff --git a/rs/moq-auth/src/request.rs b/rs/moq-auth/src/request.rs index f7079f0201a..12a768fd5d9 100644 --- a/rs/moq-auth/src/request.rs +++ b/rs/moq-auth/src/request.rs @@ -183,8 +183,10 @@ pub enum Transport { Quic, /// A WebSocket connection using qmux framing. WebSocket, - /// A TCP connection using qmux framing, plaintext or TLS. + /// A plaintext TCP connection using qmux framing. Tcp, + /// A TCP connection using qmux framing inside TLS, a `tls://` stream link. + Tls, /// A Unix domain socket using qmux framing. Unix, /// A one-shot HTTP request on the relay's web listener (`/fetch`, `/announced`), @@ -210,6 +212,7 @@ impl Transport { Self::Quic => "quic", Self::WebSocket => "websocket", Self::Tcp => "tcp", + Self::Tls => "tls", Self::Unix => "unix", Self::Http => "http", Self::Rtmp => "rtmp", @@ -429,6 +432,16 @@ mod tests { } } + #[test] + fn stream_link_transports_keep_their_own_names() { + for (transport, text) in [(Transport::Tcp, "tcp"), (Transport::Tls, "tls")] { + let request = Request::new("relay-1", transport, "/room"); + let json = serde_json::to_value(&request).unwrap(); + assert_eq!(json["transport"], text); + assert_eq!(serde_json::from_value::(json).unwrap(), request); + } + } + #[test] fn a_unix_session_has_no_addresses() { let request = Request::new("relay-1", Transport::Unix, ""); diff --git a/rs/moq-cli/src/main.rs b/rs/moq-cli/src/main.rs index 5210131b3b4..58247e6b320 100644 --- a/rs/moq-cli/src/main.rs +++ b/rs/moq-cli/src/main.rs @@ -222,10 +222,11 @@ impl Serving { } } -/// Whether ordinary clients may use this transport on the shared LAN server. +/// Whether ordinary clients may use this transport on the shared LAN server. A TLS stream link is +/// public the same way plaintext TCP is. fn is_public_transport(transport: moq_tokio::Transport, public_quic: bool) -> bool { match transport { - moq_tokio::Transport::Tcp | moq_tokio::Transport::Unix => true, + moq_tokio::Transport::Tcp | moq_tokio::Transport::Tls | moq_tokio::Transport::Unix => true, _ => public_quic, } } @@ -1733,6 +1734,7 @@ mod tests { #[test] fn explicit_stream_listeners_are_public_without_exposing_mesh_quic() { assert!(is_public_transport(moq_tokio::Transport::Tcp, false)); + assert!(is_public_transport(moq_tokio::Transport::Tls, false)); assert!(is_public_transport(moq_tokio::Transport::Unix, false)); assert!(!is_public_transport(moq_tokio::Transport::Quic, false)); assert!(is_public_transport(moq_tokio::Transport::Quic, true)); diff --git a/rs/moq-ffi/src/server.rs b/rs/moq-ffi/src/server.rs index 332069047ff..e593301c5c0 100644 --- a/rs/moq-ffi/src/server.rs +++ b/rs/moq-ffi/src/server.rs @@ -433,6 +433,8 @@ pub enum MoqTransport { WebSocket, /// A plaintext TCP connection using qmux framing. Tcp, + /// A TCP connection using qmux framing inside TLS, a `tls://` stream link. + Tls, /// A Unix domain socket using qmux framing. Unix, /// WebTransport over HTTP/3 on QUIC. @@ -447,6 +449,7 @@ impl TryFrom for MoqTransport { moq_tokio::Transport::Quic => Self::Quic, moq_tokio::Transport::WebSocket => Self::WebSocket, moq_tokio::Transport::Tcp => Self::Tcp, + moq_tokio::Transport::Tls => Self::Tls, moq_tokio::Transport::Unix => Self::Unix, moq_tokio::Transport::WebTransport => Self::WebTransport, _ => return Err(MoqError::Unsupported), @@ -467,6 +470,7 @@ mod transport_tests { MoqTransport::WebSocket ); assert_eq!(MoqTransport::try_from(Transport::Tcp).unwrap(), MoqTransport::Tcp); + assert_eq!(MoqTransport::try_from(Transport::Tls).unwrap(), MoqTransport::Tls); assert_eq!(MoqTransport::try_from(Transport::Unix).unwrap(), MoqTransport::Unix); assert_eq!( MoqTransport::try_from(Transport::WebTransport).unwrap(), diff --git a/rs/moq-relay/src/auth.rs b/rs/moq-relay/src/auth.rs index 3af10326673..a64fc849ba5 100644 --- a/rs/moq-relay/src/auth.rs +++ b/rs/moq-relay/src/auth.rs @@ -1291,6 +1291,7 @@ fn transport(transport: moq_tokio::Transport) -> moq_auth::Transport { moq_tokio::Transport::WebTransport => moq_auth::Transport::WebTransport, moq_tokio::Transport::WebSocket => moq_auth::Transport::WebSocket, moq_tokio::Transport::Tcp => moq_auth::Transport::Tcp, + moq_tokio::Transport::Tls => moq_auth::Transport::Tls, moq_tokio::Transport::Unix => moq_auth::Transport::Unix, moq_tokio::Transport::WebRtc => moq_auth::Transport::WebRtc, // A transport added to moq-tokio before this mapping learns it still reaches @@ -1546,7 +1547,15 @@ mod tests { #[test] fn every_transport_has_an_auth_name() { use moq_tokio::Transport as T; - for transport in [T::Quic, T::WebTransport, T::WebSocket, T::Tcp, T::Unix, T::WebRtc] { + for transport in [ + T::Quic, + T::WebTransport, + T::WebSocket, + T::Tcp, + T::Tls, + T::Unix, + T::WebRtc, + ] { assert_eq!(super::transport(transport).as_str(), transport.as_str()); } } diff --git a/rs/moq-relay/tests/integration/auth_lifetime.rs b/rs/moq-relay/tests/integration/auth_lifetime.rs index f18e41163f2..836ada6ee65 100644 --- a/rs/moq-relay/tests/integration/auth_lifetime.rs +++ b/rs/moq-relay/tests/integration/auth_lifetime.rs @@ -475,6 +475,7 @@ async fn admits_and_reports_the_session() { let connect = seen.iter().find(|r| r.event == Event::Connect).expect("a connect"); assert_eq!(connect.node, "test-relay"); assert_eq!(connect.transport, moq_auth::Transport::Tcp); + assert_eq!(pub_session.transport(), Some(moq_tokio::Transport::Tcp)); assert_eq!(connect.path, "/room"); assert_eq!(connect.query.as_deref(), Some("jwt=token")); assert!(connect.remote.is_some_and(|addr| addr.ip().is_loopback())); @@ -487,6 +488,29 @@ async fn admits_and_reports_the_session() { relay.abort(); } +/// A `tls://` session reaches the auth server as `tls`, and both ends of it report `tls`, so +/// a policy keyed on `tcp` sees only the plaintext link. +#[tokio::test] +async fn reports_a_tls_session_as_tls() { + let script = Script::new(grant(Duration::from_secs(3600))); + let mut config = moq_tokio::listen::Config::default(); + config.tcp.tls = Some(true); + config.tls.generate = vec!["localhost".into()]; + let cluster = crate::spawn_cluster(cluster::Options::default()); + let (port, relay) = spawn_relay_config(build_auth(script.spawn().await), cluster, config).await; + let (pub_session, sub_session) = connect_and_round_trip(&room_url("tls", port)).await; + + let seen = script.seen.lock().unwrap().clone(); + let connect = seen.iter().find(|r| r.event == Event::Connect).expect("a connect"); + assert_eq!(connect.transport, moq_auth::Transport::Tls); + assert_eq!(pub_session.transport(), Some(moq_tokio::Transport::Tls)); + assert_eq!(sub_session.transport(), Some(moq_tokio::Transport::Tls)); + + drop(pub_session); + drop(sub_session); + relay.abort(); +} + /// Write all of `data` to a raw qmux stream. async fn write_all(send: &mut qmux::SendStream, mut data: &[u8]) { use moq_net::transport::poll::SendStream as _; diff --git a/rs/moq-tokio/src/client.rs b/rs/moq-tokio/src/client.rs index 4f0026ebce2..62f0e48e172 100644 --- a/rs/moq-tokio/src/client.rs +++ b/rs/moq-tokio/src/client.rs @@ -503,7 +503,7 @@ impl Client { ) .await?; let session = connect_session(&moq, session).await?; - return Ok(Dialed::new(session, crate::Transport::Tcp)); + return Ok(Dialed::new(session, crate::Transport::Tls)); } // Unix domain socket (qmux, no TLS). Same-host only; the server can diff --git a/rs/moq-tokio/src/server.rs b/rs/moq-tokio/src/server.rs index 86ba46fea38..1b26cf0b09c 100644 --- a/rs/moq-tokio/src/server.rs +++ b/rs/moq-tokio/src/server.rs @@ -1295,7 +1295,7 @@ impl Incoming { .zip(session.peer_certificates()) .map(|(tls, chain)| tls.peer(chain.to_vec())); Self { - transport: Transport::Tcp, + transport: if tls.is_some() { Transport::Tls } else { Transport::Tcp }, url: None, link: Link { remote, diff --git a/rs/moq-tokio/src/tcp.rs b/rs/moq-tokio/src/tcp.rs index 6e14b5f4be9..9609965b8b9 100644 --- a/rs/moq-tokio/src/tcp.rs +++ b/rs/moq-tokio/src/tcp.rs @@ -639,7 +639,7 @@ mod tests { let url: Url = format!("tls://localhost:{port}/room?jwt=credential").parse().unwrap(); let accept = tokio::spawn(async move { let request = server.accept().await.unwrap(); - assert_eq!(request.transport(), crate::Transport::Tcp); + assert_eq!(request.transport(), crate::Transport::Tls); assert_eq!(request.path(), "/room"); assert_eq!(request.query(), Some("jwt=credential")); let session = request.ok().await.unwrap(); @@ -660,10 +660,11 @@ mod tests { matches!(untrusted, Ok(Err(_))), "an untrusted certificate must be refused" ); - let _session = kio::clock::timeout(Duration::from_secs(5), dial(true).established()) + let session = kio::clock::timeout(Duration::from_secs(5), dial(true).established()) .await .expect("trusted dial timed out") .expect("trusted dial failed"); + assert_eq!(session.transport(), Some(crate::Transport::Tls)); let (_server, _accepted) = kio::clock::timeout(Duration::from_secs(5), accept) .await .expect("accept timed out") diff --git a/rs/moq-tokio/src/transport.rs b/rs/moq-tokio/src/transport.rs index 4387b0c2260..75c2bb914dd 100644 --- a/rs/moq-tokio/src/transport.rs +++ b/rs/moq-tokio/src/transport.rs @@ -10,6 +10,8 @@ pub enum Transport { WebSocket, /// A plaintext TCP connection using qmux framing. Tcp, + /// A TCP connection using qmux framing inside TLS, a `tls://` stream link. + Tls, /// A Unix domain socket using qmux framing. Unix, /// WebTransport over HTTP/3 on QUIC. @@ -25,6 +27,7 @@ impl Transport { Self::Quic => "quic", Self::WebSocket => "websocket", Self::Tcp => "tcp", + Self::Tls => "tls", Self::Unix => "unix", Self::WebTransport => "webtransport", Self::WebRtc => "webrtc", From 0b096284eba3f071f20479d0ca74c6d2647beb13 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 17 Nov 2026 00:02:50 -0800 Subject: [PATCH 3/4] Format the merged transport test Co-Authored-By: Claude Sonnet 5.5 --- rs/moq-relay/src/auth.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/rs/moq-relay/src/auth.rs b/rs/moq-relay/src/auth.rs index b44c3b52a21..1691aae2c40 100644 --- a/rs/moq-relay/src/auth.rs +++ b/rs/moq-relay/src/auth.rs @@ -1536,14 +1536,7 @@ mod tests { #[test] fn every_transport_has_an_auth_name() { use moq_tokio::Transport as T; - for transport in [ - T::Quic, - T::WebTransport, - T::WebSocket, - T::Tcp, - T::Tls, - T::Unix, - ] { + for transport in [T::Quic, T::WebTransport, T::WebSocket, T::Tcp, T::Tls, T::Unix] { assert_eq!(super::transport(transport).as_str(), transport.as_str()); } } From 5cc6603788969798ad928742091ea2bd4dc36513 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 17 Nov 2026 00:52:38 -0800 Subject: [PATCH 4/4] Append Tls to the transport enums and qualify the auth upgrade note Co-Authored-By: Claude Sonnet 5.5 --- doc/bin/relay/auth.md | 5 +++-- rs/moq-auth/src/request.rs | 4 ++-- rs/moq-tokio/src/transport.rs | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/doc/bin/relay/auth.md b/doc/bin/relay/auth.md index e394b6ece56..154870ecc98 100644 --- a/doc/bin/relay/auth.md +++ b/doc/bin/relay/auth.md @@ -404,8 +404,9 @@ subscribe = [] Upgrade auth servers before relays when adopting the `webtransport` or `tls` transport value. WebTransport sessions report `webtransport`; native QUIC sessions report `quic`. `tls://` sessions report `tls`; plaintext `tcp://` sessions report `tcp`. -Older auth servers reject the new values. Updated Rust and JavaScript auth parsers -map future transport names to `unknown`, which your policy should handle explicitly. +An auth server built before `tls` existed does not fail to parse it: the Rust and JavaScript +parsers read an unrecognized transport name as `unknown`, so admission then depends on how your +policy treats `unknown`. Update any policy keyed on `tcp` for stream links to handle `tls` too. `moq auth serve` is the reference auth server, answering the contract above. diff --git a/rs/moq-auth/src/request.rs b/rs/moq-auth/src/request.rs index 002590031f8..da4294ca8d3 100644 --- a/rs/moq-auth/src/request.rs +++ b/rs/moq-auth/src/request.rs @@ -188,8 +188,6 @@ pub enum Transport { WebSocket, /// A plaintext TCP connection using qmux framing. Tcp, - /// A TCP connection using qmux framing inside TLS, a `tls://` stream link. - Tls, /// A Unix domain socket using qmux framing. Unix, /// A one-shot HTTP request on the relay's web listener (`/fetch`, `/announced`), @@ -203,6 +201,8 @@ pub enum Transport { WebRtc, /// A WebTransport connection over HTTP/3. WebTransport, + /// A TCP connection using qmux framing inside TLS, a `tls://` stream link. + Tls, /// A transport name this auth server does not recognize. #[serde(other)] Unknown, diff --git a/rs/moq-tokio/src/transport.rs b/rs/moq-tokio/src/transport.rs index 796a963ff5d..bf2cc4532a8 100644 --- a/rs/moq-tokio/src/transport.rs +++ b/rs/moq-tokio/src/transport.rs @@ -10,12 +10,12 @@ pub enum Transport { WebSocket, /// A plaintext TCP connection using qmux framing. Tcp, - /// A TCP connection using qmux framing inside TLS, a `tls://` stream link. - Tls, /// A Unix domain socket using qmux framing. Unix, /// WebTransport over HTTP/3 on QUIC. WebTransport, + /// A TCP connection using qmux framing inside TLS, a `tls://` stream link. + Tls, } impl Transport { @@ -25,9 +25,9 @@ impl Transport { Self::Quic => "quic", Self::WebSocket => "websocket", Self::Tcp => "tcp", - Self::Tls => "tls", Self::Unix => "unix", Self::WebTransport => "webtransport", + Self::Tls => "tls", } } }