diff --git a/Cargo.lock b/Cargo.lock index 004024f3e4b..96db2f02f4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4645,6 +4645,7 @@ dependencies = [ "hashlink", "kio", "libc", + "moq-net", "moq-pattern", "num_enum", "proptest", diff --git a/doc/bin/relay/config.md b/doc/bin/relay/config.md index 225dc917488..b627823467e 100644 --- a/doc/bin/relay/config.md +++ b/doc/bin/relay/config.md @@ -8,7 +8,7 @@ description: TOML reference for moq-relay `moq-relay relay.toml`. Every key is also a CLI flag and environment variable that joins the section and key: `listen.tls.cert` is `--listen-tls-cert` / `MOQ_LISTEN_TLS_CERT`. The exceptions: `listen.bind` is spelled `--listen` / -`MOQ_LISTEN`, and `listen.extensions` and `connect.extensions` are TOML only. +`MOQ_LISTEN`. Precedence is CLI, then env, then file, then defaults. `moq-relay --help` lists every flag. @@ -45,10 +45,6 @@ bind = "127.0.0.1:4444" [listen.unix] # Plaintext qmux over a Unix socket, gated by peer credentials. bind = "/run/moq/internal.sock" allow.uid = [1001] - -[listen.extensions] # moq-transport SETUP extensions to offer, each on by default. - # The relay always offers ietf, for moq-lite-07 relay links. -solicit = false # Decline MoQ Solicit, so peers may announce unasked. ``` `timeout` bounds the whole handshake, transport through MoQ SETUP and auth @@ -305,7 +301,6 @@ tls.cert = "relay.pem" # Present a client certificate (mTLS to pee tls.key = "relay.key" goaway.redirect = "same-host" # How far to trust a draining peer's redirect URI. goaway.handover = "10s" # Cap on how long the drained upstream keeps serving. -extensions.solicit = false # Decline MoQ Solicit on outbound moq-transport sessions, as in [listen.extensions]. ``` A draining upstream may name a replacement URI. `same-host` follows it only diff --git a/doc/concept/standard.md b/doc/concept/standard.md index 19366d00d4f..436b1d587f4 100644 --- a/doc/concept/standard.md +++ b/doc/concept/standard.md @@ -55,8 +55,7 @@ ignores unknown parameters: [cluster](/draft/moq-cluster) routing hop lists, [hidden](/draft/moq-hidden) to keep `.`-named namespaces out of discovery, and [active-count](/draft/moq-active-count) to count the `NAMESPACE` messages before a `SUBSCRIBE_NAMESPACE` is synced. -Both libraries offer solicit unless a side's `extensions` setting declines it, -which connects it as a peer that does not speak that extension. The pooled JavaScript `Connection` has no such setting yet. +Both libraries always offer solicit. moq-transport carries no [publisher instance](/concept/moq-lite#publisher-instances), so the receiving session mints one per announcement. @@ -71,8 +70,10 @@ does and a browser session does not yet. [ietf](/draft/moq-ietf) goes the other way: it extends moq-lite-07 to carry this object state between relays. moq-lite-07 is still a work in progress (`moq-lite-07-wip`), negotiated only when both sides enable it, so a peer that -does not offer it does not carry this state. Only Rust offers the extension, when -`extensions.ietf` is set, and `moq-relay` always does on moq-lite-07. +does not offer it does not carry this state. Only `moq-relay` offers the extension, +always, on moq-lite-07. It costs a moq-lite track nothing: only a track a moq-transport +publisher made carries the state, so the groups of any other cross the hop byte for +byte as they would without the extension. [moq-e2ee](/draft/moq-e2ee), published and experimental, is not a transport extension. It encrypts application payloads, so relays still forward named tracks they cannot read. See [Encryption](/concept/hang#encryption). diff --git a/drafts/draft-lcurley-moq-ietf.md b/drafts/draft-lcurley-moq-ietf.md index 13494b99c80..dab8dee2243 100644 --- a/drafts/draft-lcurley-moq-ietf.md +++ b/drafts/draft-lcurley-moq-ietf.md @@ -26,6 +26,7 @@ informative: This document defines an extension for moq-lite {{moql}} that carries the object state of MoQ Transport {{moqt}} across a moq-lite session between two relays. A track a MoQ Transport publisher sends through relay A, then over moq-lite to relay B, reaches a MoQ Transport subscriber of relay B as it would through one relay: with its Object IDs, gaps, properties, and END_OF_GROUP status. +A datagram track keeps only what moq-lite carries. --- note_Note_to_Readers @@ -37,7 +38,7 @@ Submit an [issue](https://github.com/moq-dev/moq/issues) or [PR](https://github. # Conventions and Definitions {::boilerplate bcp14-tagged} -A **relayed** group or datagram arrived from a MoQ Transport publisher, so it has object state that moq-lite cannot express. +A **relayed** group arrived from a MoQ Transport publisher, so it has object state that moq-lite cannot express. A **plain** one has none: its Object IDs are its frame indices, it has no properties, and its group ends where its last frame does. A track's **Version** is the {{moqt}} version its original publisher spoke, which serialized every property it carries, or none for a track published over moq-lite ([Track Stream](#track)). @@ -62,14 +63,15 @@ An endpoint offers the extension with the following Setup Parameter ({{moql}} SE The value MUST be empty; a receiver MUST close the session with a PROTOCOL_VIOLATION otherwise. The extension is negotiated only when both endpoints offer it, and only on moq-lite-07 and later. -An endpoint MUST NOT send any field this document defines unless the extension is negotiated, and MUST NOT parse a Group Stream, FETCH response, Track Stream, or datagram from the peer until it has the peer's SETUP and so knows whether it was. -An endpoint MAY drop a datagram that arrives before then. -A Group Stream, FETCH response, or datagram is read with the Version of its track, which the Track Stream carries before any subscription or fetch opens. +An endpoint MUST NOT send any field this document defines unless the extension is negotiated, and MUST NOT parse a Group Stream, FETCH response, or Track Stream from the peer until it has the peer's SETUP and so knows whether it was. +A Group Stream or FETCH response is read with the Version of its track, which the Track Stream carries before any subscription or fetch opens. # Group Streams {#group} -When the extension is negotiated, a Group Stream carries a Group State after the GROUP message, and an Object Record before each FRAME. -A FETCH response carries the same, with the Group State first. +When the extension is negotiated, a Group Stream of a track with a Version carries a Group State after the GROUP message, and an Object Record before each FRAME. +A FETCH response for such a track carries the same, with the Group State first. +A Group Stream or FETCH response of a track without a Version is exactly as {{moql}} defines it, so the extension costs a track published over moq-lite nothing. +Datagrams are unchanged too: a datagram track ({{moql}}) has no Track Stream and so no Version. ~~~ Group Stream { @@ -93,7 +95,6 @@ A bit field describing the group's relay state, or 0 for a plain group: - `0x8` **END_OF_GROUP**: The stream's end ends the group, as a {{moqt}} subgroup that contains the end of its group. A receiver MUST reset the stream with a PROTOCOL_VIOLATION on any other bit, a bit without RELAYED, or a record with Properties when EXTENSIONS is clear. -A track without a Version has no {{moqt}} state, so a receiver MUST reset the stream with a PROTOCOL_VIOLATION on any Group State but 0 for one. A publisher MUST clear FIRST_OBJECT when the stream starts after the first frame it holds, and END_OF_GROUP when the stream may stop before the end of the group, such as at a subscription's end frame. A stream that stops at an end frame carries no END_OF_GROUP record, even when that frame is the group's last. @@ -134,11 +135,10 @@ A relay forwards the block to a peer of that encoding unchanged, so the block ne Every property of the object, serialized as the track's Version serializes an object's properties, in ascending ID order. Immutable Properties (0x0b) are in the same encoding, as the publisher sent them. It MUST NOT be empty or longer than 65,536 bytes. -A track without a Version carries no properties: a Property Block on one is malformed. -On a timed track an object with a FRAME, or a datagram without a Status, MUST NOT carry one longer than 65,526 bytes, leaving room for the largest Timestamp a relay restates ([Timestamps](#timestamps)): a one-byte key and a value of up to nine bytes. +On a timed track an object with a FRAME MUST NOT carry one longer than 65,526 bytes, leaving room for the largest Timestamp a relay restates ([Timestamps](#timestamps)): a one-byte key and a value of up to nine bytes. A relay MUST refuse a {{moqt}} object whose properties, less its mutable Timestamp, exceed that, so every object it forwards fits. A receiver MUST treat a block the track's Version would refuse as malformed, as it MUST a block on an object that Version could not send with properties. -Only draft 14 lets a status object carry them, so a block on the END_OF_GROUP record needs a Version of draft 14, and a datagram with a block MUST have fields an OBJECT_DATAGRAM Type of its Version carries ([Datagrams](#datagrams)). +Only draft 14 lets a status object carry them, so a block on the END_OF_GROUP record needs a Version of draft 14. The Version also gives each property its meaning: drafts 18 and 19 serialize a block alike, but only drafts 19 and later assign property 0x06 to SUBGROUP_DELIVERY_TIMEOUT, so a relay knows not to forward a 0x06 to a draft that would read it differently. Other properties are opaque to this extension. @@ -148,13 +148,13 @@ A nonzero Version identifies timestamps from MoQ Transport, which may be arrival The receiver MUST NOT apply moq-lite's group-start rewind check to such a track; a Version of zero retains that check. Without this extension, or in a listing ({{track}}), the receiver may check them like native moq-lite timestamps and refuse a Group that rewinds. -On a timed track, the FRAME's Timestamp, or the datagram's for a datagram, is the object's time, and nothing else carries it. +On a timed track, the FRAME's Timestamp is the object's time, and nothing else carries it. The Property Block MUST NOT contain a mutable Timestamp (0x10) there; a receiver MUST treat one as malformed. A relay forwarding the object to {{moqt}} restates the time as the mutable Timestamp, unless a Timestamp inside the Immutable Properties already says it. A sealed Timestamp is in the track's Timescale ({{moql}} TRACK_INFO), and a relay MUST NOT forward one to a peer of other units, which would change its meaning. On an untimed track there is no FRAME Timestamp, so a mutable Timestamp stays in the Property Block as an opaque property. -Likewise, an object without a FRAME, such as the END_OF_GROUP record or a datagram with a non-zero Status, has no time of its own beside the block, so its mutable Timestamp stays there on any track. +Likewise, the END_OF_GROUP record has no FRAME and so no time of its own beside the block, so its mutable Timestamp stays there on any track. # Track Stream {#track} @@ -203,43 +203,6 @@ A TRACKS_ADD ({{moql}} Tracks Stream) embeds TRACK_INFO without TRACK_PROPERTIES Lacking the Version, a TRACKS_ADD cannot mark a {{moqt}} track's timestamps as unchecked ({{timestamps}}). -# Datagrams {#datagrams} -When the extension is negotiated, a DATAGRAM carries a Datagram State after its Group Sequence. - -~~~ -DATAGRAM Body { - Subscribe ID (i) - Group Sequence (i) - Datagram State (i) - [Object ID (i)] - [Publisher Priority (8)] - [Status (i)] - [Properties Length (i), Properties (..)] - [Timestamp (i)] - [Inflated Size (i)] - Payload (b) -} -~~~ - -**Datagram State**: -A bit field, or 0 for a plain datagram, which has none of the optional fields before the Timestamp: - -- `0x1` **RELAYED**: The datagram is relayed, so its Properties follow. Every other bit requires it. -- `0x2` **OBJECT_ID**: The Object ID follows. -- `0x4` **PRIORITY**: The {{moqt}} Publisher Priority follows. -- `0x8` **END_OF_GROUP**: The object ends its group. -- `0x10` **STATUS**: The {{moqt}} Object Status follows. - -A receiver MUST drop a datagram with any other bit, a bit without RELAYED, or any bit on a track without a Version. - -A datagram with a Status MUST have an empty Payload, as {{moqt}} sends no payload beside one; a Normal (0) Status is an empty object. -It has no Inflated Size ({{moql}} DATAGRAM), even on a compressed track, as there is no payload to inflate. -A non-zero Status carries no object: it has no Timestamp, even on a timed track. -A receiver MUST drop a datagram whose Status no {{moqt}} draft defines: only 0 (Normal), 1 (DOES_NOT_EXIST, drafts 14 and 15), 3 (END_OF_GROUP), and 4 (END_OF_TRACK) are relayed. -It MUST also drop one its track's Version could not send: whose fields no OBJECT_DATAGRAM Type of that Version carries, such as STATUS with END_OF_GROUP, or whose Status it does not define. -From draft 17 on a non-zero Status carries no properties, and only drafts 14 and 15 define DOES_NOT_EXIST. - - # Security Considerations A peer sets how much state a receiver holds for each object, up to a 65,536-byte Property Block. A receiver SHOULD hold the block as received, not decoded, and charge it to the group's cache budget like a payload. diff --git a/js/net/src/connection/accept.ts b/js/net/src/connection/accept.ts index c8246f270dc..be989d74876 100644 --- a/js/net/src/connection/accept.ts +++ b/js/net/src/connection/accept.ts @@ -8,7 +8,6 @@ import type { Consumer as OriginConsumer, Producer as OriginProducer } from "../ import { Stream } from "../stream.ts"; import { untilAborted } from "../util/abort.ts"; import { after } from "../util/timer.ts"; -import * as Extensions from "./extensions.ts"; import { DISCOVERY_REMOVED, forwardAnnounced } from "./forward.ts"; import { DEFAULT_TIMEOUT, exchangeSetup, handsOff } from "./handshake.ts"; import type { Session } from "./session.ts"; @@ -40,13 +39,6 @@ export interface AcceptProps { */ consume?: OriginProducer; - /** - * The moq-transport extensions to offer, each on unless set to `false`. - * - * @internal Tests only; nothing outside the package consumes it. - */ - extensions?: Extensions.Extensions; - /** The implementation this side advertises in SETUP; see the `implementation` connect option. */ implementation?: string; } @@ -56,8 +48,6 @@ type SessionProps = { publish?: OriginConsumer; /** Whether this side dialed; only the dialing side aborts on a publication its grant does not cover. */ client: boolean; - /** The moq-transport extensions this side offers. */ - extensions: Extensions.Offered; /** The implementation this side advertises in SETUP; empty sends nothing. */ implementation: string; }; @@ -115,7 +105,6 @@ async function acceptInner( const wiring: SessionProps = { publish: props.publish, client: false, - extensions: Extensions.offered(props.extensions), implementation: props.implementation ?? IMPLEMENTATION, }; diff --git a/js/net/src/connection/connect.ts b/js/net/src/connection/connect.ts index a2a8fc12ad1..d1bd432a38e 100644 --- a/js/net/src/connection/connect.ts +++ b/js/net/src/connection/connect.ts @@ -14,7 +14,6 @@ import * as Hex from "../util/hex.ts"; import { after } from "../util/timer.ts"; import { isWebTransportSupported } from "./browser.ts"; import { parse, show } from "./endpoint.ts"; -import * as Extensions from "./extensions.ts"; import { DISCOVERY_REMOVED, forwardAnnounced } from "./forward.ts"; import { DEFAULT_TIMEOUT, exchangeSetup, handsOff } from "./handshake.ts"; import type { Session } from "./session.ts"; @@ -251,13 +250,6 @@ export interface ConnectProps { */ consume?: OriginProducer; - /** - * The moq-transport extensions to offer, each on unless set to `false`. - * - * @internal Tests only; nothing outside the package consumes it. - */ - extensions?: Extensions.Extensions; - /** * Credentials to present, kept apart from the URL. * @@ -313,8 +305,6 @@ type SessionProps = { handle?: Auth.Handle; /** Whether this side dialed; only the dialing side aborts on a publication its grant does not cover. */ client: boolean; - /** The moq-transport extensions this side offers. */ - extensions: Extensions.Offered; /** The connection credential SETUP presents, on versions that carry one. */ token?: Uint8Array; /** The implementation this side advertises in SETUP; empty sends nothing. */ @@ -475,7 +465,6 @@ async function connectInner( publish: props.publish, handle: props.auth, client: true, - extensions: Extensions.offered(props.extensions), token: presented.setup === undefined ? undefined : new TextEncoder().encode(presented.setup), implementation: props.implementation ?? IMPLEMENTATION, probeTarget: props.viewers?.target, diff --git a/js/net/src/connection/extensions.test.ts b/js/net/src/connection/extensions.test.ts deleted file mode 100644 index 74314d9f9a3..00000000000 --- a/js/net/src/connection/extensions.test.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { expect, spyOn, test } from "bun:test"; -import { PublishNamespace } from "../ietf/publish_namespace.ts"; -import { RequestOk } from "../ietf/request.ts"; -import { ALPN, Version } from "../ietf/version.ts"; -import { createMockTransportPair } from "../mock.ts"; -import * as Path from "../path.ts"; -import { Stream } from "../stream.ts"; -import { accept } from "./accept.ts"; -import { type Extensions, offered } from "./extensions.ts"; -import { exchangeSetup } from "./handshake.ts"; - -const VERSION = Version.DRAFT_18; -const URL_ = new URL("https://example.com"); - -/** What each side learns from the other's SETUP when each offers `client` and `server`. */ -async function handshake(client: Extensions, server: Extensions) { - const pair = createMockTransportPair(ALPN.DRAFT_18); - const [dialed, accepted] = await Promise.all([ - exchangeSetup(pair.client, VERSION, "test", { client: true, extensions: offered(client) }), - exchangeSetup(pair.server, VERSION, "test", { client: false, extensions: offered(server) }), - ]); - return { dialed, accepted }; -} - -/** Accept a draft-18 session offering `extensions`, against a peer offering every extension. */ -async function acceptWith(extensions: Extensions) { - const pair = createMockTransportPair(ALPN.DRAFT_18); - const [peer, connection] = await Promise.all([ - exchangeSetup(pair.client, VERSION, "test", { client: true, extensions: offered() }), - accept({ transport: pair.server, url: URL_, extensions }), - ]); - return { pair, peer, connection }; -} - -test("a declined extension stays out of SETUP", async () => { - // Control: both sides offer it. - const all = await handshake({}, {}); - expect(all.accepted.solicit).toBe(true); - - const none = await handshake({ solicit: false }, {}); - expect(none.accepted.solicit).toBeUndefined(); - expect(none.dialed.solicit).toBe(true); -}); - -test("a side that declined solicit takes an unsolicited announce", async () => { - const announce = async (session: Awaited>) => { - const stream = await Stream.open(session.pair.client, { version: VERSION }); - await stream.writer.u53(PublishNamespace.id); - await new PublishNamespace({ - requestId: 0n, - trackNamespace: Path.from("room"), - params: { cluster: { hops: [session.peer.cluster.self], cost: 0n } }, - }).encode(stream.writer, VERSION); - return stream; - }; - - const declined = await acceptWith({ solicit: false }); - const taken = await announce(declined); - expect(await taken.reader.u53()).toBe(RequestOk.id); - declined.connection.close(); - - // Control: our SETUP declared it, so the peer that implements it broke it. - const logged = spyOn(console, "error").mockImplementation(() => void 0); - try { - const declaring = await acceptWith({}); - await announce(declaring); - await declaring.pair.client.closed; - expect(logged).toHaveBeenCalled(); - } finally { - logged.mockRestore(); - } -}); diff --git a/js/net/src/connection/extensions.ts b/js/net/src/connection/extensions.ts deleted file mode 100644 index f157fc34990..00000000000 --- a/js/net/src/connection/extensions.ts +++ /dev/null @@ -1,26 +0,0 @@ -import * as Ietf from "../ietf/index.ts"; - -/** - * The moq-transport extensions a session offers in its SETUP, each on unless set to `false`. - * Turning one off connects as a peer that does not speak it. moq-lite carries them in its - * core, so this only changes moq-transport sessions. - */ -export interface Extensions { - /** The MoQ Solicit extension: the peer answers our SUBSCRIBE_NAMESPACE rather than announcing unasked. */ - solicit?: boolean; -} - -/** Every extension resolved to whether it is offered. */ -export type Offered = Required; - -/** Resolve each unset extension to offered. */ -export function offered(extensions?: Extensions): Offered { - return { - solicit: extensions?.solicit ?? true, - }; -} - -/** Write the options for the offered extensions into a SETUP. */ -export function intoSetup(params: Ietf.SetupOptions, extensions: Offered) { - if (extensions.solicit) Ietf.solicitIntoSetup(params); -} diff --git a/js/net/src/connection/handshake.ts b/js/net/src/connection/handshake.ts index 50f6d3ecc38..00dcc67de94 100644 --- a/js/net/src/connection/handshake.ts +++ b/js/net/src/connection/handshake.ts @@ -5,7 +5,6 @@ import * as Ietf from "../ietf/index.ts"; import * as Message from "../ietf/message.ts"; import * as Lite from "../lite/index.ts"; import { acceptBudget, Reader, Stream, UnexpectedEnd, Writer } from "../stream.ts"; -import * as Extensions from "./extensions.ts"; /** Default bound on a connection attempt, including its SETUP exchange. @internal */ export const DEFAULT_TIMEOUT = Duration.millis(30_000); @@ -20,8 +19,8 @@ export const DEFAULT_TIMEOUT = Duration.millis(30_000); * {@link receiveSetup}), plus what the peer's SETUP declared: whether it requires * solicitation, which decides whether we announce namespaces unprompted (see the MoQ Solicit * extension) and its Hop ID (see the MoQ Cluster extension), plus the implementation it - * advertised. We declare our Hop ID on every session, and Solicit unless `extensions` - * declines it: we send SUBSCRIBE_NAMESPACE for each prefix we want, so an unsolicited advertisement + * advertised. We declare our Hop ID and Solicit on every session: we send + * SUBSCRIBE_NAMESPACE for each prefix we want, so an unsolicited advertisement * can tell us nothing we won't have asked for, and a peer that knows our Hop ID can withhold * the advertisements that already flowed through us. */ @@ -29,11 +28,21 @@ export async function exchangeSetup( transport: WebTransport, version: Ietf.IetfVersion, implementation: string, - { client, extensions, token }: { client: boolean; extensions: Extensions.Offered; token?: Uint8Array }, + { + client, + token, + solicit = true, + }: { + client: boolean; + token?: Uint8Array; + /** Declare MoQ Solicit. `false` only in a test acting as a peer without it. */ + solicit?: boolean; + }, ): Promise<{ control: Stream; early: Reader[]; solicit: boolean | undefined; + declaredSolicit: boolean; hidden: boolean; maxAge: boolean; activeCount: boolean; @@ -42,7 +51,7 @@ export async function exchangeSetup( }> { const params = new Ietf.SetupOptions(); Ietf.implementationIntoSetup(params, implementation); - Extensions.intoSetup(params, extensions); + if (solicit) Ietf.solicitIntoSetup(params); Ietf.hiddenIntoSetup(params); Ietf.maxAgeIntoSetup(params); Ietf.activeCountIntoSetup(params); @@ -74,6 +83,7 @@ export async function exchangeSetup( control: new Stream({ writer, reader: received.reader }), early: received.early, solicit: received.solicit, + declaredSolicit: solicit, hidden: received.hidden, maxAge: received.maxAge, activeCount: received.activeCount, diff --git a/js/net/src/connection/reload.ts b/js/net/src/connection/reload.ts index 90f5e77c788..554d720d4e0 100644 --- a/js/net/src/connection/reload.ts +++ b/js/net/src/connection/reload.ts @@ -93,13 +93,13 @@ export type ReloadDelay = { * {@link ConnectProps.transport} is excluded: a supplied session is good for exactly one * connection, so the reconnect loop has nothing to reuse once that session drops. Call * {@link connect} directly when you have a session to hand over. Every attempt advertises - * the default {@link ConnectProps.implementation} and {@link ConnectProps.extensions}. + * the default {@link ConnectProps.implementation}. * * @internal */ export type ReloadProps = Omit< ConnectProps, - "url" | "signal" | "transport" | "implementation" | "extensions" | "tokens" | "viewers" + "url" | "signal" | "transport" | "implementation" | "tokens" | "viewers" > & { /** See {@link ConnectProps.tokens}; pass a `Signal` to replace them before they expire. */ tokens?: readonly string[] | Signal; diff --git a/js/net/src/connection/solicit.test.ts b/js/net/src/connection/solicit.test.ts new file mode 100644 index 00000000000..a5d7af524fb --- /dev/null +++ b/js/net/src/connection/solicit.test.ts @@ -0,0 +1,76 @@ +import { expect, spyOn, test } from "bun:test"; +import { Connection } from "../ietf/connection.ts"; +import { PublishNamespace } from "../ietf/publish_namespace.ts"; +import { RequestOk } from "../ietf/request.ts"; +import { ALPN, Version } from "../ietf/version.ts"; +import { createMockTransportPair } from "../mock.ts"; +import * as Path from "../path.ts"; +import { Stream } from "../stream.ts"; +import { accept } from "./accept.ts"; +import { exchangeSetup } from "./handshake.ts"; + +const VERSION = Version.DRAFT_18; +const URL_ = new URL("https://example.com"); + +test("a peer without MoQ Solicit leaves it out of SETUP", async () => { + const handshake = async (solicit: boolean) => { + const pair = createMockTransportPair(ALPN.DRAFT_18); + const [dialed, accepted] = await Promise.all([ + exchangeSetup(pair.client, VERSION, "test", { client: true, solicit }), + exchangeSetup(pair.server, VERSION, "test", { client: false }), + ]); + return { dialed, accepted }; + }; + + const declared = await handshake(true); + expect(declared.accepted.solicit).toBe(true); + + const peer = await handshake(false); + expect(peer.accepted.solicit).toBeUndefined(); + expect(peer.dialed.solicit).toBe(true); +}); + +test("a peer that implements MoQ Solicit may not announce unasked", async () => { + const pair = createMockTransportPair(ALPN.DRAFT_18); + const [peer, connection] = await Promise.all([ + exchangeSetup(pair.client, VERSION, "test", { client: true }), + accept({ transport: pair.server, url: URL_ }), + ]); + + const logged = spyOn(console, "error").mockImplementation(() => void 0); + try { + const stream = await Stream.open(pair.client, { version: VERSION }); + await stream.writer.u53(PublishNamespace.id); + await new PublishNamespace({ + requestId: 0n, + trackNamespace: Path.from("room"), + params: { cluster: { hops: [peer.cluster.self], cost: 0n } }, + }).encode(stream.writer, VERSION); + await pair.client.closed; + expect(logged).toHaveBeenCalled(); + } finally { + logged.mockRestore(); + connection.close(); + } +}); + +test("a side that declined MoQ Solicit takes an unasked announce", async () => { + const pair = createMockTransportPair(ALPN.DRAFT_18); + const [peer, setup] = await Promise.all([ + exchangeSetup(pair.client, VERSION, "test", { client: true }), + exchangeSetup(pair.server, VERSION, "test", { client: false, solicit: false }), + ]); + const connection = new Connection({ url: URL_, quic: pair.server, version: VERSION, client: false, ...setup }); + try { + const stream = await Stream.open(pair.client, { version: VERSION }); + await stream.writer.u53(PublishNamespace.id); + await new PublishNamespace({ + requestId: 0n, + trackNamespace: Path.from("room"), + params: { cluster: { hops: [peer.cluster.self], cost: 0n } }, + }).encode(stream.writer, VERSION); + expect(await stream.reader.u53()).toBe(RequestOk.id); + } finally { + await connection.close(); + } +}); diff --git a/js/net/src/connection/tokens.test.ts b/js/net/src/connection/tokens.test.ts index 759e88f9640..ce18f75e080 100644 --- a/js/net/src/connection/tokens.test.ts +++ b/js/net/src/connection/tokens.test.ts @@ -4,7 +4,6 @@ import type { Pending } from "../auth_session.ts"; import * as Ietf from "../ietf/index.ts"; import { createMockTransportPair } from "../mock.ts"; import { Reader } from "../stream.ts"; -import { offered } from "./extensions.ts"; import { exchangeSetup } from "./handshake.ts"; import type { Session } from "./session.ts"; import { credential, extra, fallback, Held, hold } from "./tokens.ts"; @@ -135,7 +134,7 @@ test("an IETF client presents its token in SETUP", async () => { const pair = createMockTransportPair(Ietf.ALPN.DRAFT_18); const token = new TextEncoder().encode("credential"); // Never answered: only the SETUP the client writes matters here. - void exchangeSetup(pair.client, version, "test", { client: true, extensions: offered(), token }).catch(() => {}); + void exchangeSetup(pair.client, version, "test", { client: true, token }).catch(() => {}); const streams = pair.server.incomingUnidirectionalStreams.getReader(); const next = await streams.read(); diff --git a/js/net/src/ietf/connection.test.ts b/js/net/src/ietf/connection.test.ts index a4a6e7b3e0f..bdbb532bf1e 100644 --- a/js/net/src/ietf/connection.test.ts +++ b/js/net/src/ietf/connection.test.ts @@ -1,6 +1,5 @@ import { expect, spyOn, test } from "bun:test"; import { yieldNow } from "@moq/clock"; -import { offered } from "../connection/extensions.ts"; import { exchangeSetup } from "../connection/handshake.ts"; import { SessionCode } from "../error.ts"; import { createMockTransportPair } from "../mock.ts"; @@ -257,7 +256,6 @@ test("uni streams before SETUP are held until it lands", async () => { const { control, early, solicit, hidden, cluster } = await exchangeSetup(pair.server, version, "test", { client: false, - extensions: offered(), }); expect(early.length).toBe(2); @@ -305,7 +303,7 @@ test("truncated uni stream before SETUP is skipped", async () => { parameters.setBytes(SetupOption.Implementation, new TextEncoder().encode("test")); await new Setup({ parameters }).encode(setup, version); - const { early } = await exchangeSetup(pair.server, version, "test", { client: false, extensions: offered() }); + const { early } = await exchangeSetup(pair.server, version, "test", { client: false }); expect(early.length).toBe(0); }); diff --git a/js/net/src/ietf/connection.ts b/js/net/src/ietf/connection.ts index a5808b7adf9..cdea17c6291 100644 --- a/js/net/src/ietf/connection.ts +++ b/js/net/src/ietf/connection.ts @@ -121,13 +121,13 @@ export class Connection implements Session { client, publish, solicit, + declaredSolicit = true, hidden = false, maxAge = false, activeCount = false, cluster, handle, early = [], - extensions, peerImplementation, }: { url: URL; @@ -143,6 +143,8 @@ export class Connection implements Session { * nothing, which is the one case where announcing at us unasked is not a bug. */ solicit?: boolean; + /** Whether our own SETUP declared MoQ Solicit; `false` only in a test acting as a peer without it. */ + declaredSolicit?: boolean; /** Whether the peer understands the HIDDEN parameter (MoQ Hidden). */ hidden?: boolean; /** Whether the peer accepts subscriber max age. */ @@ -158,8 +160,6 @@ export class Connection implements Session { handle?: Auth.Handle; /** Uni streams that arrived before the peer's SETUP, type unread. */ early?: Reader[]; - /** What our own SETUP offered; every extension when omitted. */ - extensions?: { solicit: boolean }; /** The implementation the peer's SETUP advertised, read before the session starts. */ peerImplementation?: string; }) { @@ -208,7 +208,7 @@ export class Connection implements Session { auth: this.#auth, }); this.#solicit = solicit; - this.#declaredSolicit = extensions?.solicit ?? true; + this.#declaredSolicit = declaredSolicit; this.#cluster = cluster; this.#subscriber = new Subscriber({ maxAge, @@ -407,7 +407,7 @@ export class Connection implements Session { const msg = await this.#request(stream, "publish_namespace", decoded); if (!msg) break; - // Unless we declined it, we declare that advertisements to us must be + // Unless a test declined it, we declare that advertisements to us must be // solicited (MoQ Solicit), and writing the option at all proves the peer // implements the extension, whichever value it chose. It also cannot have // advertised before reading our SETUP, since our SETUP is what says whether diff --git a/js/net/src/ietf/malformed.test.ts b/js/net/src/ietf/malformed.test.ts index 398d447804b..57d17924007 100644 --- a/js/net/src/ietf/malformed.test.ts +++ b/js/net/src/ietf/malformed.test.ts @@ -1,7 +1,6 @@ import { expect, spyOn, test } from "bun:test"; import { Duration } from "@moq/clock"; import type { Manual } from "@moq/clock/test"; -import { offered } from "../connection/extensions.ts"; import { exchangeSetup } from "../connection/handshake.ts"; import { ProtocolViolation, SessionCode, StreamCode, StreamError } from "../error.ts"; import { createMockTransportPair, manual } from "../mock.ts"; @@ -271,7 +270,7 @@ for (const [version, alpn] of DRAFTS) { parameters.setBytes(key, new Uint8Array(value)); await new Setup({ parameters }).encode(setup, version); - const dialed = exchangeSetup(pair.client, version, "test", { client: true, extensions: offered() }); + const dialed = exchangeSetup(pair.client, version, "test", { client: true }); if (code === undefined) { await dialed; pair.client.close(); diff --git a/js/net/src/ietf/solicit.ts b/js/net/src/ietf/solicit.ts index c7f3d135317..fd74c14d040 100644 --- a/js/net/src/ietf/solicit.ts +++ b/js/net/src/ietf/solicit.ts @@ -37,9 +37,8 @@ export function solicitFromSetup(params: SetupOptions): boolean | undefined { /** * Declare that advertisements to us must be solicited. * - * Declared unless the session's `extensions` declines it: we send SUBSCRIBE_NAMESPACE for - * each prefix we want, so there is nothing an unsolicited PUBLISH_NAMESPACE could tell us - * that we will not have asked for. + * Always declared: we send SUBSCRIBE_NAMESPACE for each prefix we want, so there is + * nothing an unsolicited PUBLISH_NAMESPACE could tell us that we will not have asked for. * * @internal */ diff --git a/nix/Cargo.nix b/nix/Cargo.nix index 537c917bfad..b82b6423542 100644 --- a/nix/Cargo.nix +++ b/nix/Cargo.nix @@ -18537,6 +18537,12 @@ rec { name = "moq-loc"; packageId = "moq-loc"; } + { + name = "moq-tokio"; + packageId = "moq-tokio"; + usesDefaultFeatures = false; + features = [ "test-support" ]; + } { name = "moq-video"; packageId = "moq-video"; @@ -19277,6 +19283,12 @@ rec { name = "moq-shaper"; packageId = "moq-shaper"; } + { + name = "moq-tokio"; + packageId = "moq-tokio"; + usesDefaultFeatures = false; + features = [ "test-support" ]; + } { name = "moq-video"; packageId = "moq-video"; @@ -20178,6 +20190,14 @@ rec { packageId = "libc"; target = { target, features }: (target."unix" or false); } + { + name = "moq-net"; + packageId = "moq-net"; + features = [ + "relay" + "test-support" + ]; + } { name = "proptest"; packageId = "proptest"; @@ -20218,6 +20238,8 @@ rec { "async" "default" "fuzz" + "relay" + "test-support" ]; }; "moq-net-fuzz" = rec { @@ -20323,7 +20345,11 @@ rec { { name = "moq-net"; packageId = "moq-net"; - features = [ "fuzz" ]; + features = [ + "fuzz" + "relay" + "test-support" + ]; } { name = "serde_json"; @@ -20800,6 +20826,7 @@ rec { name = "moq-tokio"; packageId = "moq-tokio"; usesDefaultFeatures = false; + features = [ "relay" ]; } { name = "moq-uring"; @@ -20962,7 +20989,11 @@ rec { { name = "moq-net"; packageId = "moq-net"; - features = [ "fuzz" ]; + features = [ + "fuzz" + "relay" + "test-support" + ]; } { name = "moq-shaper"; @@ -22055,13 +22086,16 @@ rec { "dep:tikv-jemallocator" "dep:tikv-jemalloc-ctl" ]; + "relay" = [ "moq-net/relay" ]; "test-support" = [ "kio/sim" "moq-quic/sim" + "moq-net/test-support" ]; }; resolvedDefaultFeatures = [ "jemalloc" + "relay" "test-support" ]; }; diff --git a/quest/m2/README.md b/quest/m2/README.md index 63918d0d967..d4d36025ae3 100644 --- a/quest/m2/README.md +++ b/quest/m2/README.md @@ -21,7 +21,7 @@ removal, a rename, or a wire, catalog, or format change that is free until 0.22 publishes it. - **lite-07 wire.** [YIELDED continuations](/quest/m2/yield-defer.md) leave - for lite-08; [the ietf extension](/quest/m2/ietf-records-per-track.md) + for lite-08; the ietf extension costs nothing on a moq-lite track; the path escape is finished; Subscriber Min Age stays and gains its reader, reversing 2026-11-14; and diff --git a/quest/m2/ietf-records-per-track.md b/quest/m2/ietf-records-per-track.md deleted file mode 100644 index 8ce3d627882..00000000000 --- a/quest/m2/ietf-records-per-track.md +++ /dev/null @@ -1,89 +0,0 @@ -# [M] The ietf extension costs nothing on a moq-lite track - -## Goal - -On a lite-07 session that negotiated the `ietf` extension, object records and -a Group State ride only the Group Streams, FETCH responses, and datagrams of -a track whose TRACK_PROPERTIES Version is nonzero, meaning a moq-transport -publisher made it. A track published over moq-lite is byte-for-byte what it -is on a session without the extension. `setup::Extensions` and -`with_extensions` leave the public API and the `extensions` config tables: -moq-relay turns the extension on for its own links through a crate-private -door, and no other caller can. - -## Plan - -Decided 2026-11-16 (maintainer, /quest-plan of the pre-cut audit): - -- ✅ Keep the extension; records and Group State ride only tracks with a - nonzero Version, and `setup::Extensions` leaves the public API and config - with the relay enabling it internally (rejected: take the extension out of - the cut until a consumer is named; keep as is). The 2026-11-09 decision to - keep the extension stands. The maintainer asked what "pay only when used" - would be: it is the Version the track already carries, which says whether - its original publisher spoke moq-transport, so no new flag is needed. - -Facts found by the audit: - -- A record precedes every frame on every relay link, plain media included. - `lite::ietf::Records::new(self.ctx.ietf, ..)` - (`rs/moq-net/src/lite/publisher.rs:6575`) keys on the session, not the - track, and the draft says so: "In a plain group, every record has a `Skip` - of 0" (`drafts/draft-lcurley-moq-ietf.md`, Object). - [moq-dev/moq#6058](https://github.com/moq-dev/moq/pull/6058) measured it - at 2 bytes per frame. -- The per-track fact already exists: `object_records: ietf && - track.info().ietf().is_some()` (`rs/moq-net/src/lite/publisher.rs:2556`), - added by [moq-dev/moq#8843](https://github.com/moq-dev/moq/pull/8843) so a - plain track can yield. Only the framing ignores it. -- moq-relay forces the extension on for both directions after loading its - config, whatever the file says (`rs/moq-relay/src/config.rs:339-340`), so - `[listen.extensions] ietf` and `[connect.extensions] ietf` are settings - nobody can use. Nothing else sets it. -- `solicit`, the struct's other field, is "moq-transport only" by its own - doc (`rs/moq-net/src/setup.rs:81-88`). Every caller that sets it false is - a test or a benchmark (`rs/moq-net/benches/auth.rs`, - `rs/moq-relay/tests/integration/auth_lifetime.rs`, `rs/moq-ffi/src/test.rs`, - `rs/moq-c/src/test.rs`). JS has the same one-field `Extensions` - (`js/net/src/connection/extensions.ts`). -- `rs/moq-net/AGENTS.md`: a moq-transport feature never adds public API. The - root file: no opt-out flags. - -Guidance for the PR: - -- Wire: the receiver knows a track's Version from its Track Stream before - any group arrives, so both sides agree on the framing with no per-stream - marker. A track with Version 0 has no Group State and no records, so - `drafts/draft-lcurley-moq-ietf.md` says the extension changes nothing for - it, and its rules for a plain group shrink to whatever a track with a - Version still needs. Rename the draft's "Since -00 (in progress)" heading - while there: no -00 was published, which `drafts/AGENTS.md` forbids. -- API: delete `setup::Extensions`, `Client::with_extensions`, - `Server::with_extensions`, the `extensions` field on moq-tokio's - `connect::Config` and `listen::Config`, the relay's two TOML tables - (`doc/bin/relay/config.md`), and JS `extensions`. Solicit is always - offered. The relay reaches the `ietf` offer through a hidden door - (`#[doc(hidden)]` or a moq-relay-only feature), since moq-relay is a - separate crate; pick whichever keeps it out of rustdoc and the API diff. - A config file that still names either table is refused with a message - naming the removal, as other removed keys are. -- Tests and benchmarks that set `solicit = false` to act as a peer without - it move to a test-support constructor. -- Tests: a plain track over a link with the extension encodes the same bytes - as over one without; a moq-transport track still crosses two relays with - its Object IDs, gaps, and properties (the path the 2026-11-09 decision - kept, which #8843 noted "is not exercised end to end": add that test). -- With [YIELDED deferred](/quest/m2/yield-defer.md), the "never reset with - YIELDED" rule for such tracks is already gone; if this lands first, leave - that sentence to it. -- Run `just test interop --all`. - -Public API: `setup::Extensions` and both `with_extensions` leave moq-net, -`extensions` leaves moq-tokio's configs and `@moq/net`. Config: -`listen.extensions` and `connect.extensions` are refused. Wire: lite-07-wip -with the `ietf` extension only; a moq-lite track loses its records. - -## Related - -- [YIELDED deferred](/quest/m2/yield-defer.md) - deletes the extension's yield exception -- [moq-transport time addressing](/quest/m2/ietf-time-addressing.md) - changes what moq-transport state a track carries diff --git a/quest/m2/lite07-finalize.md b/quest/m2/lite07-finalize.md index e2802592593..f6280f9c2f4 100644 --- a/quest/m2/lite07-finalize.md +++ b/quest/m2/lite07-finalize.md @@ -169,8 +169,7 @@ audited the lite-07 draft for what it could lose): - ✅ [YIELDED continuations](/quest/m2/yield-defer.md) leave lite-07 for lite-08, where they are designed with takeover (rejected: keep them). -- ✅ The `ietf` extension stays, and - [rides only moq-transport tracks](/quest/m2/ietf-records-per-track.md) +- ✅ The `ietf` extension stays, and rides only moq-transport tracks (rejected: as it is, where every frame on a relay link carries a record). - ✅ The `\` path escape is finished rather than removed: moq-transport names a track by a tuple, and the escape is how a @@ -198,7 +197,6 @@ the version that ships them. ## Required - [YIELDED deferred](/quest/m2/yield-defer.md) - removes reset code 0x3C and continuations from the lite-07 wire -- [ietf records per track](/quest/m2/ietf-records-per-track.md) - changes the extension's framing on relay links - [Cache-aware multicast](/quest/m2/multicast/README.md) - lite-07 carries the redesigned route layer: routes to forwarding nodes, no holds or doubt, claims crossing trust boundaries by a chain, and no Route Key - [Routes and announces](/quest/m2/cluster-routes/README.md) - lite-07 carries the route layer: ROUTE per origin node and path-less ANNOUNCE, with the native hop list gone (only the temporary lite-06 compatibility chain remains) - [Lite-07 by start](/quest/m2/time-addressing/lite07.md) - lite-07 carries group starts, previous-start links, GROUP_END, and time bounds instead of sequence numbers diff --git a/quest/m2/unused-api/README.md b/quest/m2/unused-api/README.md index 85d751027e0..32c63dac309 100644 --- a/quest/m2/unused-api/README.md +++ b/quest/m2/unused-api/README.md @@ -31,8 +31,7 @@ reaches them when a binding user needs it, so the sweep mirrors nothing new into moq-ffi. Not part of the sweep, because each has its own quest: socket endpoints -([removed for Kixel](/quest/m2/sockets/README.md)), `setup::Extensions` -([the ietf extension](/quest/m2/ietf-records-per-track.md)), and the public +([removed for Kixel](/quest/m2/sockets/README.md)), the public route API ([the route switch](/quest/m2/multicast/switch.md)). Public API: each child lists what leaves. Wire: none. diff --git a/quest/m2/unused-api/net.md b/quest/m2/unused-api/net.md index 6ab781f3d9b..5947f14ea2b 100644 --- a/quest/m2/unused-api/net.md +++ b/quest/m2/unused-api/net.md @@ -69,8 +69,6 @@ Not in this sweep, with their owners: - `origin::Producer::update_hold`, `with_proxy`, `Source`, `source()`, `Consumer::local()`, `origin::RouteKey`, and `Config::route_key` belong to [the route switch](/quest/m2/multicast/switch.md). -- `setup::Extensions` belongs to - [the `ietf` extension](/quest/m2/ietf-records-per-track.md). Run `just api-diff rust` after the change and list every item it shows removed in the PR's Impact section. diff --git a/rs/moq-c/Cargo.toml b/rs/moq-c/Cargo.toml index f5ffce6d531..8ba0c1b0f90 100644 --- a/rs/moq-c/Cargo.toml +++ b/rs/moq-c/Cargo.toml @@ -51,6 +51,8 @@ cbindgen = "0.29" [dev-dependencies] kio = { path = "../kio", features = ["runtime"] } moq-loc = { path = "../moq-loc" } +# A peer without MoQ Solicit. +moq-tokio = { path = "../moq-tokio", default-features = false, features = ["test-support"] } # The tests encode with OpenH264, the one encoder a GPU-less host has, so they # turn it on without the `openh264` feature. moq-video = { path = "../moq-video", features = ["openh264"] } diff --git a/rs/moq-c/src/test.rs b/rs/moq-c/src/test.rs index 45b44dcae47..6bc3d2da3d0 100644 --- a/rs/moq-c/src/test.rs +++ b/rs/moq-c/src/test.rs @@ -9115,7 +9115,7 @@ fn base_moqt_server(version: &str, sink: u32) -> (String, mpsc::Receiver (Session, Session, auth::Reques let mut mock = moq_net::transport::memory::Config::default(); mock.protocol = Some(version.alpn().to_string()); let (client, server) = create_mock_session_pair(mock); - // Tokens ride requests alone, and the client announces with PUBLISH_NAMESPACE. - let mut server_extensions = moq_net::setup::Extensions::default(); - server_extensions.solicit = false; + // Tokens ride requests alone, and the client announces with PUBLISH_NAMESPACE, as to a + // peer without MoQ Solicit. let (subscribe, driver) = origin::Producer::new(origin::Config::new(std::num::NonZeroU64::new(1).unwrap())); harness::spawn(driver); let client = async { @@ -141,7 +140,7 @@ async fn publisher(origin: &origin::Producer) -> (Session, Session, auth::Reques let server = async { let mut request = moq_net::Server::new() .with_versions(version.into()) - .with_extensions(server_extensions) + .with_solicit(false) .with_subscriber(subscribe.clone()) .accept_request(harness::now(), server) .await diff --git a/rs/moq-net/src/client.rs b/rs/moq-net/src/client.rs index 43e87ec89f5..9cc33973671 100644 --- a/rs/moq-net/src/client.rs +++ b/rs/moq-net/src/client.rs @@ -197,10 +197,23 @@ impl Client { self } - /// Choose which extensions to offer in SETUP. Defaults to every moq-transport one, and - /// not [`ietf`](setup::Extensions::ietf), which only relays turn on. - pub fn with_extensions(mut self, extensions: setup::Extensions) -> Self { - self.extensions = extensions; + /// Offer the `ietf` extension on moq-lite-07, so a hop between relays carries the + /// moq-transport state of a track a moq-transport publisher made. Off by default. + /// + /// Behind the `relay` feature: moq-relay's door for its own links, not an API. + #[cfg(feature = "relay")] + pub fn with_ietf(mut self, ietf: bool) -> Self { + self.extensions.ietf = ietf; + self + } + + /// Whether to offer MoQ Solicit on moq-transport, which every session does. Off acts as a + /// moq-transport peer without it. + /// + /// Behind the `test-support` feature: a test's door, not an API. + #[cfg(feature = "test-support")] + pub fn with_solicit(mut self, solicit: bool) -> Self { + self.extensions.solicit = solicit; self } diff --git a/rs/moq-net/src/fuzz/ingest.rs b/rs/moq-net/src/fuzz/ingest.rs index e499f4148c9..0042999b64c 100644 --- a/rs/moq-net/src/fuzz/ingest.rs +++ b/rs/moq-net/src/fuzz/ingest.rs @@ -45,7 +45,8 @@ struct Ingested { enum Session { Lite { version: lite::Version, - /// The session negotiated the `ietf` extension, so each frame follows a record. + /// The session negotiated the `ietf` extension and the track has a Version, so + /// each frame follows a record. records: bool, frame_start: u64, }, @@ -92,9 +93,11 @@ pub fn ingest(data: &[u8]) -> bool { // The track arrives timed exactly when the wire stamps it: never before Lite05, // always on Lite05/06 (an untimed one carries its send times), as declared after. let timed = version.wire_timescale(timed.then_some(Timescale::MILLI)).is_some(); + // Only the `ietf` extension carries a Version, and only on a track that has one. + let draft = draft.filter(|_| settings & 0x10 != 0 && version.has_ietf()); let session = Session::Lite { version, - records: settings & 0x10 != 0 && version.has_ietf(), + records: draft.is_some(), frame_start: (settings >> 5) as u64, }; // Only lite-07 can mark a track compressed. @@ -380,7 +383,8 @@ pub(super) fn seeds() -> Vec { } } - // moq-lite-07 with the `ietf` extension: a plain Group State, then records. + // moq-lite-07 with the `ietf` extension, on a track a draft-18 publisher made: a plain + // Group State, then records. let lite07 = super::LITE_VERSIONS.len() - 1; let mut data = vec![(lite07 * 2) as u8, 0x10, 2, 0]; for payload in [&b"ab"[..], b"c"] { diff --git a/rs/moq-net/src/ietf/solicit.rs b/rs/moq-net/src/ietf/solicit.rs index e303d08f1f3..0983cf2bc97 100644 --- a/rs/moq-net/src/ietf/solicit.rs +++ b/rs/moq-net/src/ietf/solicit.rs @@ -39,7 +39,7 @@ pub fn from_setup(params: &super::Parameters, _version: Version) -> Result (Vec, crate::lite::test_transport::Log) { let direct = relay_passthrough_via(script.clone(), ingress, egress, fetch, None, false).await; let hopped = relay_passthrough_via(script, ingress, egress, fetch, None, true).await; + // The bytes alone would pass a hop that wrote them and then reset the stream. + assert_eq!( + hopped.1.resets(), + direct.1.resets(), + "{ingress} -> {egress}: the moq-lite hop changed the resets" + ); let fetch_ok = |bytes: &[u8]| { let mut decoder = Decoder::new(bytes, egress.into()); (decoder.varint().ok()? == ietf::FetchOk::ID).then_some(())?; @@ -15549,6 +15555,44 @@ mod stitch_tests { } } + /// A subscribed moq-transport group crosses two relays joined by a moq-lite hop with the + /// `ietf` extension byte for byte, as it crosses one: its Object IDs, the gaps between + /// them and their marks, its properties, and its END_OF_GROUP status object. + #[kio::test] + async fn passthrough_keeps_gaps_properties_and_the_end_across_two_relays() { + let version = Version::Draft22; + let objects: [(u64, &[u8], Option); 3] = [ + (6, &[0x3e, 6, 0x22, 1], None), + (9, &[0x3e, 2], None), + (10, &[], Some(super::super::object::END_OF_GROUP)), + ]; + let script = object_stream(version, true, &objects); + // Compares the two-relay path against the direct one. + let (bytes, log) = relay_passthrough_stream(script.clone(), version, version).await; + assert!(log.resets().is_empty()); + let mut decoder = Decoder::new(&bytes, version.into()); + let header = ietf::GroupHeader::decode(&mut decoder, version).unwrap(); + assert!(header.flags.first_object && header.flags.has_extensions); + let mut previous = None; + for (id, properties, status) in objects { + let delta = previous.map_or(id, |previous: u64| id - previous - 1); + previous = Some(id); + assert_eq!(decoder.varint().unwrap(), delta, "Object {id}"); + assert_eq!(decoder.bytes().unwrap(), properties, "Object {id}"); + match status { + Some(status) => { + assert_eq!(decoder.varint().unwrap(), 0, "Object {id}"); + assert_eq!(decoder.varint().unwrap(), status, "Object {id}"); + } + None => { + assert_eq!(decoder.varint().unwrap(), 1, "Object {id}"); + assert_eq!(decoder.slice(1).unwrap(), &[99], "Object {id}"); + } + } + } + assert!(decoder.is_empty()); + } + /// A relayed Timestamp leaves in the units the publisher declared: the cache holds the /// track on the publisher's grid, so a copy of the same instance over another route /// matches it, including across a moq-lite hop that negotiated the `ietf` extension. diff --git a/rs/moq-net/src/lite/ietf.rs b/rs/moq-net/src/lite/ietf.rs index e1dc08c25c8..1cd3af1e094 100644 --- a/rs/moq-net/src/lite/ietf.rs +++ b/rs/moq-net/src/lite/ietf.rs @@ -2,7 +2,8 @@ //! preserves, carried across a lite-07 hop when both SETUPs offer it. //! //! Every field here is crate-private relay metadata (see `model::object`). Plain readers -//! never see it, and a session without the extension sends none of it. +//! never see it, and only a track a moq-transport publisher made carries it, so a moq-lite +//! track crosses a negotiated hop exactly as it crosses one without the extension. use std::sync::Arc; @@ -210,8 +211,8 @@ pub(crate) fn decode_end(body: &[u8], framing: super::Framing) -> Result) -> Option { - ietf.then_some(Self { + /// The records a group stream of a track that carries them needs. `capped` when the + /// stream stops before the group may end. + pub fn new(capped: bool, timescale: Option) -> Self { + Self { stated: false, prior: None, capped, timescale, - }) + } } /// Buffer the Group State for a stream serving `group` from its current index, once the @@ -747,17 +748,13 @@ pub(crate) async fn test_hop( protocol: Some(version.alpn().to_string()), ..Default::default() }); - let extensions = |ietf| crate::setup::Extensions { - ietf, - ..Default::default() - }; let dial = crate::Client::new() .with_versions(version.into()) - .with_extensions(extensions(offer[0])) + .with_ietf(offer[0]) .with_subscriber(downstream.clone()); let serve = crate::Server::new() .with_versions(version.into()) - .with_extensions(extensions(offer[1])) + .with_ietf(offer[1]) .with_publisher(upstream.consume()); let (client, server) = futures::join!( async { @@ -1130,6 +1127,40 @@ mod hop_tests { drop(sessions); } + /// A group of a moq-lite publisher's track fetched across a negotiated hop is as plain + /// as one subscribed: the FETCH response carries no Group State or records either. + #[kio::test] + async fn plain_media_fetches_unchanged() { + let upstream = crate::origin::Config::new(std::num::NonZeroU64::new(2).unwrap()).produce(); + let broadcast = upstream.route("room", crate::origin::RouteOptions::default()).unwrap(); + let track = broadcast + .broadcast() + .create_track("video", track::Info::timed().with_timescale(Timescale::MILLI)) + .unwrap(); + let mut first = track.create_group(0u64.into()).unwrap(); + first.write_frame(ts(5), b"key".to_vec()).unwrap(); + first.write_frame(ts(6), b"delta".to_vec()).unwrap(); + first.finish().unwrap(); + let (downstream, sessions) = test_hop(&upstream, "room", [true, true]).await; + let broadcast = downstream.consume().request("room", None).await.unwrap(); + let copy = broadcast.track("video").unwrap(); + let mut fetched = kio::clock::timeout(TIMEOUT, copy.fetch_group(0, None)) + .await + .unwrap() + .unwrap(); + for (millis, payload) in [(5, &b"key"[..]), (6, b"delta")] { + let frame = next(&mut fetched).await.unwrap(); + assert_eq!( + (frame.timestamp, &frame.payload.contiguous(0)[..]), + (ts(millis), payload) + ); + assert!(frame.fields.is_none()); + } + assert!(next(&mut fetched).await.is_none()); + assert!(fetched.wire().is_none()); + drop(sessions); + } + /// Every hop carries IETF times, and provenance keeps them unchecked after a hop that /// negotiated the extension. A peer declining it checks them like native moq-lite, as a /// listing's copy does. SUBSCRIBE and FETCH must agree with TRACK_INFO. diff --git a/rs/moq-net/src/lite/publisher.rs b/rs/moq-net/src/lite/publisher.rs index 6eaa50f17a7..24c27c759c0 100644 --- a/rs/moq-net/src/lite/publisher.rs +++ b/rs/moq-net/src/lite/publisher.rs @@ -2514,7 +2514,6 @@ impl Request for SubscribeServe { version: shared.version, stamp, outcomes: Default::default(), - ietf, object_records: ietf && track.info().ietf().is_some(), }; @@ -3096,7 +3095,7 @@ enum FetchServe { chunk: Option, batch: Box, batch_pos: usize, - /// The `ietf` extension's object records, when negotiated. + /// The `ietf` extension's object records, when negotiated and the track carries them. records: Option, }, } @@ -3195,7 +3194,8 @@ impl Request for FetchServe { writer.bill(group.delegate()); let capped = msg.end_frame.is_some(); let timescale = stamp.map(|stamp| stamp.timescale); - let records = lite::ietf::Records::new(ietf, capped, timescale); + // Only a track a moq-transport publisher made carries records. + let records = (ietf && group.ietf().is_some()).then(|| lite::ietf::Records::new(capped, timescale)); *self = Self::Serve { group, @@ -4766,10 +4766,9 @@ struct Subscription { stamp: Option, /// Outcomes shared by the subscription and every group it serves. outcomes: Arc, - /// Whether the session negotiated the `ietf` extension, so streams carry relay state. - ietf: bool, - /// Whether the track carries moq-transport object records on `ietf` streams, which a - /// continuation cannot resume. + /// Whether the session negotiated the `ietf` extension and a moq-transport publisher made + /// the track, so its group streams carry object records, which a continuation cannot + /// resume. object_records: bool, } @@ -4784,10 +4783,9 @@ struct GroupContext { stamp: Option, /// Outcomes shared by the subscription and every group it serves. outcomes: Arc, - /// Whether the session negotiated the `ietf` extension, so streams carry relay state. - ietf: bool, - /// Whether the track carries moq-transport object records on `ietf` streams, which a - /// continuation cannot resume. + /// Whether the session negotiated the `ietf` extension and a moq-transport publisher made + /// the track, so its group streams carry object records, which a continuation cannot + /// resume. object_records: bool, } @@ -4856,7 +4854,6 @@ impl Subscription { version: self.version, stamp: self.stamp, outcomes: self.outcomes.clone(), - ietf: self.ietf, object_records: self.object_records, } } @@ -6147,7 +6144,6 @@ impl CoverageBench { version, stamp: None, outcomes: Default::default(), - ietf: false, object_records: false, }; let mut this = Self { @@ -6307,7 +6303,7 @@ enum GroupState { chunk: Option, batch: Box, batch_pos: usize, - /// The `ietf` extension's object records, when negotiated. + /// The `ietf` extension's object records, when negotiated and the track carries them. records: Option, }, /// Every frame is written and the FIN sent: wait for the acknowledgement so a @@ -6411,7 +6407,10 @@ impl GroupServe { }; let header = writer.buffer(&lite::DataType::Group).and_then(|()| writer.buffer(&msg)); let records = match header { - Ok(()) => lite::ietf::Records::new(self.ctx.ietf, self.capped, self.ctx.stamp.map(|stamp| stamp.timescale)), + Ok(()) => self + .ctx + .object_records + .then(|| lite::ietf::Records::new(self.capped, self.ctx.stamp.map(|stamp| stamp.timescale))), Err(err) => { // The header wrote nothing, so the group-stream reset has nothing to pin // it to this subscription. The run loop reads the slot and resets the @@ -6959,7 +6958,6 @@ mod serve_group_test { version: Version::Lite06, stamp: Stamp::new(Version::Lite06, Some(crate::Timescale::MILLI)), outcomes: Default::default(), - ietf: false, object_records: false, }; @@ -7006,7 +7004,6 @@ mod serve_group_test { version: Version::Lite06, stamp: Stamp::new(Version::Lite06, Some(crate::Timescale::MILLI)), outcomes: Default::default(), - ietf: false, object_records: false, }; @@ -7074,7 +7071,6 @@ mod serve_group_test { version: Version::Lite06, stamp: Stamp::new(Version::Lite06, Some(crate::Timescale::MILLI)), outcomes: Default::default(), - ietf: false, object_records: false, }; let track = track::Producer::new( @@ -7149,7 +7145,6 @@ mod serve_group_test { version: Version::Lite06, stamp: Stamp::new(Version::Lite06, Some(crate::Timescale::MILLI)), outcomes: Default::default(), - ietf: false, object_records: false, }; let track = track::Producer::new( @@ -7220,7 +7215,6 @@ mod serve_group_test { version: Version::Lite06, stamp: Stamp::new(Version::Lite06, Some(crate::Timescale::MILLI)), outcomes: Default::default(), - ietf: false, object_records: false, }; @@ -7271,7 +7265,6 @@ mod serve_group_test { version: Version::Lite06, stamp: Stamp::new(Version::Lite06, Some(crate::Timescale::MILLI)), outcomes: Default::default(), - ietf: false, object_records: false, }; @@ -7339,7 +7332,6 @@ mod serve_group_test { version: Version::Lite06, stamp: Stamp::new(Version::Lite06, Some(crate::Timescale::MILLI)), outcomes: Default::default(), - ietf: false, object_records: false, }; @@ -7519,7 +7511,6 @@ mod serve_group_test { version: Version::Lite06, stamp: Stamp::new(Version::Lite06, Some(crate::Timescale::MILLI)), outcomes: Default::default(), - ietf: false, object_records: false, }; @@ -7592,7 +7583,6 @@ mod serve_group_test { version: Version::Lite06, stamp: Stamp::new(Version::Lite06, Some(crate::Timescale::MILLI)), outcomes: Default::default(), - ietf: false, object_records: false, }; @@ -7642,7 +7632,6 @@ mod serve_group_test { version: Version::Lite06, stamp: Stamp::new(Version::Lite06, Some(crate::Timescale::MILLI)), outcomes: Default::default(), - ietf: false, object_records: false, }; @@ -7691,7 +7680,6 @@ mod serve_group_test { version: Version::Lite06, stamp: Stamp::new(Version::Lite06, Some(crate::Timescale::MILLI)), outcomes: Default::default(), - ietf: false, object_records: false, }; @@ -7768,7 +7756,6 @@ mod serve_group_test { version, stamp: Stamp::new(Version::Lite06, Some(crate::Timescale::MILLI)), outcomes: Default::default(), - ietf: false, object_records: false, }; let bounds = Bounds::new(&[lite::Range::span(Some(0), 0, None, None)], false); @@ -10039,7 +10026,6 @@ mod serve_group_test { version: Version::Lite07, stamp: Stamp::new(Version::Lite07, Some(crate::Timescale::MILLI)), outcomes: outcomes.clone(), - ietf: false, object_records: false, }; let bounds = Bounds::new(&[lite::Range::span(Some(start_group), 0, None, None)], false); @@ -12551,6 +12537,102 @@ mod tests { } } + /// The lite-07 Group Stream a subscriber gets for one finished group of a track `info` + /// describes, on a session that negotiated the `ietf` extension or not. + async fn served_group(info: crate::track::Info, ietf: bool) -> Vec { + use kio::Task; + let version = Version::Lite07; + let origin = crate::origin::Config::default().produce(); + let broadcast = origin.route("room", crate::origin::RouteOptions::hidden()).unwrap(); + broadcast.announce().unwrap(); + let track = broadcast.broadcast().create_track("video", info).unwrap(); + let mut group = track.create_group(group::Info { start: 0 }).unwrap(); + for (millis, payload) in [(0, &b"key"[..]), (33, b"delta")] { + group + .write_frame(crate::Timestamp::from_millis(millis).unwrap(), payload) + .unwrap(); + } + group.finish().unwrap(); + + let request = lite::Subscribe { + order: crate::track::Order::Ascending, + instance: None, + node: 0, + depth: 0, + id: 0, + broadcast: crate::Path::from_static("room"), + track: "video".into(), + priority: 0, + max_delay: Duration::ZERO, + min_delay: None, + ranges: vec![lite::Range::span(Some(0), 0, None, None)], + update: 0, + }; + let session = ScriptedSession::new(request.encode_bytes(version).unwrap().to_vec()); + let log = session.log.clone(); + let stream = Stream::open(&crate::driver::Transport::new(session.clone()), version) + .await + .unwrap(); + let estimate = kio::Producer::default(); + let probe = probe_server( + crate::driver::Transport::new(session.clone()), + stream, + version, + &estimate, + ); + let mut shared = probe.shared; + { + let shared = Arc::get_mut(&mut shared).expect("one owner"); + shared.origin = origin.consume(); + shared.peer_setup = lite::PeerSetup::new(false, crate::transport::Address::Setup).offer_ietf(ietf); + shared + .peer_setup + .set(lite::Setup { + ietf, + ..Default::default() + }) + .unwrap(); + } + let mut control = Control { + shared: shared.clone(), + runtime: crate::time::sim(), + state: ControlState::Subscribe(RequestServe::new(shared, probe.stream.unwrap())), + }; + let serving = kio::clock::timeout(Duration::from_millis(10), kio::wait(|waiter| control.poll(waiter))).await; + assert!(serving.is_err(), "the subscription ended"); + + // Stream 0 is the request's own; the group's opened after it. + let mut bytes = Vec::new(); + for (stream, sent) in log.trail() { + if let (1, crate::lite::test_transport::Sent::Write(chunk)) = (stream, sent) { + bytes.extend(chunk); + } + } + assert!(!bytes.is_empty(), "no group stream"); + bytes + } + + /// The `ietf` extension costs a moq-lite track nothing: its Group Stream is the same bytes + /// on a session that negotiated it, while a moq-transport track's carries its records. + #[kio::test] + async fn a_moq_lite_group_is_the_same_bytes_with_the_ietf_extension() { + let plain = crate::track::Info::timed(); + assert_eq!( + served_group(plain.clone(), true).await, + served_group(plain, false).await + ); + + let mut relayed = crate::track::Info::timed(); + relayed.properties = Some(Arc::new(crate::model::object::TrackProperties { + version: crate::ietf::Version::Draft22, + values: Vec::new(), + })); + let without = served_group(relayed.clone(), false).await; + let with = served_group(relayed, true).await; + // A Group State, then an empty record before each of the two frames. + assert_eq!(with.len(), without.len() + 1 + 2 * 2); + } + #[kio::test] async fn goaway_roles_limits_and_transport_termination() { use kio::Task; diff --git a/rs/moq-net/src/lite/subscriber.rs b/rs/moq-net/src/lite/subscriber.rs index 1e9f74ded2f..0738660148d 100644 --- a/rs/moq-net/src/lite/subscriber.rs +++ b/rs/moq-net/src/lite/subscriber.rs @@ -1749,14 +1749,14 @@ impl GroupRecv { let ietf: bool = header.0; let hdr: lite::Group = header.1; // Lite-07 on a track without object records: a YIELDED reset pauses the group. - let yields: bool = self.subscriber.version.has_yield() - && !(ietf - && self - .subscriber - .subscribes - .lock() - .get(&hdr.subscribe) - .is_some_and(|entry| entry.has_records())); + let records: bool = ietf + && self + .subscriber + .subscribes + .lock() + .get(&hdr.subscribe) + .is_some_and(|entry| entry.has_records()); + let yields: bool = self.subscriber.version.has_yield() && !records; if let (Err(err), Some((_, ticket))) = (&accepted, &parked) && let Some(entry) = self.subscriber.subscribes.lock().get_mut(&hdr.subscribe) { @@ -1861,7 +1861,7 @@ impl GroupRecv { let group: crate::recv::Group = group; let track: track::Producer = track; let mut ingest: FrameIngest = - FrameIngest::new(framing, ietf, hdr.frame_start).yielding(yields, cut.map(|cut| *cut)); + FrameIngest::new(framing, records, hdr.frame_start).yielding(yields, cut.map(|cut| *cut)); let reading: Reading = reading; // Filling the group, bailing if the track or group dies first. The track or group @@ -2015,12 +2015,13 @@ enum IngestPhase { } impl FrameIngest { - /// `ietf` when the session negotiated the extension, so the stream starts with a Group State. - pub(crate) fn new(framing: lite::Framing, ietf: bool, frame_start: u64) -> Self { + /// `records` when the session negotiated the `ietf` extension and a moq-transport + /// publisher made the track, so the stream starts with a Group State. + pub(crate) fn new(framing: lite::Framing, records: bool, frame_start: u64) -> Self { Self { framing, prev_ts: 0, - phase: match ietf { + phase: match records { true => IngestPhase::State, false => Self::first_field(framing), }, @@ -2161,10 +2162,6 @@ impl FrameIngest { let state = ready!(reader.poll_varint(waiter))?; let wire = lite::ietf::decode_state(state, self.frame_start)?; let relayed = wire.is_some(); - // A track published over moq-lite has no moq-transport state. - if relayed && self.framing.ietf.is_none() { - return Poll::Ready(Err(Error::ProtocolViolation)); - } let extensions = wire.as_ref().is_some_and(|wire| wire.extensions); if let Some(wire) = wire { group.set_wire(wire)?; @@ -5123,18 +5120,17 @@ mod tests { } } - /// A track published over moq-lite has no moq-transport state, so a relayed group on - /// one is refused, though its plain groups cross. + /// A track published over moq-lite has no moq-transport state, so its Group Streams + /// carry no Group State and no records, as on a session without the extension. #[kio::test] - async fn ietf_records_need_a_moq_transport_track() { - let plain = [0, 0, 0, 1, u64::from(b'x')]; - let relayed = [0x1, 0, 0, 1, u64::from(b'x')]; - for (framing, ok) in [(draft18(None), true), (lite::Framing::default(), false)] { - let (res, ..) = receive_ietf(framing, &plain).await; - res.unwrap(); - let (res, ..) = receive_ietf(framing, &relayed).await; - assert_eq!(res.is_ok(), ok, "{framing:?}: {res:?}"); - } + async fn a_moq_lite_track_has_no_records() { + let (res, track, _) = receive_ietf(lite::Framing::default(), &[1, u64::from(b'x')]).await; + res.unwrap(); + let mut group = track.consume().peek_group(0).unwrap(); + let frame = group.read_frame().now_or_never().unwrap().unwrap().unwrap(); + assert_eq!(frame.payload, b"x"[..]); + assert!(group.read_frame().now_or_never().unwrap().unwrap().is_none()); + assert!(group.wire().is_none()); } /// A relayed group's records carry properties only when its Group State sets EXTENSIONS, @@ -5557,9 +5553,9 @@ mod tests { compressed: false, length_first: true, }; - // The `ietf` extension's plain records: a Group State of 0 after the header, then a - // record before each frame, as a moq-lite track on a relay link carries them. - let header = |ietf: bool| { + // A moq-lite track carries no records, so a relay link that negotiated the `ietf` + // extension sends the same stream. + let header = || { let mut script = Vec::new(); lite::Group { subscribe: 7, @@ -5568,18 +5564,11 @@ mod tests { } .encode(&mut crate::coding::Encoder::new(&mut script, version.into()), version) .unwrap(); - if ietf { - script.push(0); - } script }; // A lite-07 FRAME: the payload size plus one, the timestamp delta, then the first // `sent` bytes of the payload. - let frame = |script: &mut Vec, ietf: bool, delta: i64, payload: &[u8], sent: usize| { - if ietf { - // The next Object ID, with no properties. - script.extend_from_slice(&[0, 0]); - } + let frame = |script: &mut Vec, delta: i64, payload: &[u8], sent: usize| { let mut encoder = crate::coding::Encoder::new(&mut *script, version.into()); encoder.varint(payload.len() as u64 + 1).unwrap(); encoder.varint(crate::coding::varint::zigzag(delta)).unwrap(); @@ -5589,12 +5578,12 @@ mod tests { for (overtakes, ietf) in [(false, false), (true, false), (false, true), (true, true)] { // Frame 0 whole, then frame 1 cut after three bytes. - let mut cut = header(ietf); - frame(&mut cut, ietf, frames[0].0, frames[0].1, frames[0].1.len()); - frame(&mut cut, ietf, frames[1].0, frames[1].1, 3); - let mut whole = header(ietf); + let mut cut = header(); + frame(&mut cut, frames[0].0, frames[0].1, frames[0].1.len()); + frame(&mut cut, frames[1].0, frames[1].1, 3); + let mut whole = header(); for (delta, payload) in frames { - frame(&mut whole, ietf, delta, payload, payload.len()); + frame(&mut whole, delta, payload, payload.len()); } let yielded = ScriptedSession::new(cut); let continued = ScriptedSession::eof(whole); @@ -14891,11 +14880,10 @@ impl kio::Task for FetchServeRun { stream, producer: Box::new(crate::recv::Group::new(producer)), readers, - ingest: Box::new(FrameIngest::new( - lite::Framing::new(&info, self.serve.subscriber.version), - ietf, - frame_start, - )), + ingest: Box::new({ + let framing = lite::Framing::new(&info, self.serve.subscriber.version); + FrameIngest::new(framing, ietf && framing.ietf.is_some(), frame_start) + }), }; } FetchRunState::Ingest { diff --git a/rs/moq-net/src/server.rs b/rs/moq-net/src/server.rs index 1856657c471..48f5af4754b 100644 --- a/rs/moq-net/src/server.rs +++ b/rs/moq-net/src/server.rs @@ -163,10 +163,23 @@ impl Server { self } - /// Choose which extensions to offer in SETUP. Defaults to every moq-transport one, and - /// not [`ietf`](setup::Extensions::ietf), which only relays turn on. - pub fn with_extensions(mut self, extensions: setup::Extensions) -> Self { - self.extensions = extensions; + /// Offer the `ietf` extension on moq-lite-07, so a hop between relays carries the + /// moq-transport state of a track a moq-transport publisher made. Off by default. + /// + /// Behind the `relay` feature: moq-relay's door for its own links, not an API. + #[cfg(feature = "relay")] + pub fn with_ietf(mut self, ietf: bool) -> Self { + self.extensions.ietf = ietf; + self + } + + /// Whether to offer MoQ Solicit on moq-transport, which every session does. Off acts as a + /// moq-transport peer without it. + /// + /// Behind the `test-support` feature: a test's door, not an API. + #[cfg(feature = "test-support")] + pub fn with_solicit(mut self, solicit: bool) -> Self { + self.extensions.solicit = solicit; self } diff --git a/rs/moq-net/src/setup.rs b/rs/moq-net/src/setup.rs index 2889392d3ab..ceb90abc129 100644 --- a/rs/moq-net/src/setup.rs +++ b/rs/moq-net/src/setup.rs @@ -1,8 +1,7 @@ -//! The SETUP exchange, the extensions a side offers in it, and the credential a peer may -//! present in it. +//! The SETUP exchange and the credential a peer may present in it. //! -//! Only [`Extensions`], [`Token`], and [`Role`] are public; the SETUP messages themselves -//! are wire internals. +//! Only [`Token`] and [`Role`] are public; the SETUP messages and the extensions a side +//! offers in them are wire internals. use bytes::Bytes; @@ -73,14 +72,12 @@ pub(crate) fn implementation(value: &str) -> Option { /// The SETUP extensions this side offers. /// -/// Turning one off connects as a peer that does not speak that extension. moq-lite carries -/// solicit in its core, so that one only changes moq-transport sessions. -#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)] -#[serde(default, deny_unknown_fields)] -#[non_exhaustive] -pub struct Extensions { +/// Not public: every session offers Solicit, and only moq-relay offers `ietf`, through +/// `Client::with_ietf` and `Server::with_ietf` behind the `relay` feature. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) struct Extensions { /// The MoQ Solicit extension: the peer answers our SUBSCRIBE_NAMESPACE rather than - /// announcing unasked (moq-transport only). + /// announcing unasked (moq-transport only). Off only in tests acting as a peer without it. pub solicit: bool, /// The MoQ IETF extension, off by default: a moq-lite 07 hop between relays carries the /// moq-transport object state a relay preserves, such as Object IDs and properties. diff --git a/rs/moq-net/tests/integration/auth.rs b/rs/moq-net/tests/integration/auth.rs index f9d80b49303..df7230017c7 100644 --- a/rs/moq-net/tests/integration/auth.rs +++ b/rs/moq-net/tests/integration/auth.rs @@ -262,11 +262,7 @@ async fn connect_route_auth_on( client_publish: Some(client_origin.clone()), server_subscribe: Some(server_origin.clone()), server_requests: true, - server_extensions: Some({ - let mut extensions = moq_net::setup::Extensions::default(); - extensions.solicit = false; - extensions - }), + server_declines_solicit: true, client_auth, ..Default::default() }) @@ -410,8 +406,8 @@ struct Options { server_subscribe: Option, /// Take the server's AUTH requests before its driver runs. server_requests: bool, - /// The server's extensions, when not the defaults. - server_extensions: Option, + /// The server acts as a moq-transport peer without MoQ Solicit. + server_declines_solicit: bool, version: Option<&'static str>, /// The connection credential the client's SETUP presents. client_token: Option<&'static [u8]>, @@ -456,10 +452,9 @@ async fn connect(opts: Options) -> Pair { client = client.with_auth(handle); } - let mut server = Server::new().with_versions(version.into()); - if let Some(extensions) = opts.server_extensions { - server = server.with_extensions(extensions); - } + let mut server = Server::new() + .with_versions(version.into()) + .with_solicit(!opts.server_declines_solicit); if let Some(publish) = &opts.server_publish { server = server.with_publisher(publish); } diff --git a/rs/moq-net/tests/integration/extensions.rs b/rs/moq-net/tests/integration/extensions.rs index 9ebedcae41a..f57ba0eb733 100644 --- a/rs/moq-net/tests/integration/extensions.rs +++ b/rs/moq-net/tests/integration/extensions.rs @@ -1,7 +1,7 @@ #![cfg(feature = "async")] -//! A side may decline a moq-transport extension with `setup::Extensions`, and then -//! connects as a peer that does not speak it. +//! A test side may decline a moq-transport extension through moq-net's hidden doors, and +//! then connects as a peer that does not speak it. //! //! Deterministic: paused time over the mock transport. @@ -9,8 +9,8 @@ use crate::support; use std::time::Duration; -use moq_net::{Version, origin, setup::Extensions}; -use support::harness::{MockConnectOptions, MockPair, connect_mock}; +use moq_net::{Version, origin}; +use support::harness::{Extensions, MockConnectOptions, MockPair, connect_mock}; /// Long enough, in virtual time, for anything in flight to reach the far side. const SETTLE: Duration = Duration::from_secs(1); diff --git a/rs/moq-net/tests/integration/support/harness.rs b/rs/moq-net/tests/integration/support/harness.rs index 82e40df1b87..6c69c47f202 100644 --- a/rs/moq-net/tests/integration/support/harness.rs +++ b/rs/moq-net/tests/integration/support/harness.rs @@ -85,9 +85,9 @@ pub struct MockConnectOptions { /// What the client may make the server's session hold, when not the default. pub server_limits: Option, /// The extensions the client offers. - pub client_extensions: moq_net::setup::Extensions, + pub client_extensions: Extensions, /// The extensions the server offers. - pub server_extensions: moq_net::setup::Extensions, + pub server_extensions: Extensions, /// The price the client puts on the link, when not the default. pub cost: Option, /// What both transports report as their connection statistics. @@ -138,6 +138,24 @@ impl MockConnectOptions { } } +/// The SETUP extensions a side offers, which moq-net sets only through hidden doors. +#[derive(Clone, Copy, Debug)] +pub struct Extensions { + /// MoQ Solicit, which every session offers: off acts as a moq-transport peer without it. + pub solicit: bool, + /// The `ietf` extension, which only moq-relay offers. + pub ietf: bool, +} + +impl Default for Extensions { + fn default() -> Self { + Self { + solicit: true, + ietf: false, + } + } +} + /// A connected mock pair. Both protocol drivers run on spawned tasks for the /// lifetime of their session. pub struct MockPair { @@ -174,7 +192,8 @@ pub async fn connect_mock(opts: MockConnectOptions) -> MockPair { let mut client = Client::new() .with_versions(opts.version.into()) - .with_extensions(opts.client_extensions); + .with_solicit(opts.client_extensions.solicit) + .with_ietf(opts.client_extensions.ietf); if let Some(cost) = opts.cost { client = client.with_cost(cost); } @@ -196,7 +215,8 @@ pub async fn connect_mock(opts: MockConnectOptions) -> MockPair { let mut server = Server::new() .with_stats(opts.server_stats) .with_versions(opts.version.into()) - .with_extensions(opts.server_extensions); + .with_solicit(opts.server_extensions.solicit) + .with_ietf(opts.server_extensions.ietf); if let Some(publish) = &opts.server_publish { server = server.with_publisher(publish.clone()); } diff --git a/rs/moq-relay/Cargo.toml b/rs/moq-relay/Cargo.toml index 30fa445636b..fa9a8e1f041 100644 --- a/rs/moq-relay/Cargo.toml +++ b/rs/moq-relay/Cargo.toml @@ -65,7 +65,8 @@ 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 } +# `relay` offers the lite-07 `ietf` extension on the relay's own links. +moq-tokio = { workspace = true, features = ["relay"] } # The /metrics text encoder; the protobuf features stay off. prometheus-client = "0.25.2" qmux = { workspace = true } @@ -110,8 +111,9 @@ h2 = { workspace = true } kio = { path = "../kio", features = ["manual", "sim"] } moq-auth = { path = "../moq-auth", features = ["client", "serve"] } moq-congestion = { path = "../moq-congestion" } -# The shared session bench fills FETCH runs through the `fuzz` module. -moq-net = { path = "../moq-net", features = ["fuzz"] } +# The shared session bench fills FETCH runs through the `fuzz` module and sets the +# extensions each side offers. +moq-net = { path = "../moq-net", features = ["fuzz", "relay", "test-support"] } moq-shaper = { path = "../moq-shaper", features = ["test"] } # The tests dial and serve bare QUIC and WebTransport through moq-tokio's driver. moq-tokio = { path = "../moq-tokio", features = ["test-support"] } diff --git a/rs/moq-relay/benches/session.rs b/rs/moq-relay/benches/session.rs index 462701a0fc7..1cb4c0ba73c 100644 --- a/rs/moq-relay/benches/session.rs +++ b/rs/moq-relay/benches/session.rs @@ -122,7 +122,8 @@ impl Backend for Relay { let task = tokio::spawn(async move { let server = moq_net::Server::new() .with_versions(version.into()) - .with_extensions(extensions); + .with_solicit(extensions.solicit) + .with_ietf(extensions.ietf); let handshake = server .accept_request(moq_net::time::Instant::now(), server_link) .await @@ -140,7 +141,8 @@ impl Backend for Relay { .map(|origin| origin.consume().routes()); let mut client = moq_net::Client::new() .with_versions(version.into()) - .with_extensions(options.client_extensions); + .with_solicit(options.client_extensions.solicit) + .with_ietf(options.client_extensions.ietf); // Older protocols need the peer exemption to discover dot paths. if peer || hidden { client = client.with_url("moql://localhost/peer".parse().unwrap()); diff --git a/rs/moq-relay/src/config.rs b/rs/moq-relay/src/config.rs index 57cd7fc4fe6..899fc82e57a 100644 --- a/rs/moq-relay/src/config.rs +++ b/rs/moq-relay/src/config.rs @@ -363,8 +363,8 @@ impl Config { .get_or_insert(moq_tokio::quic::DEFAULT_MAX_STREAMS); // A relay keeps the moq-transport object state it forwards across a moq-lite hop to // another relay. Only negotiated when both sides offer it, so other peers never see it. - self.listen.extensions.ietf = true; - self.connect.extensions.ietf = true; + self.listen.ietf = true; + self.connect.ietf = true; // Name the relay ahead of its core unless the embedder set a name (empty omits it), // and dial cluster peers under the same name. let implementation = self @@ -553,21 +553,20 @@ mod tests { } } - /// The moq-transport extension choices are file-only, so the loader must carry them through. + /// The SETUP extensions are no setting: the relay always offers `ietf` on its own links, + /// and a file naming either table is refused. #[test] - fn loader_keeps_toml_extension_settings() { + fn extension_tables_are_refused() { let dir = tempfile::tempdir().unwrap(); - let path = dir.path().join("relay.toml"); - std::fs::write( - &path, - "[listen.extensions]\nietf = true\n\n[connect.extensions]\nsolicit = false\n", - ) - .unwrap(); - let config = Config::parse_and_merge([std::ffi::OsString::from("moq-relay"), path.into()]).unwrap(); - assert!(config.listen.extensions.ietf); - assert!(config.listen.extensions.solicit); - assert!(!config.connect.extensions.solicit); - assert!(!config.connect.extensions.ietf); + for table in [ + "[listen.extensions]\nietf = true\n", + "[connect.extensions]\nsolicit = false\n", + ] { + let path = dir.path().join("relay.toml"); + std::fs::write(&path, table).unwrap(); + let parsed = Config::parse_and_merge([std::ffi::OsString::from("moq-relay"), path.into()]); + assert!(parsed.is_err(), "{table}"); + } } #[test] diff --git a/rs/moq-relay/src/uring.rs b/rs/moq-relay/src/uring.rs index 532d041b516..9cdb7e76766 100644 --- a/rs/moq-relay/src/uring.rs +++ b/rs/moq-relay/src/uring.rs @@ -145,7 +145,6 @@ impl Workers { bind, versions, // With the versions and timeout, mapped onto the moq handshake by `listen.server()`. - extensions: _, implementation: _, timeout, tls: listen_tls, diff --git a/rs/moq-relay/tests/integration/auth_lifetime.rs b/rs/moq-relay/tests/integration/auth_lifetime.rs index 769a334ce45..be74b112849 100644 --- a/rs/moq-relay/tests/integration/auth_lifetime.rs +++ b/rs/moq-relay/tests/integration/auth_lifetime.rs @@ -2034,12 +2034,12 @@ async fn in_band_tokens_widen_and_withdraw_live_prefixes() { async fn request_token_lease_ends_before_the_connection_and_reopens_later() { let script = Script::new(Grant::new(all(), all())); let mut server = moq_tokio::listen::Config::default(); - server.extensions.solicit = false; + server.decline_solicit = true; let cluster = crate::spawn_cluster(cluster::Options::default()); let (port, relay) = spawn_relay_config(build_auth(script.spawn().await), cluster, server).await; let mut config = moq_tokio::connect::Config::default(); config.version = vec!["moq-transport-22".parse().unwrap()]; - config.extensions.solicit = false; + config.decline_solicit = true; let client = config.init(Default::default()).unwrap().with_reconnect(false); let origin = moq_tokio::origin::spawn(); let publisher = client diff --git a/rs/moq-tokio/Cargo.toml b/rs/moq-tokio/Cargo.toml index 11a17199ee3..6eb71f6dbd8 100644 --- a/rs/moq-tokio/Cargo.toml +++ b/rs/moq-tokio/Cargo.toml @@ -22,7 +22,12 @@ jemalloc = ["dep:tikv-jemallocator", "dep:tikv-jemalloc-ctl"] # `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. -test-support = ["kio/sim", "moq-quic/sim"] +# It also exposes the `decline_solicit` field of `connect::Config` and `listen::Config`, +# which acts as a moq-transport peer without MoQ Solicit. +test-support = ["kio/sim", "moq-quic/sim", "moq-net/test-support"] +# The `ietf` field of `connect::Config` and `listen::Config`, which offers the lite-07 `ietf` +# extension: moq-relay's door for its own links, not a setting. Hidden from the docs. +relay = ["moq-net/relay"] [dependencies] bytes = "1" diff --git a/rs/moq-tokio/src/client.rs b/rs/moq-tokio/src/client.rs index 65395a4c111..d525ad164ce 100644 --- a/rs/moq-tokio/src/client.rs +++ b/rs/moq-tokio/src/client.rs @@ -150,9 +150,15 @@ impl Client { policy.timeout = resolved.timeout; policy.pinned = !config.tls.fingerprint.is_empty(); - let mut moq = moq_net::Client::new() - .with_versions(versions.clone()) - .with_extensions(config.extensions); + let mut moq = moq_net::Client::new().with_versions(versions.clone()); + #[cfg(feature = "relay")] + { + moq = moq.with_ietf(config.ietf); + } + #[cfg(feature = "test-support")] + { + moq = moq.with_solicit(!config.decline_solicit); + } if let Some(implementation) = &config.implementation { moq = moq.with_implementation(implementation); } diff --git a/rs/moq-tokio/src/connect.rs b/rs/moq-tokio/src/connect.rs index 97c0c59d0bc..fed6b3958fd 100644 --- a/rs/moq-tokio/src/connect.rs +++ b/rs/moq-tokio/src/connect.rs @@ -369,19 +369,10 @@ impl ConnectError { mod tests { use super::*; - /// The dial config offers every extension unless told otherwise, and leaves the - /// default out when serialized. + /// The SETUP extensions are no setting: a file naming them is refused. #[test] - fn extensions_default_on_and_parse_off() { - let config: Config = toml::from_str("[extensions]\nsolicit = false\n").expect("parse"); - assert!(!config.extensions.solicit); - assert!(!config.extensions.ietf); - assert!(toml::to_string(&config).expect("serialize").contains("solicit = false")); - assert!( - !toml::to_string(&Config::default()) - .expect("serialize") - .contains("extensions") - ); + fn extensions_are_not_a_setting() { + assert!(toml::from_str::("[extensions]\nsolicit = false\n").is_err()); } #[test] @@ -487,11 +478,6 @@ failover_delay = "1s" } } -/// Whether `extensions` is the default a config leaves out. -pub(crate) fn all_extensions(extensions: &moq_net::setup::Extensions) -> bool { - *extensions == moq_net::setup::Extensions::default() -} - /// The dial side of an endpoint: where to connect and how to get there. /// /// Derives [`usage_rs::Args`], so flatten it into a binary's own parser with @@ -639,10 +625,19 @@ pub struct Config { )] pub version: Vec, - /// The extensions to offer in SETUP, every moq-transport one by default. - #[serde(default, skip_serializing_if = "crate::connect::all_extensions")] + /// Offer the `ietf` extension on moq-lite-07. Behind the `relay` feature: moq-relay's + /// door for its own links, not a setting. + #[cfg(feature = "relay")] #[usage(skip)] - pub extensions: moq_net::setup::Extensions, + #[serde(skip)] + pub ietf: bool, + + /// Decline MoQ Solicit, acting as a moq-transport peer without it. Behind the + /// `test-support` feature: a test's door, not a setting. + #[cfg(feature = "test-support")] + #[usage(skip)] + #[serde(skip)] + pub decline_solicit: bool, /// The implementation to advertise in SETUP, as space-separated `name/version` /// product tokens. `None` advertises [`moq_net::IMPLEMENTATION`]; empty advertises diff --git a/rs/moq-tokio/src/listen.rs b/rs/moq-tokio/src/listen.rs index a8da52e995c..e0310f495c3 100644 --- a/rs/moq-tokio/src/listen.rs +++ b/rs/moq-tokio/src/listen.rs @@ -138,10 +138,19 @@ pub struct Config { )] pub version: Vec, - /// The extensions to offer in SETUP, every moq-transport one by default. - #[serde(default, skip_serializing_if = "crate::connect::all_extensions")] + /// Offer the `ietf` extension on moq-lite-07. Behind the `relay` feature: moq-relay's + /// door for its own links, not a setting. + #[cfg(feature = "relay")] #[usage(skip)] - pub extensions: moq_net::setup::Extensions, + #[serde(skip)] + pub ietf: bool, + + /// Decline MoQ Solicit, acting as a moq-transport peer without it. Behind the + /// `test-support` feature: a test's door, not a setting. + #[cfg(feature = "test-support")] + #[usage(skip)] + #[serde(skip)] + pub decline_solicit: bool, /// The implementation to advertise in SETUP, as space-separated `name/version` /// product tokens. `None` advertises [`moq_net::IMPLEMENTATION`]; empty advertises @@ -266,8 +275,6 @@ pub struct Resolved { pub bind: Option, /// The versions to accept, every one when none was configured. pub versions: moq_net::Versions, - /// The extensions to offer in SETUP. - pub extensions: moq_net::setup::Extensions, /// The implementation to advertise in SETUP, or the runtime's own when unset. pub implementation: Option, /// The handshake deadline, from [`Config::resolved_timeout`]. @@ -560,7 +567,12 @@ impl Config { let Self { bind, version: _, - extensions, + // Offered by the moq-net server every listener accepts with, which no QUIC + // listener reads. + #[cfg(feature = "relay")] + ietf: _, + #[cfg(feature = "test-support")] + decline_solicit: _, implementation, timeout: _, tls, @@ -581,7 +593,6 @@ impl Config { Ok(Resolved { bind: bind.clone(), versions: self.versions(), - extensions: *extensions, implementation: implementation.clone(), timeout: self.resolved_timeout(), tls: tls.clone(), @@ -614,19 +625,10 @@ impl Config { mod tests { use super::*; - /// The listen config offers every extension unless told otherwise, and leaves the - /// default out when serialized. + /// The SETUP extensions are no setting: a file naming them is refused. #[test] - fn extensions_default_on_and_parse_off() { - let config: Config = toml::from_str("[extensions]\nsolicit = false\n").expect("parse"); - assert!(!config.extensions.solicit); - assert!(!config.extensions.ietf); - assert!(toml::to_string(&config).expect("serialize").contains("solicit = false")); - assert!( - !toml::to_string(&Config::default()) - .expect("serialize") - .contains("extensions") - ); + fn extensions_are_not_a_setting() { + assert!(toml::from_str::("[extensions]\nsolicit = false\n").is_err()); } /// A parser wrapping the config, since it derives `Args` (see the note in /// [`crate::connect`]). diff --git a/rs/moq-tokio/src/server.rs b/rs/moq-tokio/src/server.rs index 16ad1641c89..45f6cacd59f 100644 --- a/rs/moq-tokio/src/server.rs +++ b/rs/moq-tokio/src/server.rs @@ -65,8 +65,15 @@ impl crate::listen::Config { pub fn server(&self) -> moq_net::Server { let mut server = moq_net::Server::new() .with_timeout(self.resolved_timeout()) - .with_versions(self.versions()) - .with_extensions(self.extensions); + .with_versions(self.versions()); + #[cfg(feature = "relay")] + { + server = server.with_ietf(self.ietf); + } + #[cfg(feature = "test-support")] + { + server = server.with_solicit(!self.decline_solicit); + } if let Some(implementation) = &self.implementation { server = server.with_implementation(implementation); } diff --git a/test/interop/clients/js-native/control.ts b/test/interop/clients/js-native/control.ts index d4e31ce7578..80dbf58990b 100644 --- a/test/interop/clients/js-native/control.ts +++ b/test/interop/clients/js-native/control.ts @@ -1,7 +1,6 @@ /** Real JS wire peer for a TRACK_STATUS query. */ import assert from "node:assert/strict"; import * as Moq from "@moq/net"; -import { offered } from "../../../../js/net/src/connection/extensions.ts"; import { exchangeSetup } from "../../../../js/net/src/connection/handshake.ts"; import type * as Ietf from "../../../../js/net/src/ietf/index.ts"; import { NativeSession } from "../../../../js/net/src/ietf/session.ts"; @@ -20,8 +19,7 @@ const quic = new Qmux(new URL(address), { requireProtocol: true, }); await quic.ready; -const extensions = offered({ solicit: false }); -await exchangeSetup(quic, version, "interop-control", { client: true, extensions }); +await exchangeSetup(quic, version, "interop-control", { client: true, solicit: false }); const session = new NativeSession(quic, version, true); try { diff --git a/test/interop/clients/js-native/ranges.ts b/test/interop/clients/js-native/ranges.ts index ef354880fde..49b3dc9a51c 100644 --- a/test/interop/clients/js-native/ranges.ts +++ b/test/interop/clients/js-native/ranges.ts @@ -3,7 +3,6 @@ import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; import * as Moq from "@moq/net"; import WebTransport from "@moq/web-transport"; -import { offered } from "../../../../js/net/src/connection/extensions.ts"; import { exchangeSetup } from "../../../../js/net/src/connection/handshake.ts"; import { Connection } from "../../../../js/net/src/ietf/connection.ts"; import { Version } from "../../../../js/net/src/ietf/version.ts"; @@ -26,9 +25,8 @@ async function connect() { await transport.ready; // Moxygen's pinned HTTP/3 server predates subprotocol negotiation. This fixture's // server offers draft 18 alone, so exchange that SETUP directly on its WebTransport. - const extensions = offered({ solicit: false }); - const setup = await exchangeSetup(transport, Version.DRAFT_18, "interop-ranges", { client: true, extensions }); - return new Connection({ url, quic: transport, version: Version.DRAFT_18, client: true, extensions, ...setup }); + const setup = await exchangeSetup(transport, Version.DRAFT_18, "interop-ranges", { client: true, solicit: false }); + return new Connection({ url, quic: transport, version: Version.DRAFT_18, client: true, ...setup }); } function payload(bytes: Uint8Array, size: number) { diff --git a/test/interop/clients/js-native/server.ts b/test/interop/clients/js-native/server.ts index d9f62442ded..7d69e6eeec8 100644 --- a/test/interop/clients/js-native/server.ts +++ b/test/interop/clients/js-native/server.ts @@ -2,7 +2,6 @@ import assert from "node:assert/strict"; import { createInterface } from "node:readline"; import * as Moq from "@moq/net"; -import * as Extensions from "../../../../js/net/src/connection/extensions.ts"; import { exchangeSetup } from "../../../../js/net/src/connection/handshake.ts"; import { Connection } from "../../../../js/net/src/ietf/connection.ts"; import { GoAway } from "../../../../js/net/src/ietf/goaway.ts"; @@ -15,7 +14,6 @@ const [mode, name] = process.argv.slice(2); assert(name && mode === "goaway", "usage: server.ts goaway VERSION"); const version = (0xff000000 + Number(name.split("-").at(-1))) as Ietf.IetfVersion; const alpns = [`moqt-${Number(version) - 0xff000000}`]; -const extensions = Extensions.offered(); const origin = new Moq.Origin.Producer(); const broadcastRoute = origin.route(Moq.Path.from("handover"), { hidden: true }); const broadcast = broadcastRoute.broadcast; @@ -100,7 +98,7 @@ function listen(publish: Moq.Origin.Consumer) { } async function accept(quic: WebTransport, url: URL, publish: Moq.Origin.Consumer) { - const setup = await exchangeSetup(quic, version, "interop-js-server", { client: false, extensions }); + const setup = await exchangeSetup(quic, version, "interop-js-server", { client: false }); return { control: setup.control, connection: new Connection({ @@ -109,7 +107,6 @@ async function accept(quic: WebTransport, url: URL, publish: Moq.Origin.Consumer version, client: false, publish, - extensions, ...setup, }), }; diff --git a/test/interop/ietf-compression.ts b/test/interop/ietf-compression.ts index a2d636bbdfa..9e1b7894eed 100644 --- a/test/interop/ietf-compression.ts +++ b/test/interop/ietf-compression.ts @@ -1,6 +1,5 @@ /** JS does not offer IETF FLATE and consumes Rust's inflated fallback through its subscriber. */ import assert from "node:assert/strict"; -import { offered } from "../../js/net/src/connection/extensions.ts"; import { exchangeSetup } from "../../js/net/src/connection/handshake.ts"; import { Group } from "../../js/net/src/ietf/object.ts"; import { NativeSession } from "../../js/net/src/ietf/session.ts"; @@ -20,10 +19,7 @@ const pair = createMockTransportPair(`moqt-${input.draft}`); try { if (input.response === undefined) { // Exercise the real offer builder rather than constructing a reduced test offer. - const exchanging = exchangeSetup(pair.client, version, "compression interop", { - client: true, - extensions: offered(), - }); + const exchanging = exchangeSetup(pair.client, version, "compression interop", { client: true }); const remote = new Writer(await pair.server.createUnidirectionalStream(), version); await remote.u53(Setup.id); await new Setup().encode(remote, version);