diff --git a/doc/concept/standard.md b/doc/concept/standard.md index 0093964bf9d..68ccd9d86c1 100644 --- a/doc/concept/standard.md +++ b/doc/concept/standard.md @@ -11,7 +11,7 @@ with it, while shipping a simpler profile you can use today. | Spec | Scope | Here | | --- | --- | --- | -| [moq-transport](https://datatracker.ietf.org/doc/draft-ietf-moq-transport/) | The IETF pub/sub protocol | Drafts 18 and 22 negotiated by ALPN; [moq-lite](/concept/moq-lite) is a forward-compatible subset | +| [moq-transport](https://datatracker.ietf.org/doc/draft-ietf-moq-transport/) | The IETF pub/sub protocol | Drafts 18, 20, and 22 negotiated by ALPN; [moq-lite](/concept/moq-lite) is a forward-compatible subset | | [MSF](https://datatracker.ietf.org/doc/draft-ietf-moq-msf/) | The IETF catalog format | Read and written; broadcasts ending in `.msf` select it | | [LOC](https://datatracker.ietf.org/doc/draft-ietf-moq-loc/) | The IETF low-overhead container | Supported as a hang container kind | | [moq-lite](/draft/moq-lite), [hang](/draft/moq-hang), [e2ee](/draft/moq-e2ee), and friends | This project's own drafts | Normative for the implementation, published to the datatracker from [`drafts/`](https://github.com/moq-dev/moq/tree/main/drafts) | @@ -26,16 +26,16 @@ maps everything else to "not supported" or a harmless equivalent. The subset drops. What a peer actually observes against this implementation: - **Pull.** Subscribers ask. Single-track `PUBLISH` offers are declined, unless they answer our `SUBSCRIBE_TRACKS` (below); announce a namespace and serve the resulting subscriptions. Announcements go out unsolicited. A client asks only for the prefixes its readers watch, and a server or relay link for every prefix it may discover. We never hold two overlapping requests at a peer that did not declare solicit: a broader one replaces the narrower ones once they are closed. The solicit `SETUP` option makes us wait to be asked. Without it, a peer also gets each match as a `NAMESPACE` on its `SUBSCRIBE_NAMESPACE` stream, so it hears the namespace twice. We send `PUBLISH` only to answer a `SUBSCRIBE_TRACKS` (below). -- **`SUBSCRIBE_TRACKS` lists, it never pushes.** It lists every track of every broadcast under its prefix, later ones included. With `FORWARD=0`, each track gets a paused `PUBLISH` carrying its Track Properties, and a `PUBLISH_DONE` once the track is no longer listed: `TRACK_ENDED` if it finished, even just before its broadcast ended, and an error otherwise, since the track may go on elsewhere. A `REQUEST_UPDATE` with `FORWARD=1` resumes one, served from the cache like a `SUBSCRIBE` with the update's filter and answered with `LARGEST_OBJECT`; `FORWARD=0` pauses it again. Each paused `PUBLISH` opens only as the peer's stream credit admits it, so a peer that grants none holds none. A listing that omits `FORWARD` or sets it to 1 asks for every track's objects: on draft 22 each track gets `PUBLISH_SKIPPED`, and the subscriber `SUBSCRIBE`s to what it wants; draft 18 has no such skip, so the request is refused with `NOT_SUPPORTED`. A prefix overlapping another listing gets `PREFIX_OVERLAP`, a `TRACK_PROPERTY_FILTER` gets `NOT_SUPPORTED`, and a `REQUEST_UPDATE` on the listing itself ends it. On draft 18, a `SUBSCRIBE` to a track we `PUBLISH`ed gets `DUPLICATE_SUBSCRIPTION`. Cancelling the listing stops new `PUBLISH`es, while those sent live on. A broadcast is listed only while our publish grant covers it, from scratch once it does. Rust sends it upstream for a listing (below); JavaScript does not. +- **`SUBSCRIBE_TRACKS` lists, it never pushes.** It lists every track of every broadcast under its prefix, later ones included. With `FORWARD=0`, each track gets a paused `PUBLISH` carrying its Track Properties, and a `PUBLISH_DONE` once the track is no longer listed: `TRACK_ENDED` if it finished, even just before its broadcast ended, and an error otherwise, since the track may go on elsewhere. A `REQUEST_UPDATE` with `FORWARD=1` resumes one, served from the cache like a `SUBSCRIBE` with the update's filter and answered with `LARGEST_OBJECT`; `FORWARD=0` pauses it again. Each paused `PUBLISH` opens only as the peer's stream credit admits it, so a peer that grants none holds none. A listing that omits `FORWARD` or sets it to 1 asks for every track's objects: from draft 20 each track gets `PUBLISH_SKIPPED`, and the subscriber `SUBSCRIBE`s to what it wants; draft 18 has no such skip, so the request is refused with `NOT_SUPPORTED`. A prefix overlapping another listing gets `PREFIX_OVERLAP`, a `TRACK_PROPERTY_FILTER` gets `NOT_SUPPORTED`, and a `REQUEST_UPDATE` on the listing itself ends it. On draft 18, a `SUBSCRIBE` to a track we `PUBLISH`ed gets `DUPLICATE_SUBSCRIPTION`. Cancelling the listing stops new `PUBLISH`es, while those sent live on. A broadcast is listed only while our publish grant covers it, from scratch once it does. Rust sends it upstream for a listing (below); JavaScript does not. - **A Rust TRACKS listing sends `SUBSCRIBE_TRACKS` upstream, only on demand.** Listing a broadcast from a moq-transport peer sends `SUBSCRIBE_TRACKS` with `FORWARD=0` while someone lists it, never on connect, announce, or subscribe, so a peer that refuses, resets, or ignores it affects only that listing. Each listed track's paused `PUBLISH` is its upstream copy, which a reader resumes rather than subscribing again. Only a `PUBLISH_DONE` with `TRACK_ENDED` removes a listed track, and it lists as finished; any other end, including the error our own answerer sends for a track that left unfinished, fails the listing, and readers list again. -- **History is served one group at a time.** Our moq-transport publishers answer a `FETCH` only within one group, a draft-18 joining `FETCH` for the subscription's current group head, and a draft-22 fill for the largest group's head. Whole-group fetches wait for an open group to finish. Both implementations accept and ignore `FILL_TIMEOUT`, including zero. A JavaScript subscription joins at the current group: on draft 18 it fetches the group's head with a Relative Joining `FETCH`, and on draft 22 asks for it with a fill. Datagrams are never fetchable. Subscribers still request ranges upstream, one per run of missing groups; a third-party publisher can answer those ranges and mark their gaps. A Rust reader that only fetches learns the track from `TRACK_STATUS`, so a finished track stays fetchable; a reader whose publisher refuses `TRACK_STATUS` as `NOT_SUPPORTED` still subscribes. +- **History is served one group at a time.** Our moq-transport publishers answer a `FETCH` only within one group, a draft-18 joining `FETCH` for the subscription's current group head, and a draft 20+ fill for the largest group's head. Whole-group fetches wait for an open group to finish. Both implementations accept and ignore `FILL_TIMEOUT`, including zero. A JavaScript subscription joins at the current group: on draft 18 it fetches the group's head with a Relative Joining `FETCH`, and from draft 20 asks for it with a fill. Datagrams are never fetchable. Subscribers still request ranges upstream, one per run of missing groups; a third-party publisher can answer those ranges and mark their gaps. A Rust reader that only fetches learns the track from `TRACK_STATUS`, so a finished track stays fetchable; a reader whose publisher refuses `TRACK_STATUS` as `NOT_SUPPORTED` still subscribes. - **Compression.** Rust peers exchange compressed tracks when both offer the [Flate extension](/draft/moq-flate). Other peers receive one shared inflated copy. A publisher that seals the compression declaration makes that fallback unavailable: an incompatible peer is refused, preserving the sealed metadata. JavaScript does not offer the IETF extension. - **Timing.** A track whose `SUBSCRIBE_OK` declares no `TIMESCALE` is untimed. A Rust reader that never subscribed takes the units from `TRACK_STATUS`. - **Strict SETUP and parameters.** Repeated unknown `SETUP` options, GREASE included, are accepted if well-formed; a repeated known option is rejected. A `GROUP_ORDER` other than Ascending (1) or Descending (2) closes the session. An unknown message parameter, or one defined only for another message, closes the session. Other malformed control input closes the session with the draft's code too, such as a server `SETUP` carrying `PATH` or `AUTHORITY`, a namespace field ending in `/` (it would map to a path with an empty segment), a request cut short by FIN, or a second `GOAWAY` on one stream; a first `GOAWAY` on a request stream is legal. - **One `SETUP` credential**, forwarded to the [auth server](/bin/relay/auth#the-contract) unverified. A second `SETUP` token closes the session. We advertise no token cache, so an alias reference in `SETUP` closes it with `PROTOCOL_VIOLATION`, one on a request with `UNKNOWN_AUTH_TOKEN_ALIAS`, and a registration on a request with `AUTH_TOKEN_CACHE_OVERFLOW`. Where the Rust side authorizes the peer or verifies tokens, a token on a `SUBSCRIBE` or `PUBLISH_NAMESPACE` is verified like an in-band session token and authorizes that one request alone, even where that authorization already covers it; it never widens the session. It is refused with `NOT_SUPPORTED` when nothing verifies it, when it is empty, or when its Token Type is anything but 0 (out of band). A side that does neither, JavaScript included, ignores the token. Rust refuses a request carrying more than one distinct token with `NOT_SUPPORTED`, since it verifies one; JavaScript, which verifies none, ignores them all. A token-authorized `SUBSCRIBE` still stays within the grant the peer gave us. A token-authorized `PUBLISH_NAMESPACE` needs a grant covering everything beneath the namespace, and the tracks we subscribe under it rely on that announce instead of our limit, ending with it. An update renews the token, and a refused renewal ends only that request. Rust and JavaScript send the token a route names (`Route::auth`) on its `PUBLISH_NAMESPACE`, and swapping it renews the request with `REQUEST_UPDATE`; the inline `NAMESPACE` that answers a solicited `SUBSCRIBE_NAMESPACE` carries no token. A token added to a reconnecting connection's auth handle rides every session it makes, so the announcement keeps it across a reconnect; one added to a single session's handle ends with that session. A token on any other request is decoded and grants nothing, and a request repeating one is refused with `MALFORMED_AUTH_TOKEN`. The negotiated [MoQ Auth extension](/concept/moq-lite#authorization) accepts additional session tokens in band. - **Pause delivery.** `FORWARD=0` on a `SUBSCRIBE` or its update drops the subscription, closing its data streams and holding nothing upstream, while the request and its slot stay. `FORWARD=1` subscribes again as a new `SUBSCRIBE` with the same filter would, so nothing carries across the pause: its `REQUEST_OK` names the live edge it joined at. A paused update may change only priority and max age. -- **Refused, not fatal.** A legal request this stack does not serve is rejected on its own and the session stays up: multi-group `FETCH` and joining requests reaching before the joined group get `NOT_SUPPORTED`. Range Filters get `INVALID_FILTER` on draft 22 because the advertised filter limit is zero. On draft 22, namespaces whose first tuple field is exactly `.` or `.session` get `DOES_NOT_EXIST` before application lookup; other dot prefixes still reach the application. Subscription updates accept priority, negotiated subscriber max age, and delivery timeouts. Rust also carries range changes, keeps bounded subscriptions updatable, renews request tokens, and judges `NEW_GROUP_REQUEST` as a join (see dynamic groups below). On draft 22, a wider or historical fill fails on its separate fetch stream while its subscription stays open; a largest-group fill hands its head to the live subgroup tail. Other supported-but-unimplemented preferences end that subscription; a `TRACK_PROPERTY_FILTER` there closes the session with `PROTOCOL_VIOLATION`, since it belongs only to `SUBSCRIBE_TRACKS`. A namespace update may change its prefix; suffixes after the acknowledgement are relative to that new prefix. -- **Objects and datagrams.** Only subgroup 0 is accepted: a stream for any other subgroup, whether its header gives the ID or takes it from the first Object ID, is stopped and the session stays up. Rust relays preserve Object IDs, gaps, object properties, FIRST\_OBJECT, and END\_OF\_GROUP status objects between moq-transport peers for subgroup 0, including across a moq-lite-07 hop between two relays that negotiate the [ietf](/draft/moq-ietf) extension. Datagrams retain their IDs, properties, priority, and status. Plain Rust readers and moq-lite peers without the extension see consecutive frames and only normal datagram payloads at Object ID 0; other datagram objects and statuses are dropped on those surfaces. JavaScript supports only normal datagrams at Object ID 0. A malformed datagram closes the session; a relayed one the downstream draft cannot carry is dropped. A relayed Timestamp leaves in the units the downstream response declares, and is dropped where it declares none, as for a plain frame; an immutable one that would change or vanish is refused. On a timed track the frame holds each object's time, so a mutable Timestamp that only repeats the immutable one is not restated; a status object has no frame, so it keeps its Timestamp among its properties. Only property 0x10 is read as a Timestamp. Property 0x06 stays opaque and keeps its value regardless of timestamp units; it is dropped between drafts 18 and 22, or refused when immutable, because draft 22 assigns it to SUBGROUP\_DELIVERY\_TIMEOUT. A status object carrying properties is refused. A `FETCH` has no status objects, so its response ends at the last frame. A group cannot resume across route changes by frame ordinal once Object IDs skip ahead of the ordinals on either route; recovery refuses it instead of splicing different objects. +- **Refused, not fatal.** A legal request this stack does not serve is rejected on its own and the session stays up: multi-group `FETCH` and joining requests reaching before the joined group get `NOT_SUPPORTED`. Range Filters get `INVALID_FILTER` from draft 20 because the advertised filter limit is zero. From draft 20, namespaces whose first tuple field is exactly `.` or `.session` get `DOES_NOT_EXIST` before application lookup; other dot prefixes still reach the application. Subscription updates accept priority, negotiated subscriber max age, and delivery timeouts. Rust also carries range changes, keeps bounded subscriptions updatable, renews request tokens, and judges `NEW_GROUP_REQUEST` as a join (see dynamic groups below). From draft 20, a wider or historical fill fails on its separate fetch stream while its subscription stays open; a largest-group fill hands its head to the live subgroup tail. Other supported-but-unimplemented preferences end that subscription; a `TRACK_PROPERTY_FILTER` there closes the session with `PROTOCOL_VIOLATION`, since it belongs only to `SUBSCRIBE_TRACKS`. A namespace update may change its prefix; suffixes after the acknowledgement are relative to that new prefix. +- **Objects and datagrams.** Only subgroup 0 is accepted: a stream for any other subgroup, whether its header gives the ID or takes it from the first Object ID, is stopped and the session stays up. Rust relays preserve Object IDs, gaps, object properties, FIRST\_OBJECT, and END\_OF\_GROUP status objects between moq-transport peers for subgroup 0, including across a moq-lite-07 hop between two relays that negotiate the [ietf](/draft/moq-ietf) extension. Datagrams retain their IDs, properties, priority, and status. Plain Rust readers and moq-lite peers without the extension see consecutive frames and only normal datagram payloads at Object ID 0; other datagram objects and statuses are dropped on those surfaces. JavaScript supports only normal datagrams at Object ID 0. A malformed datagram closes the session; a relayed one the downstream draft cannot carry is dropped. A relayed Timestamp leaves in the units the downstream response declares, and is dropped where it declares none, as for a plain frame; an immutable one that would change or vanish is refused. On a timed track the frame holds each object's time, so a mutable Timestamp that only repeats the immutable one is not restated; a status object has no frame, so it keeps its Timestamp among its properties. Only property 0x10 is read as a Timestamp. Property 0x06 stays opaque and keeps its value regardless of timestamp units; it is dropped between draft 18 and later drafts, or refused when immutable, because draft 20 assigns it to SUBGROUP\_DELIVERY\_TIMEOUT. A status object carrying properties is refused. A `FETCH` has no status objects, so its response ends at the last frame. A group cannot resume across route changes by frame ordinal once Object IDs skip ahead of the ordinals on either route; recovery refuses it instead of splicing different objects. - **Dynamic groups.** A track advertises `DYNAMIC_GROUPS` when its publisher sets a refresh ratio, and a track received with `DYNAMIC_GROUPS` gets a ratio of 0. A `NEW_GROUP_REQUEST` counts as one more subscriber joining, which a `SUBSCRIBE` already is: it asks for a new group only when the newest group's bytes after its first frame exceed the ratio times the first frame. Joins coalesce until the asked-for group arrives. A Rust relay sends `NEW_GROUP_REQUEST` upstream, on the `SUBSCRIBE` or in a `REQUEST_UPDATE`, once a join wants a group past the newest it holds; a relay holding nothing yet asks for none. On a track without a ratio, an update carrying one ends the subscription with `UPDATE_FAILED`. A moq-lite-07 hop (`moq-lite-07-wip`, opt-in) carries the same demand natively: the ratio in `TRACK_INFO` and the asked-for group in `SUBSCRIBE_UPDATE`. Earlier moq-lite versions carry neither, so a track received over one never refreshes. - **Priority.** Higher is served first. This stack's priorities run from -128 to 127 with 0 unset, and go out on the IETF wire, which ranks lower first, as `127 - priority`: an unset priority is IETF 127. An omitted subscriber or publisher priority reads as the drafts' default of IETF 128, one step below unset, so a relay forwards it unchanged. A relay's upstream subscription carries the highest priority its subscribers ask for and updates it as they come and go; its group order stays as the `SUBSCRIBE` asked, since no draft lets an update change it. - **Size.** An object extension block larger than 64 KiB ends that subgroup stream. The session stays up. This cap is ours, not the draft's. @@ -85,7 +85,7 @@ choices. They follow the product model. Immutable property blocks retain their bytes. Forwarding is refused when the negotiated drafts use incompatible key or integer encodings, or when the block holds a Timestamp in units the response does not declare. Property 0x06 crosses - between drafts 18 and 22 as it does on an object. A track carrying a + between draft 18 and later drafts as it does on an object. A track carrying a Mandatory Track Property (0x4000-0x7FFF) is refused with `UNSUPPORTED_EXTENSION` instead. diff --git a/js/net/src/connection/accept.ts b/js/net/src/connection/accept.ts index 3fa1e923593..7156d204208 100644 --- a/js/net/src/connection/accept.ts +++ b/js/net/src/connection/accept.ts @@ -123,6 +123,9 @@ async function acceptInner( if (protocol === Ietf.ALPN.DRAFT_22) { return acceptAlpn(transport, url, Ietf.Version.DRAFT_22, wiring); } + if (protocol === Ietf.ALPN.DRAFT_20) { + return acceptAlpn(transport, url, Ietf.Version.DRAFT_20, wiring); + } if (protocol === Ietf.ALPN.DRAFT_18) { return acceptAlpn(transport, url, Ietf.Version.DRAFT_18, wiring); } else if (protocol === Lite.ALPN_07_WIP) { diff --git a/js/net/src/connection/connect.ts b/js/net/src/connection/connect.ts index 1ac53d96214..2fac875e451 100644 --- a/js/net/src/connection/connect.ts +++ b/js/net/src/connection/connect.ts @@ -96,6 +96,7 @@ const VERSIONS: Record = { "moq-lite-02": { alpn: Lite.ALPN, setup: Lite.Version.DRAFT_02 }, "moq-lite-01": { alpn: Lite.ALPN, setup: Lite.Version.DRAFT_01 }, "moq-transport-22": { alpn: Ietf.ALPN.DRAFT_22 }, + "moq-transport-20": { alpn: Ietf.ALPN.DRAFT_20 }, "moq-transport-18": { alpn: Ietf.ALPN.DRAFT_18 }, }; @@ -107,6 +108,7 @@ const DEFAULT_VERSIONS = Object.keys(VERSIONS).filter((name) => name !== "moq-li // it knows and the server pick one. const QMUX: Record = { [Ietf.ALPN.DRAFT_22]: "qmux-01", + [Ietf.ALPN.DRAFT_20]: "qmux-01", [Ietf.ALPN.DRAFT_18]: "qmux-01", }; @@ -494,9 +496,11 @@ async function negotiate( const ietf = protocol === Ietf.ALPN.DRAFT_22 ? Ietf.Version.DRAFT_22 - : protocol === Ietf.ALPN.DRAFT_18 - ? Ietf.Version.DRAFT_18 - : undefined; + : protocol === Ietf.ALPN.DRAFT_20 + ? Ietf.Version.DRAFT_20 + : protocol === Ietf.ALPN.DRAFT_18 + ? Ietf.Version.DRAFT_18 + : undefined; if (ietf !== undefined) { return await handshakeAlpn(url, session, ietf, wiring); } else if (protocol === Lite.ALPN_07_WIP) { diff --git a/js/net/src/error.test.ts b/js/net/src/error.test.ts index aa0d5820a9e..ee7bdc58507 100644 --- a/js/net/src/error.test.ts +++ b/js/net/src/error.test.ts @@ -375,7 +375,7 @@ test("toStreamCode: a control timeout keeps its own code", () => { expect(toStreamCode(timeout)).toBe(StreamCode.ControlTimeout); // The moq-transport registry has no value for it, so every draft reads it as INTERNAL_ERROR. - for (const version of [Version.DRAFT_18, Version.DRAFT_22]) { + for (const version of [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22]) { expect(toStreamCode(timeout, { version })).toBe(StreamCode.Internal); } diff --git a/js/net/src/ietf/datagram.test.ts b/js/net/src/ietf/datagram.test.ts index 2ad2b042669..b471a8d03fc 100644 --- a/js/net/src/ietf/datagram.test.ts +++ b/js/net/src/ietf/datagram.test.ts @@ -4,7 +4,7 @@ import { encodeVarint } from "../stream.ts"; import { ObjectDatagram } from "./datagram.ts"; import { type IetfVersion, Version } from "./version.ts"; -const ALL: IetfVersion[] = [Version.DRAFT_18, Version.DRAFT_22]; +const ALL: IetfVersion[] = [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22]; function single(publisherPriority?: number): ObjectDatagram { return new ObjectDatagram({ diff --git a/js/net/src/ietf/epoch.test.ts b/js/net/src/ietf/epoch.test.ts index 82e2523ed44..d5902668b7f 100644 --- a/js/net/src/ietf/epoch.test.ts +++ b/js/net/src/ietf/epoch.test.ts @@ -20,7 +20,7 @@ const VERSION = Version.DRAFT_18; const EPOCH_PARAM = 0x40b69n; const EPOCH = Epoch.mint(); -const ALL = [Version.DRAFT_18, Version.DRAFT_22] as const; +const ALL = [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22] as const; async function encode( message: { encode(w: Writer, v: IetfVersion): Promise }, diff --git a/js/net/src/ietf/error.test.ts b/js/net/src/ietf/error.test.ts index 180a68cf73b..c990111992c 100644 --- a/js/net/src/ietf/error.test.ts +++ b/js/net/src/ietf/error.test.ts @@ -2,7 +2,7 @@ import { expect, test } from "bun:test"; import { fromRequestCode, type RequestCondition, type RequestKind, toRequestCode } from "./error.ts"; import { type IetfVersion, Version } from "./version.ts"; -const ALL: IetfVersion[] = [Version.DRAFT_18, Version.DRAFT_22]; +const ALL: IetfVersion[] = [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22]; const KINDS: RequestKind[] = [ "subscribe", @@ -84,11 +84,11 @@ test("going away is 0x6 on every request", () => { } }); -test("INVALID_FILTER is registered from draft 22", () => { +test("INVALID_FILTER is registered from draft 20", () => { for (const version of ALL) { - expect(toRequestCode("invalid_filter", "subscribe", version)).toBe(version >= Version.DRAFT_22 ? 0x36 : 0); + expect(toRequestCode("invalid_filter", "subscribe", version)).toBe(version >= Version.DRAFT_20 ? 0x36 : 0); expect(fromRequestCode(0x36, "fetch", version)).toBe( - version >= Version.DRAFT_22 ? "invalid_filter" : undefined, + version >= Version.DRAFT_20 ? "invalid_filter" : undefined, ); } }); diff --git a/js/net/src/ietf/error.ts b/js/net/src/ietf/error.ts index 82700e1da80..6192484230d 100644 --- a/js/net/src/ietf/error.ts +++ b/js/net/src/ietf/error.ts @@ -112,7 +112,7 @@ function invalidJoiningRequestId(kind: RequestKind, version: IetfVersion): numbe export function toRequestCode(condition: RequestCondition, kind: RequestKind, version: IetfVersion): number { switch (condition) { case "invalid_filter": - return version >= Version.DRAFT_22 ? INVALID_FILTER : INTERNAL_ERROR; + return version >= Version.DRAFT_20 ? INVALID_FILTER : INTERNAL_ERROR; case "internal": return INTERNAL_ERROR; case "unauthorized": @@ -161,7 +161,7 @@ export function fromRequestCode(code: number, kind: RequestKind, version: IetfVe return "not_supported"; } - if (code === INVALID_FILTER && version >= Version.DRAFT_22) return "invalid_filter"; + if (code === INVALID_FILTER && version >= Version.DRAFT_20) return "invalid_filter"; if (code === DOES_NOT_EXIST) return "does_not_exist"; if (code === invalidRange(kind)) return "invalid_range"; if (code === invalidJoiningRequestId(kind, version)) return "invalid_joining_request_id"; diff --git a/js/net/src/ietf/fetch.test.ts b/js/net/src/ietf/fetch.test.ts index bc1519591d2..fbcd95a6afa 100644 --- a/js/net/src/ietf/fetch.test.ts +++ b/js/net/src/ietf/fetch.test.ts @@ -19,10 +19,11 @@ import { NativeSession } from "./session.ts"; import { Subscribe, SubscribeOk } from "./subscribe.ts"; import { ALPN, type IetfVersion, Version } from "./version.ts"; -const VERSIONS = [Version.DRAFT_18, Version.DRAFT_22] as const; +const VERSIONS = [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22] as const; const D18 = Version.DRAFT_18; +const D20 = Version.DRAFT_20; const D22 = Version.DRAFT_22; -const ALPNS: Record = { [D18]: ALPN.DRAFT_18, [D22]: ALPN.DRAFT_22 }; +const ALPNS: Record = { [D18]: ALPN.DRAFT_18, [D20]: ALPN.DRAFT_20, [D22]: ALPN.DRAFT_22 }; const SUBSCRIBE_ID = 7n; const FETCH_ID = 9n; diff --git a/js/net/src/ietf/fetch.ts b/js/net/src/ietf/fetch.ts index fe88878009d..9b4a5f0652e 100644 --- a/js/net/src/ietf/fetch.ts +++ b/js/net/src/ietf/fetch.ts @@ -145,7 +145,7 @@ export class Fetch { params.fillTimeout = this.fillTimeout; const type = this.type; - if (Filter.isDraft22(version)) { + if (Filter.isDraft20(version)) { // The joining forms and the Fetch Type tag are gone in draft-22. if (type.kind !== "filtered") throw new Error(`${type.kind} FETCH needs draft-18`); await Namespace.encodeTrack(w, type.trackNamespace, type.trackName); @@ -191,7 +191,7 @@ export class Fetch { const requestId = await r.u62(); let type: FetchType; - if (Filter.isDraft22(version)) { + if (Filter.isDraft20(version)) { // Draft-22 names the track up front and moves the range into LOCATION_FILTER. const { namespace, name } = await Namespace.decodeTrack(r); // Placeholder until the parameters name the filter. diff --git a/js/net/src/ietf/filter.test.ts b/js/net/src/ietf/filter.test.ts index 41d91bb331d..9280400cb86 100644 --- a/js/net/src/ietf/filter.test.ts +++ b/js/net/src/ietf/filter.test.ts @@ -7,6 +7,7 @@ import { joinFilter } from "./subscribe.ts"; import { Version } from "./version.ts"; const OLD = Version.DRAFT_18; +const FIELDS = Version.DRAFT_20; const NEW = Version.DRAFT_22; test("a live join is Next Object, its head left to a joining FETCH or a StartGroup=1 fill", () => { @@ -14,15 +15,84 @@ test("a live join is Next Object, its head left to a joining FETCH or a StartGro expect([...Filter.encode(old.filter, OLD)]).toEqual([0x02]); expect(old.fill).toBeUndefined(); + const draft20 = joinFilter(FIELDS); + expect([...Filter.encode(draft20.filter, FIELDS)]).toEqual([0x00, 0x00]); + expect(draft20.fill).toEqual({ filter: { kind: "relative", groups: 1n }, rangeFilters: false }); + const draft22 = joinFilter(NEW); expect([...Filter.encode(draft22.filter, NEW)]).toEqual([0x05]); expect(draft22.fill).toEqual({ filter: { kind: "relative", groups: 1n }, rangeFilters: false }); }); -function roundTrip(filter: Filter.Filter, version: typeof OLD | typeof NEW): Filter.Filter { +function roundTrip(filter: Filter.Filter, version: typeof OLD | typeof FIELDS | typeof NEW): Filter.Filter { return Filter.decode(Filter.encode(filter, version), version); } +test("draft-20 selects the meaning by field count", () => { + expect([...Filter.encode({ kind: "nextObject" }, FIELDS)]).toEqual([0x00, 0x00]); + expect([...Filter.encode({ kind: "relative", groups: 0n }, FIELDS)]).toEqual([0x00]); + expect([...Filter.encode({ kind: "relative", groups: 1n }, FIELDS)]).toEqual([0x01]); + expect([...Filter.encode({ kind: "absolute", startGroup: 7n, startObject: 3n }, FIELDS)]).toEqual([0x07, 0x03]); + // End is a delta from the start group, not an absolute group id. + expect([...Filter.encode({ kind: "absolute", startGroup: 7n, startObject: 3n, endGroup: 9n }, FIELDS)]).toEqual([ + 0x07, 0x03, 0x02, + ]); + // The value is framed by a Length, unlike draft-22's typed form. + expect([...Filter.encodeParam({ kind: "nextObject" }, FIELDS)]).toEqual([0x02, 0x00, 0x00]); +}); + +test("draft-20 round trips", () => { + const filters: Filter.Filter[] = [ + { kind: "unfiltered" }, + { kind: "nextObject" }, + { kind: "relative", groups: 0n }, + { kind: "relative", groups: 5n }, + { kind: "relative", groups: 128n }, + { kind: "absolute", startGroup: 12n, startObject: 0n, endGroup: undefined, endObject: undefined }, + { kind: "absolute", startGroup: 12n, startObject: 4n, endGroup: 20n, endObject: undefined }, + ]; + for (const filter of filters) { + expect(roundTrip(filter, FIELDS)).toEqual(filter); + } +}); + +// An open ended absolute {0, 0} is defined as equivalent to unfiltered, so it must not +// collide with the two-zero-field spelling of Next Object. +test("draft-20 absolute origin is unfiltered", () => { + const origin: Filter.Filter = { kind: "absolute", startGroup: 0n, startObject: 0n }; + expect(Filter.encode(origin, FIELDS).length).toBe(0); + expect(roundTrip(origin, FIELDS)).toEqual({ kind: "unfiltered" }); +}); + +// The fourth field bounds the last object in the end group. Dropping it on decode would +// let a publisher deliver past the Location the subscriber asked for. +test("draft-20 keeps the end object", () => { + const bounded: Filter.Filter = { + kind: "absolute", + startGroup: 7n, + startObject: 3n, + endGroup: 9n, + endObject: 4n, + }; + expect([...Filter.encode(bounded, FIELDS)]).toEqual([0x07, 0x03, 0x02, 0x04]); + expect(roundTrip(bounded, FIELDS)).toEqual(bounded); +}); + +test("draft-20 rejects too many fields", () => { + expect(() => Filter.decode(new Uint8Array([0, 0, 0, 0, 0]), FIELDS)).toThrow(); +}); + +// Draft-20's nested LOCATION_FILTER keeps its Length. +test("draft-20 fill frames its filter with a Length", () => { + const encoded = Filter.encodeFill({ filter: { kind: "relative", groups: 1n }, rangeFilters: false }, FIELDS); + // count=1, type=0x21, len=1, StartGroup=1 + expect([...encoded]).toEqual([0x01, 0x21, 0x01, 0x01]); + expect(Filter.decodeFill(encoded, FIELDS)).toEqual({ + filter: { kind: "relative", groups: 1n }, + rangeFilters: false, + }); +}); + test("draft-18 uses tags", () => { expect([...Filter.encode({ kind: "nextObject" }, OLD)]).toEqual([0x02]); expect([...Filter.encode({ kind: "relative", groups: 0n }, OLD)]).toEqual([0x01]); diff --git a/js/net/src/ietf/filter.ts b/js/net/src/ietf/filter.ts index 425a18d08e3..71149cf4d83 100644 --- a/js/net/src/ietf/filter.ts +++ b/js/net/src/ietf/filter.ts @@ -35,15 +35,24 @@ const TAG_ABSOLUTE_START = 0x3n; const TAG_ABSOLUTE_RANGE = 0x4n; /** - * Whether this is draft-22 or newer. + * Whether this is draft-20 or newer. * - * Draft-22 replaced the Filter Type tag with a Location Filter Type that names the fields - * that follow, so the value carries no Length, and added the parameters that ride with it. + * Draft-20 replaced the Filter Type tag with up to four optional varints, where the number + * present selects the meaning, and added the parameters that ride with it. Draft-22 names + * the meaning with a Location Filter Type instead, but keeps those parameters. */ -export function isDraft22(version: IetfVersion): boolean { +export function isDraft20(version: IetfVersion): boolean { return version !== Version.DRAFT_18; } +/** + * Whether LOCATION_FILTER starts with a Location Filter Type, which says which fields follow, + * so the value carries no Length. Draft-22 replaced draft-20's field count with it. + */ +function isTyped(version: IetfVersion): boolean { + return isDraft20(version) && version !== Version.DRAFT_20; +} + /** The Location Filter Type of draft-22. */ const TYPE_NONE = 0x0n; const TYPE_RELATIVE_START = 0x1n; @@ -54,7 +63,7 @@ const TYPE_NEXT_OBJECT = 0x5n; /** Whether the Range Filters exist on this draft. */ export function hasRangeFilters(version: IetfVersion): boolean { - return isDraft22(version); + return isDraft20(version); } const varint = Varint.encodeLeadingOnes; @@ -69,19 +78,20 @@ function endDelta(startGroup: bigint, endGroup: bigint): bigint { /** Encode a filter as its raw parameter value, without the Length that frames it before draft-22. */ export function encode(filter: Filter, version: IetfVersion): Uint8Array { - return isDraft22(version) ? encodeTyped(filter) : encodeTag(filter); + if (isTyped(version)) return encodeTyped(filter); + return isDraft20(version) ? encodeFields(filter) : encodeTag(filter); } /** Encode LOCATION_FILTER's value as it follows the parameter type from draft-17 on. */ export function encodeParam(filter: Filter, version: IetfVersion): Uint8Array { const value = encode(filter, version); // Draft-22's Location Filter Type says where the value ends, so it needs no Length. - return isDraft22(version) ? value : encodeLengthPrefixed(value); + return isTyped(version) ? value : encodeLengthPrefixed(value); } /** Read LOCATION_FILTER's value as it follows the parameter type from draft-17 on. */ export async function decodeParam(r: Reader, version: IetfVersion): Promise { - if (!isDraft22(version)) { + if (!isTyped(version)) { return decode(await r.read(await r.u53()), version); } const type = await r.u62(); @@ -92,6 +102,32 @@ export async function decodeParam(r: Reader, version: IetfVersion): Promise 0) { + if (fields.length === 4) { + throw new Error("too many fields in LOCATION_FILTER"); + } + const [value, next] = unvarint(rest); + fields.push(value); + rest = next; + } + + switch (fields.length) { + case 0: + return { kind: "unfiltered" }; + case 1: + return { kind: "relative", groups: fields[0] }; + default: { + const [startGroup, startObject] = fields; + // Two zeroes is the Next Object spelling; anything else is an absolute start. + if (fields.length === 2 && startGroup === 0n && startObject === 0n) { + return { kind: "nextObject" }; + } + const endGroup = fields.length >= 3 ? startGroup + fields[2] : undefined; + const endObject = fields.length === 4 ? fields[3] : undefined; + return { kind: "absolute", startGroup, startObject, endGroup, endObject }; + } + } } function decodeTag(data: Uint8Array): Filter { @@ -386,7 +453,7 @@ export function decodeFill(data: Uint8Array, version: IetfVersion): Fill { if (filter !== undefined) { throw new Error("duplicate LOCATION_FILTER inside FILL_PARAMETERS"); } - if (isDraft22(version)) { + if (isTyped(version)) { [filter, rest] = readTyped(rest); } else { let value: Uint8Array; diff --git a/js/net/src/ietf/ietf.test.ts b/js/net/src/ietf/ietf.test.ts index 8950f25be5e..bdf0a742ae6 100644 --- a/js/net/src/ietf/ietf.test.ts +++ b/js/net/src/ietf/ietf.test.ts @@ -103,7 +103,7 @@ async function encodeFetchFrameVersioned( } test("DEFAULT_PUBLISHER_PRIORITY has exact SUBSCRIBE_OK bytes per draft", async () => { - for (const version of [Version.DRAFT_18, Version.DRAFT_22] as const) { + for (const version of [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22] as const) { const baseline = await encodeVersioned(new Subscribe.SubscribeOk({ trackAlias: 42n }), version); const encoded = await encodeVersioned( new Subscribe.SubscribeOk({ trackAlias: 42n, properties: { priority: 37 } }), @@ -116,7 +116,7 @@ test("DEFAULT_PUBLISHER_PRIORITY has exact SUBSCRIBE_OK bytes per draft", async }); test("DEFAULT_PUBLISHER_PRIORITY has exact PUBLISH bytes per draft", async () => { - for (const version of [Version.DRAFT_18, Version.DRAFT_22] as const) { + for (const version of [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22] as const) { const fields = { requestId: 1n, trackNamespace: Path.from("ns"), @@ -151,7 +151,7 @@ test("Message Parameters: Location preserves bigint precision", async () => { expect(params.largest).toEqual(largest); - for (const version of [Version.DRAFT_18, Version.DRAFT_22]) { + for (const version of [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22]) { const encoded = await encodeVersioned(params, version); const decoded = await decodeVersioned(encoded, Parameters.decode, version); expect(decoded.largest).toEqual(largest); @@ -165,7 +165,7 @@ test("Message Parameters: Location preserves full uint64 values", async () => { expect(params.largest).toEqual(largest); - for (const version of [Version.DRAFT_18, Version.DRAFT_22]) { + for (const version of [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22]) { const encoded = await encodeVersioned(params, version); const decoded = await decodeVersioned(encoded, Parameters.decode, version); expect(decoded.largest).toEqual(largest); @@ -173,7 +173,7 @@ test("Message Parameters: Location preserves full uint64 values", async () => { }); test("PublishDone: preserves unknown statuses across supported versions", async () => { - const versions = [Version.DRAFT_18, Version.DRAFT_22] as const; + const versions = [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22] as const; for (const version of versions) { const msg = new PublishDone({ @@ -610,7 +610,7 @@ test("RequestOk v18: round trip", async () => { // A REQUEST_UPDATE_OK or TRACK_STATUS_OK must carry LARGEST_OBJECT once the track has // objects, so a REQUEST_OK with one decodes. test("RequestOk: accepts LARGEST_OBJECT", async () => { - const versions = [Version.DRAFT_18, Version.DRAFT_22] as const; + const versions = [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22] as const; for (const version of versions) { const body = [0x01, 0x09, 0x05, 0x03]; const bytes = new Uint8Array([0x00, body.length, ...body]); @@ -699,7 +699,7 @@ test("group flags round-trip firstObject", async () => { }, }); - for (const version of [Version.DRAFT_18, Version.DRAFT_22]) { + for (const version of [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22]) { for (const firstObject of [true, false]) { const encoded = await encodeVersioned(makeGroup(firstObject), version); const decoded = await decodeVersioned(encoded, Group.decode, version); @@ -803,7 +803,7 @@ test("Frame reads only the current LOC Timestamp ID on every draft", async () => hasPriority: true, firstObject: true, }; - for (const version of [Version.DRAFT_18, Version.DRAFT_22] as const) { + for (const version of [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22] as const) { for (const id of [0x06, 0x10]) { const reader = new Reader(undefined, new Uint8Array([0, 2, id, 42, 1, 0xaa]), version); const frame = await reader.decode((c) => Frame.decode(c, flags, Timescale.MILLI)); @@ -855,7 +855,7 @@ test("FetchFrame: the first object carries its absolute ids and the rest inherit // every implementation reads it (moq-wg/moq-transport#1861). Read as a delta, its group // could never name the group it follows. test("FetchEndOfRange: absolute ids and nothing after them", async () => { - for (const version of [Version.DRAFT_18, Version.DRAFT_22] as const) { + for (const version of [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22] as const) { const reason = version === Version.DRAFT_18 ? EndOfRange.Unknown : EndOfRange.TimedOut; const { stream, written } = createTestWritableStream(); const writer = new Writer(stream, version); @@ -963,7 +963,7 @@ test("Subscribe draft-22: decodes every legal parameter", async () => { // An omitted SUBSCRIBER_PRIORITY means 128, not the unset 127, so a relay forwards it unchanged. test("Subscribe: an omitted SUBSCRIBER_PRIORITY is 128", async () => { - for (const version of [Version.DRAFT_18, Version.DRAFT_22]) { + for (const version of [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22]) { const msg = await decodeVersioned(framed([...TRACK_HEAD, 0x00]), Subscribe.Subscribe.decode, version); expect(msg.subscriberPriority).toBe(128); } @@ -1060,7 +1060,7 @@ test("TRACK_PROPERTY_FILTER is rejected on SUBSCRIBE and FETCH", async () => { await expect(decodeVersioned(body, Fetch.decode, Version.DRAFT_22)).rejects.toThrow(); }); -for (const version of [Version.DRAFT_18, Version.DRAFT_22]) { +for (const version of [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22]) { for (const kind of [0x20n, 0x21n, 0x9dn, 0x11cn]) { test(`SETUP ${version}: repeated unknown option ${kind}`, async () => { const { stream, written } = createTestWritableStream(); @@ -1081,7 +1081,7 @@ for (const version of [Version.DRAFT_18, Version.DRAFT_22]) { } } -for (const version of [Version.DRAFT_18, Version.DRAFT_22]) { +for (const version of [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22]) { test(`SETUP ${version}: known options cannot repeat`, async () => { for (const bytes of [new Uint8Array([4, 1, 0, 2]), new Uint8Array([7, 1, 97, 0, 1, 98])]) { await expect(SetupOptions.decode(new Reader(undefined, bytes, version))).rejects.toThrow(/duplicate/); diff --git a/js/net/src/ietf/namespace.ts b/js/net/src/ietf/namespace.ts index 23bf26f2fc9..ad80384f99c 100644 --- a/js/net/src/ietf/namespace.ts +++ b/js/net/src/ietf/namespace.ts @@ -119,7 +119,7 @@ async function decodeFields(r: Reader): Promise<{ namespace: Path.Valid; size: n /** Whether a request names an unimplemented session namespace or the forbidden period field. */ export function reserved(namespace: Path.Valid, version: IetfVersion): boolean { - if (version < Version.DRAFT_22) return false; + if (version < Version.DRAFT_20) return false; const first = toTuple(namespace)[0]; return first === "." || first === ".session"; } diff --git a/js/net/src/ietf/parameters.ts b/js/net/src/ietf/parameters.ts index 1e08070f457..2086c0d04ff 100644 --- a/js/net/src/ietf/parameters.ts +++ b/js/net/src/ietf/parameters.ts @@ -67,7 +67,7 @@ type ControlMessage = /** True when this draft's definition of `message` includes `id`. */ function allows(message: ControlMessage, version: IetfVersion, id: bigint): boolean { - const from22 = version >= Version.DRAFT_22; + const from20 = version >= Version.DRAFT_20; const auth = id === MSG_PARAM_AUTHORIZATION_TOKEN; const forward = id === MSG_PARAM_FORWARD; const priority = id === MSG_PARAM_SUBSCRIBER_PRIORITY; @@ -77,10 +77,10 @@ function allows(message: ControlMessage, version: IetfVersion, id: bigint): bool const largest = id === MSG_PARAM_LARGEST_OBJECT; const objectTimeout = id === MSG_PARAM_DELIVERY_TIMEOUT; const subgroupTimeout = id === MSG_PARAM_SUBGROUP_DELIVERY_TIMEOUT; - const range = id >= 0x25n && id <= 0x28n && from22; - const trackRange = id === MSG_PARAM_TRACK_PROPERTY_FILTER && from22; - const fill = id === MSG_PARAM_FILL_PARAMETERS && from22; - const include = id === MSG_PARAM_INCLUDE_PROPERTIES && from22; + const range = id >= 0x25n && id <= 0x28n && from20; + const trackRange = id === MSG_PARAM_TRACK_PROPERTY_FILTER && from20; + const fill = id === MSG_PARAM_FILL_PARAMETERS && from20; + const include = id === MSG_PARAM_INCLUDE_PROPERTIES && from20; const newGroup = id === MSG_PARAM_NEW_GROUP_REQUEST; const epoch = id === MSG_PARAM_EPOCH; @@ -89,7 +89,7 @@ function allows(message: ControlMessage, version: IetfVersion, id: bigint): bool return ( auth || forward || - (from22 && + (from20 && (objectTimeout || id === MSG_PARAM_MAX_CACHE_DURATION || subgroupTimeout || @@ -107,7 +107,7 @@ function allows(message: ControlMessage, version: IetfVersion, id: bigint): bool case "publish-ok": return ( expires || - (!from22 && (forward || priority || filter || order || objectTimeout || subgroupTimeout || newGroup)) + (!from20 && (forward || priority || filter || order || objectTimeout || subgroupTimeout || newGroup)) ); case "subscribe": return ( @@ -149,15 +149,15 @@ function allows(message: ControlMessage, version: IetfVersion, id: bigint): bool return auth || id === MSG_PARAM_HIDDEN; case "publish": return ( - (objectTimeout && from22) || + (objectTimeout && from20) || auth || - (subgroupTimeout && from22) || + (subgroupTimeout && from20) || expires || largest || forward || - (priority && from22) || - (filter && from22) || - (order && from22) + (priority && from20) || + (filter && from20) || + (order && from20) ); case "publish-namespace": return auth || id === MSG_PARAM_HOP_PATH || id === MSG_PARAM_ROUTE_COST || epoch; @@ -166,7 +166,7 @@ function allows(message: ControlMessage, version: IetfVersion, id: bigint): bool auth || id === MSG_PARAM_FILL_TIMEOUT || priority || - (filter && from22) || + (filter && from20) || order || range || include || diff --git a/js/net/src/ietf/publisher.test.ts b/js/net/src/ietf/publisher.test.ts index 3b5524fbe42..3662971e843 100644 --- a/js/net/src/ietf/publisher.test.ts +++ b/js/net/src/ietf/publisher.test.ts @@ -192,7 +192,7 @@ function publisher( }; } -const IETF_VERSIONS = [Version.DRAFT_18, Version.DRAFT_22] as const; +const IETF_VERSIONS = [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22] as const; /** A request stream recording what the publisher writes, with the requester's side under test control. */ function requestStream(version: IetfVersion) { @@ -261,7 +261,7 @@ test("TRACK_STATUS is answered on every draft without subscribing", async () => const { stream, wire } = requestStream(version); // Only draft-22 can carry the opt-out. - await pub.runTrackStatusRequest(trackStatus("room", wanted || version < Version.DRAFT_22), stream); + await pub.runTrackStatusRequest(trackStatus("room", wanted || version < Version.DRAFT_20), stream); expect(subscribed).not.toHaveBeenCalled(); const r = wire(); @@ -271,7 +271,7 @@ test("TRACK_STATUS is answered on every draft without subscribing", async () => expect(ok.largest).toEqual({ groupId: 4n, objectId: 1n }); const expected = - !wanted && version >= Version.DRAFT_22 + !wanted && version >= Version.DRAFT_20 ? {} : { timescale: Timescale.MILLI, @@ -334,7 +334,7 @@ test("TRACK_STATUS outside the grant is refused on every draft", async () => { // Nothing answers a SUBSCRIBE while its broadcast resolves, yet the request stream is still // read: a second GOAWAY then closes the session at once, not once an answer goes out. test("a second GOAWAY on an unanswered SUBSCRIBE closes the session", async () => { - for (const version of [Version.DRAFT_18, Version.DRAFT_22]) { + for (const version of [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22]) { const pair = createMockTransportPair(ALPNS[version]); const session = new NativeSession(pair.server, version, true); const { pub, origin } = publisher(pair.server, { session }); @@ -556,7 +556,7 @@ test("Range Filters over MAX_FILTER_RANGES zero get INVALID_FILTER", async () => }); test("RENDEZVOUS_TIMEOUT has a zero cap with TIMEOUT for a requested wait", async () => { - for (const version of [Version.DRAFT_18, Version.DRAFT_22]) { + for (const version of [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22]) { // A wait applies only to a missing publisher; a missing track on a live one does not exist. for (const [namespace, trackName, live] of [ ["missing", "video", false], @@ -2267,7 +2267,7 @@ test.each([ }); test("subscription completion sends PUBLISH_DONE on every supported draft", async () => { - const versions = [Version.DRAFT_18, Version.DRAFT_22] as const; + const versions = [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22] as const; for (const version of versions) { // A revocation bridged from upstream keeps its meaning: UNAUTHORIZED, not INTERNAL_ERROR. @@ -2354,6 +2354,7 @@ interface ServedFill { /** The subprotocol each draft negotiates, so the mock pair names the version under test. */ const ALPNS: Record = { [Version.DRAFT_18]: ALPN.DRAFT_18, + [Version.DRAFT_20]: ALPN.DRAFT_20, [Version.DRAFT_22]: ALPN.DRAFT_22, }; @@ -3895,7 +3896,7 @@ test("namespace subscription survives requester FIN and stops on STOP_SENDING", }); test("namespace updates move the prefix after acknowledgement", async () => { - for (const version of [Version.DRAFT_18, Version.DRAFT_22]) { + for (const version of [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22]) { const pair = createMockTransportPair(ALPNS[version]); const { pub, origin } = publisher(pair.server, { session: new NativeSession(pair.server, version, false), @@ -3924,7 +3925,7 @@ test("namespace updates move the prefix after acknowledgement", async () => { await RequestOk.decode(client.reader, version); expect(await client.reader.u53()).toBe(SubscribeNamespaceEntry.id); expect((await SubscribeNamespaceEntry.decode(client.reader, version)).suffix).toBe(Path.from("second")); - if (version >= Version.DRAFT_22) { + if (version >= Version.DRAFT_20) { await client.writer.write(Uint8Array.from([0x02, 0, 6, 4, 1, 0x34, 1, 1, 46])); expect(await client.reader.u53()).toBe(RequestError.id); expect((await RequestError.decode(client.reader, version)).errorCode).toBe(0x10); diff --git a/js/net/src/ietf/publisher.ts b/js/net/src/ietf/publisher.ts index fe8eaa09b9a..ec6775779d5 100644 --- a/js/net/src/ietf/publisher.ts +++ b/js/net/src/ietf/publisher.ts @@ -480,7 +480,7 @@ export class Publisher { async #runSubscribe(msg: Subscribe, request: RequestStream) { this.#pinned(msg.epoch); // Draft-22 replaced joining FETCH with fills. - const joinable = !Filter.isDraft22(this.#session.version); + const joinable = !Filter.isDraft20(this.#session.version); if (joinable) this.#setJoin(msg.requestId, "pending"); const key = JSON.stringify([msg.trackNamespace, msg.trackName]); const claimed = this.#session.version === Version.DRAFT_18; @@ -757,7 +757,7 @@ export class Publisher { // group with no gap and no overlap. const edge = liveEdge(track); const fill = - msg.fill && msg.forward && Filter.isDraft22(version) + msg.fill && msg.forward && Filter.isDraft20(version) ? fillRange(msg.fill, msg.filter, edge.largest) : undefined; const requested = subscribeRange(msg, edge, version); @@ -798,7 +798,7 @@ export class Publisher { // Draft-22 replaced joining FETCH with fills. Older drafts save the Largest Object the // subscription starts after, again on every resume, so a joining FETCH ends exactly // where the subscription begins. Saved before the answer names it. - if (!published && !Filter.isDraft22(version)) { + if (!published && !Filter.isDraft20(version)) { this.#setJoin( msg.requestId, msg.filter.kind === "nextObject" @@ -918,7 +918,7 @@ export class Publisher { const snapshot = liveEdge(track); this.#applyPublished(msg, params); const selected = - msg.fill && Filter.isDraft22(version) + msg.fill && Filter.isDraft20(version) ? fillRange(msg.fill, msg.filter, snapshot.largest) : undefined; if (params.subscriptionFilter !== undefined || selected) { @@ -2633,7 +2633,7 @@ export class Publisher { propertiesWanted: defaults.includeProperties ?? true, }); const parameters = new Parameters(); - if (Filter.isDraft22(version)) { + if (Filter.isDraft20(version)) { parameters.subscriberPriority = subscription.subscriberPriority; parameters.groupOrder = subscription.groupOrder === "ascending" ? GroupOrder.Ascending : GroupOrder.Descending; @@ -2690,7 +2690,7 @@ export class Publisher { return; } this.#applyPublished(subscription, params); - let forward = !Filter.isDraft22(version) && params.forward !== false; + let forward = !Filter.isDraft20(version) && params.forward !== false; for (;;) { if (!this.#gate.allows(namespace) || unlisted.peek() !== undefined) { await Message.write( @@ -3076,7 +3076,7 @@ export class Publisher { const groupEnd = BigInt(last.end); const until = fetchSlice(range, last.sequence).until; let endLocation: Location; - if (Filter.isDraft22(version)) { + if (Filter.isDraft20(version)) { // Draft-22's End Location is inclusive. An empty answer still covers its start. const object = until === undefined @@ -3579,7 +3579,7 @@ function liveEdge(track: TrackSubscriber): LiveEdge { * receives. */ function subscribeRange(msg: Subscribe, edge: LiveEdge, version: IetfVersion): ServeRange { - if (!Filter.isDraft22(version) && msg.filter.kind !== "nextObject") { + if (!Filter.isDraft20(version) && msg.filter.kind !== "nextObject") { if (msg.filter.kind !== "unfiltered") { console.warn(`filter not supported before draft-22, ignoring: ${msg.filter.kind}`); } diff --git a/js/net/src/ietf/request_stream.test.ts b/js/net/src/ietf/request_stream.test.ts index c334d0917fb..0dbfefe4f72 100644 --- a/js/net/src/ietf/request_stream.test.ts +++ b/js/net/src/ietf/request_stream.test.ts @@ -39,7 +39,7 @@ const GOAWAY = [0x10, 0, 2, 0, 0]; test("an oversized or truncated request stream message type is a protocol violation", async () => { // Both drafts use leading-ones varints. - for (const version of [Version.DRAFT_18, Version.DRAFT_22]) { + for (const version of [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22]) { const oversized = Varint.encodeLeadingOnes(2n ** 53n); // A two-byte varint prefix with its second byte missing. const truncated = Uint8Array.of(0x80); @@ -52,7 +52,7 @@ test("an oversized or truncated request stream message type is a protocol violat }); test("namespace update framing refuses duplicate prefix parameters", async () => { - for (const version of [Version.DRAFT_18, Version.DRAFT_22]) { + for (const version of [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22]) { const body = [2, 2, 0x34, 1, 1, 97, 0, 1, 1, 98]; const reader = new Reader(undefined, Uint8Array.from([0, body.length, ...body]), version); await expect(namespaceUpdate({ type: 2, reader }, version)).rejects.toBeInstanceOf(ProtocolViolation); @@ -60,7 +60,7 @@ test("namespace update framing refuses duplicate prefix parameters", async () => }); test("a repeated namespace update token is a request refusal", async () => { - for (const version of [Version.DRAFT_18, Version.DRAFT_22]) { + for (const version of [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22]) { const body = [2, 2, 3, 3, 3, 0, 170, 0, 3, 3, 0, 170]; const reader = new Reader(undefined, Uint8Array.from([0, body.length, ...body]), version); expect(await namespaceUpdate({ type: 2, reader }, version)).toEqual({ @@ -70,7 +70,7 @@ test("a repeated namespace update token is a request refusal", async () => { } }); -for (const version of [Version.DRAFT_18, Version.DRAFT_22]) { +for (const version of [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22]) { test(`${versionName(version)} a request nobody reads yet still refuses a second GOAWAY`, async () => { const { request, closes } = requested(version, Uint8Array.of(...GOAWAY, ...GOAWAY)); await request.ended; @@ -109,7 +109,7 @@ for (const version of [Version.DRAFT_18, Version.DRAFT_22]) { }); } -for (const version of [Version.DRAFT_18, Version.DRAFT_22]) { +for (const version of [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22]) { test(`${versionName(version)} keeps GOAWAY state across request response phases`, async () => { // GOAWAY, an empty REQUEST_OK, and another GOAWAY on the same stream. const reader = new Reader(undefined, Uint8Array.of(0x10, 0, 2, 0, 0, 7, 0, 0, 0x10, 0, 2, 0, 0), version); diff --git a/js/net/src/ietf/subscribe.ts b/js/net/src/ietf/subscribe.ts index 6203b77909b..a9946d69197 100644 --- a/js/net/src/ietf/subscribe.ts +++ b/js/net/src/ietf/subscribe.ts @@ -57,7 +57,7 @@ function decodeGroupOrder(value: number): Order { */ export function joinFilter(version: IetfVersion): { filter: Filter.Filter; fill?: Filter.Fill } { const filter: Filter.Filter = { kind: "nextObject" }; - if (!Filter.isDraft22(version)) return { filter }; + if (!Filter.isDraft20(version)) return { filter }; return { filter, fill: { filter: { kind: "relative", groups: 1n }, rangeFilters: false } }; } @@ -156,7 +156,7 @@ export class Subscribe { // FILL_PARAMETERS and INCLUDE_PROPERTIES arrived in draft-22. An older peer reads // either as an unknown parameter, which is a protocol violation, so they are // dropped rather than downgraded. - if (Filter.isDraft22(version)) { + if (Filter.isDraft20(version)) { if (this.fill) { params.fillParameters = Filter.encodeFill(this.fill, version); } @@ -190,7 +190,7 @@ export class Subscribe { // additions. An unknown message parameter is a protocol violation, so // they stay rejected on the drafts that predate them rather than being quietly // tolerated. - const draft22 = Filter.isDraft22(version); + const draft22 = Filter.isDraft20(version); if ((params.fillParameters !== undefined || params.includeProperties !== undefined) && !draft22) { throw new Error("FILL_PARAMETERS and INCLUDE_PROPERTIES need draft-22"); } diff --git a/js/net/src/ietf/subscribe_tracks.test.ts b/js/net/src/ietf/subscribe_tracks.test.ts index 25f75a01e70..7554ee0e327 100644 --- a/js/net/src/ietf/subscribe_tracks.test.ts +++ b/js/net/src/ietf/subscribe_tracks.test.ts @@ -20,7 +20,7 @@ import { Subscribe } from "./subscribe.ts"; import { PublishSkipped, SubscribeTracks } from "./subscribe_tracks.ts"; import { ALPN, type IetfVersion, Version } from "./version.ts"; -const drafts = [Version.DRAFT_18, Version.DRAFT_22]; +const drafts = [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22]; /** A client and server WebTransport, connected to each other. */ type Pair = { client: WebTransport; server: WebTransport }; @@ -118,7 +118,7 @@ function fixture( async function publishOk(stream: Stream, version: IetfVersion) { const parameters = new Parameters(); - if (version < Version.DRAFT_22) parameters.forward = false; + if (version < Version.DRAFT_20) parameters.forward = false; await stream.writer.u53(RequestOk.id); await new RequestOk({ parameters }).encode(stream.writer, version); } diff --git a/js/net/src/ietf/subscriber.test.ts b/js/net/src/ietf/subscriber.test.ts index 88274ac621e..257b59dc47e 100644 --- a/js/net/src/ietf/subscriber.test.ts +++ b/js/net/src/ietf/subscriber.test.ts @@ -1528,7 +1528,7 @@ test("a more specific epochless announcement replaces the consumed source", asyn announced.close(); }); -for (const version of [Version.DRAFT_18, Version.DRAFT_22]) { +for (const version of [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22]) { test(`status zero without the end bit delivers an empty object and continues (${version})`, async () => { const { subscriber, track } = await subscribeTrack({ version }); onTestFinished(() => track.close()); diff --git a/js/net/src/ietf/subscriber.ts b/js/net/src/ietf/subscriber.ts index 02e467391d2..40b8f1dcf70 100644 --- a/js/net/src/ietf/subscriber.ts +++ b/js/net/src/ietf/subscriber.ts @@ -47,7 +47,7 @@ import * as Cluster from "./cluster.ts"; import { ObjectDatagram } from "./datagram.ts"; import { requestReason } from "./error.ts"; import { Fetch, FetchHeader, FetchOk } from "./fetch.ts"; -import { isDraft22 } from "./filter.ts"; +import { isDraft20 } from "./filter.ts"; import { Join } from "./join.ts"; import * as Message from "./message.ts"; import * as Namespace from "./namespace.ts"; @@ -913,7 +913,7 @@ export class Subscriber { // Ends the joining FETCH with the subscription. const joining = new AbortController(); try { - if (subscription.join && !isDraft22(this.#session.version)) { + if (subscription.join && !isDraft20(this.#session.version)) { void this.#runJoiningFetch(subscription, requestId, priority, joining.signal); } @@ -1737,7 +1737,7 @@ export class Subscriber { const { join, track, tail, timescale } = subscription; // A draft-22 fill is one of the subscription's own data streams, which PUBLISH_DONE // counts. A draft-18 joining FETCH is a request of its own; the join holds the end for it. - const read = isDraft22(version) ? tail.open(join.sequence) : undefined; + const read = isDraft20(version) ? tail.open(join.sequence) : undefined; let producer: netGroup.Producer | undefined; // A whole group took the sequence first, or the join gave up: read the rest away. diff --git a/js/net/src/ietf/token.test.ts b/js/net/src/ietf/token.test.ts index 5c8f235349f..c6cacfcc65b 100644 --- a/js/net/src/ietf/token.test.ts +++ b/js/net/src/ietf/token.test.ts @@ -15,7 +15,7 @@ import { } from "./token.ts"; import { type IetfVersion, Version } from "./version.ts"; -const VERSIONS: IetfVersion[] = [Version.DRAFT_18, Version.DRAFT_22]; +const VERSIONS: IetfVersion[] = [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22]; // A kind past one varint byte and a value that is not text, matching the Rust tests. const TOKEN: Token = { kind: 300n, value: new Uint8Array([0x00, 0xff, 0x03, 0x80, 0x6a]) }; diff --git a/js/net/src/ietf/track.ts b/js/net/src/ietf/track.ts index 938c6cf9cdb..537f6ab97fc 100644 --- a/js/net/src/ietf/track.ts +++ b/js/net/src/ietf/track.ts @@ -48,7 +48,7 @@ export class TrackStatusRequest { // Only the opt-out is worth bytes, and a peer before draft-22 would read // INCLUDE_PROPERTIES as unknown, which is a protocol violation. const params = new Parameters(); - if (!this.propertiesWanted && Filter.isDraft22(version)) params.includeProperties = false; + if (!this.propertiesWanted && Filter.isDraft20(version)) params.includeProperties = false; params.epoch = this.epoch; await params.encode(w, version); } diff --git a/js/net/src/ietf/version.ts b/js/net/src/ietf/version.ts index cf527745d57..538e5fa22f1 100644 --- a/js/net/src/ietf/version.ts +++ b/js/net/src/ietf/version.ts @@ -8,6 +8,12 @@ export const Version = { */ DRAFT_18: 0xff000012, + /** + * draft-ietf-moq-transport-20 + * https://www.ietf.org/archive/id/draft-ietf-moq-transport-20.txt + */ + DRAFT_20: 0xff000014, + /** * draft-ietf-moq-transport-22 * https://www.ietf.org/archive/id/draft-ietf-moq-transport-22.txt @@ -20,6 +26,7 @@ export type Version = (typeof Version)[keyof typeof Version]; // ALPN / WebTransport subprotocol identifiers for draft versions. export const ALPN = { DRAFT_18: "moqt-18", + DRAFT_20: "moqt-20", DRAFT_22: "moqt-22", } as const; @@ -27,10 +34,11 @@ export const ALPN = { * IETF protocol versions used by the ietf/ module. * Use this narrower type for version-branched encode/decode to get exhaustive matching. */ -export type IetfVersion = typeof Version.DRAFT_18 | typeof Version.DRAFT_22; +export type IetfVersion = typeof Version.DRAFT_18 | typeof Version.DRAFT_20 | typeof Version.DRAFT_22; const VERSION_NAMES: Record = { [Version.DRAFT_18]: "moq-transport-18", + [Version.DRAFT_20]: "moq-transport-20", [Version.DRAFT_22]: "moq-transport-22", }; diff --git a/quest/m1/README.md b/quest/m1/README.md index aaebf63bfb1..245f8928933 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -147,7 +147,7 @@ removed). - [Smoke token subject](/quest/m1/smoke-token-subject.md) - condition: grant subject ships; then the release smoke test signs with `--subject` - [Moxygen pin bump](/quest/m1/moxygen-pin-bump.md) - waiting on moxygen#264, then the TRACK_STATUS patch is dropped - [A smaller, safer API than release](/quest/m1/api-audit/README.md) - every surface added since release has a consumer or is gone, overlapping operations are collapsed, names mirror across Rust, JS, and the bindings, and every break says how to migrate -- [moq-transport 18 and 22 only](/quest/m1/ietf-drop/README.md) - drafts 14-17 and 19-21 are deleted from Rust, JS, tests, interop lanes, and docs, removing the legacy control-stream adapter and its request limit +- [moq-transport 18, 20, and 22 only](/quest/m1/ietf-drop/README.md) - drafts 14-17, 19, and 21 are deleted from Rust, JS, tests, interop lanes, and docs, removing the legacy control-stream adapter and its request limit - [Our moq-transport publishers refuse SUBSCRIBE_TRACKS](/quest/m1/ietf-tracks-refuse.md) - a peer's listing gets NOT_SUPPORTED, while Rust still lists an IETF peer's tracks upstream for the archive - [A moq-transport request token is one auth per distinct token](/quest/m1/ietf-token-auth.md) - requests naming the same token share one verification and grant, on any request type, ending with the last such request - [moq-transport carries no epoch](/quest/m1/ietf-epoch-cut.md) - Rust and JS moq-transport sessions stop negotiating MoQ Epoch, so every moq-transport hop is epochless; the draft stays diff --git a/quest/m1/ietf-drop/README.md b/quest/m1/ietf-drop/README.md index 0871eaebb99..94ec3270b71 100644 --- a/quest/m1/ietf-drop/README.md +++ b/quest/m1/ietf-drop/README.md @@ -1,11 +1,11 @@ -# [XS] moq-transport 18 and 22 only +# [XS] moq-transport 18, 20, and 22 only ## Goal -`moq-net` and `@moq/net` speak moq-transport drafts 18 and 22 and no -others. Drafts 14 to 17 and 19 to 21 are deleted from the wire code, tests, +`moq-net` and `@moq/net` speak moq-transport drafts 18, 20, and 22 and no +others. Drafts 14 to 17, 19, and 21 are deleted from the wire code, tests, fuzzing, interop lanes, and docs, and our `moq-dev-rs` and `moq-dev-js` -entries in the interop runner registry declare only 18 and 22. +entries in the interop runner registry declare only 18, 20, and 22. Out of scope: moq-lite versions. moq-lite-01/02 still negotiate over `moql` with the CLIENT_SETUP/SERVER_SETUP codec, which stays. @@ -57,9 +57,16 @@ the other breaks before the cut. Drafts 14 to 17 ([moq-dev/moq#6753](https://github.com/moq-dev/moq/pull/6753)) and 19 to 21 ([moq-dev/moq#6754](https://github.com/moq-dev/moq/pull/6754)) are gone. +Decided 2026-10-28 (maintainer): draft 20 came back, so the public relay +dashboard lists more than two moq-transport drafts. It costs only draft-20's +field-count LOCATION_FILTER codec and its SUBSCRIBE_TRACKS parameters; every +other gate is shared with draft 22, whose changes since 20 are editorial +(draft-22 appendix A.1 and A.2). Drafts 19 and 21 stay dropped: 19 splits +most gates between 18 and 22, and 21 differs from 20 only by its ALPN. + This README's remaining work: open a PR on `englishm/moq-interop-runner` narrowing the `moq-dev-rs` and `moq-dev-js` -entries in `implementations.json` to drafts 18 and 22. The maintainer +entries in `implementations.json` to drafts 18, 20, and 22. The maintainer approved posting there on 2026-10-24. ## Related diff --git a/rs/moq-net/src/client.rs b/rs/moq-net/src/client.rs index 02d5afe38ab..625342e9e0a 100644 --- a/rs/moq-net/src/client.rs +++ b/rs/moq-net/src/client.rs @@ -3,8 +3,8 @@ use crate::origin; use crate::time::{Deadlines, Instant}; use crate::transport::poll::Session as _; use crate::{ - ALPN_18, ALPN_22, ALPN_LITE, ALPN_LITE_03, ALPN_LITE_04, ALPN_LITE_05, ALPN_LITE_06, ALPN_LITE_07_WIP, Consume, - Error, NEGOTIATED, Session, Version, Versions, + ALPN_18, ALPN_20, ALPN_22, ALPN_LITE, ALPN_LITE_03, ALPN_LITE_04, ALPN_LITE_05, ALPN_LITE_06, ALPN_LITE_07_WIP, + Consume, Error, NEGOTIATED, Session, Version, Versions, coding::{self, Encode, Stream}, ietf, lite, setup, stats, }; @@ -368,9 +368,10 @@ impl Client { let (publish, subscribe) = self.origins(peer_hop); let supported = match session.protocol() { - Some(alpn @ (ALPN_22 | ALPN_18)) => { + Some(alpn @ (ALPN_22 | ALPN_20 | ALPN_18)) => { let draft = match alpn { ALPN_22 => ietf::Version::Draft22, + ALPN_20 => ietf::Version::Draft20, _ => ietf::Version::Draft18, }; diff --git a/rs/moq-net/src/fuzz.rs b/rs/moq-net/src/fuzz.rs index efe0365e88b..052d2d938ce 100644 --- a/rs/moq-net/src/fuzz.rs +++ b/rs/moq-net/src/fuzz.rs @@ -115,7 +115,7 @@ const LITE_VERSIONS: &[lite::Version] = &[ ]; /// The moq-transport drafts a target decodes at, selected by the input's first byte. -const IETF_VERSIONS: &[ietf::Version] = &[ietf::Version::Draft18, ietf::Version::Draft22]; +const IETF_VERSIONS: &[ietf::Version] = &[ietf::Version::Draft18, ietf::Version::Draft20, ietf::Version::Draft22]; /// How many types [`lite_wire`] dispatches over. const LITE_KINDS: u8 = 30; @@ -229,7 +229,12 @@ fn datagram(data: &[u8], version: lite::Version) -> bool { let mut any = false; for &negotiated in negotiated { for timescale in [Some(crate::Timescale::MILLI), None] { - for ietf in [None, Some(ietf::Version::Draft18), Some(ietf::Version::Draft22)] { + for ietf in [ + None, + Some(ietf::Version::Draft18), + Some(ietf::Version::Draft20), + Some(ietf::Version::Draft22), + ] { for compressed in [false, true] { let framing = lite::Framing { timescale, diff --git a/rs/moq-net/src/ietf/auth.rs b/rs/moq-net/src/ietf/auth.rs index 656b7c1ca09..4453b765160 100644 --- a/rs/moq-net/src/ietf/auth.rs +++ b/rs/moq-net/src/ietf/auth.rs @@ -647,7 +647,7 @@ mod tests { /// Every draft that negotiates the extension round-trips the option. #[test] fn setup_option_round_trips_on_supported_drafts() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let mut params = super::super::Parameters::default(); assert_eq!(from_setup(¶ms), None); into_setup(&mut params); diff --git a/rs/moq-net/src/ietf/datagram.rs b/rs/moq-net/src/ietf/datagram.rs index d614b8d0567..024534d69cc 100644 --- a/rs/moq-net/src/ietf/datagram.rs +++ b/rs/moq-net/src/ietf/datagram.rs @@ -201,7 +201,7 @@ mod tests { Ok(datagram) } - const ALL: [Version; 2] = [Version::Draft18, Version::Draft22]; + const ALL: [Version; 3] = [Version::Draft18, Version::Draft20, Version::Draft22]; fn single(priority: Option) -> ObjectDatagram { ObjectDatagram { diff --git a/rs/moq-net/src/ietf/error.rs b/rs/moq-net/src/ietf/error.rs index 9a7c86e362e..df687722bc2 100644 --- a/rs/moq-net/src/ietf/error.rs +++ b/rs/moq-net/src/ietf/error.rs @@ -265,7 +265,7 @@ pub(crate) mod request { mod tests { use super::*; - const ALL: [Version; 2] = [Version::Draft18, Version::Draft22]; + const ALL: [Version; 3] = [Version::Draft18, Version::Draft20, Version::Draft22]; const KINDS: [Kind; 6] = [ Kind::Subscribe, diff --git a/rs/moq-net/src/ietf/fetch.rs b/rs/moq-net/src/ietf/fetch.rs index 136dd2df9f1..41fc167ab01 100644 --- a/rs/moq-net/src/ietf/fetch.rs +++ b/rs/moq-net/src/ietf/fetch.rs @@ -949,7 +949,7 @@ mod cache_duration_tests { /// subscription still learns its retention window. #[test] fn max_cache_duration_is_read_in_each_drafts_field() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for age in [0u64, 30_000] { let mut payload = vec![0, 0, 0, 0, 4]; Encoder::new(&mut payload, version.into()).varint(age).unwrap(); diff --git a/rs/moq-net/src/ietf/filter.rs b/rs/moq-net/src/ietf/filter.rs index d5079983374..e01a966bfb3 100644 --- a/rs/moq-net/src/ietf/filter.rs +++ b/rs/moq-net/src/ietf/filter.rs @@ -68,12 +68,13 @@ mod filter_type { } impl Filter { - /// Whether this is draft-22 or newer. + /// Whether this is draft-20 or newer. /// - /// Draft-22 replaced the Filter Type tag with a Location Filter Type that names the - /// fields that follow it, and added the parameters that ride alongside it, so this - /// gates them too. - pub(crate) fn is_draft22(version: Version) -> bool { + /// Draft-20 replaced the Filter Type tag with up to four optional varints, where the + /// number present selects the meaning, and added the parameters that ride alongside it. + /// Draft-22 names the meaning with a Location Filter Type instead, but keeps those + /// parameters, so this still gates them. + pub(crate) fn is_draft20(version: Version) -> bool { !matches!(version, Version::Draft18) } @@ -82,6 +83,26 @@ impl Filter { end.checked_sub(start).ok_or(EncodeError::InvalidState) } + /// Encode the draft-20 field list, without the enclosing length prefix. + fn encode_fields(&self, w: &mut Encoder<'_>) -> Result<(), EncodeError> { + match *self { + // Zero fields. The draft defines an open ended absolute {0, 0} as equivalent, so + // that spelling normalizes to this one rather than colliding with NextObject. + Self::Unfiltered => {} + Self::NextObject => { + w.varint(0)?; + w.varint(0)?; + } + Self::Relative(groups) => w.varint(groups)?, + Self::Absolute { + start: Location { group: 0, object: 0 }, + end: None, + } => {} + Self::Absolute { start, end } => Self::encode_absolute(w, start, end)?, + } + Ok(()) + } + /// Encode the start, then as much of the end as is set. fn encode_absolute(w: &mut Encoder<'_>, start: Location, end: Option) -> Result<(), EncodeError> { w.varint(start.group)?; @@ -146,6 +167,43 @@ impl Filter { }) } + /// Decode the draft-20 field list, which the caller has already delimited. + fn decode_fields(r: &mut Decoder<'_>) -> Result { + let mut fields = Vec::with_capacity(4); + while !r.is_empty() { + if fields.len() == 4 { + return Err(DecodeError::TrailingBytes); + } + fields.push(r.varint()?); + } + + Ok(match fields[..] { + [] => Self::Unfiltered, + [groups] => Self::Relative(groups), + // Two zeroes is the Next Object spelling; anything else is an absolute start. + [0, 0] => Self::NextObject, + [group, object] => Self::Absolute { + start: Location { group, object }, + end: None, + }, + [group, object, delta] => Self::Absolute { + start: Location { group, object }, + end: Some(EndLocation { + group: group.checked_add(delta).ok_or(DecodeError::BoundsExceeded)?, + object: None, + }), + }, + [group, object, delta, end_object] => Self::Absolute { + start: Location { group, object }, + end: Some(EndLocation { + group: group.checked_add(delta).ok_or(DecodeError::BoundsExceeded)?, + object: Some(end_object), + }), + }, + _ => unreachable!("capped at 4 fields above"), + }) + } + /// Encode the draft-18 and earlier tag form, without the enclosing length prefix. fn encode_tag(&self, w: &mut Encoder<'_>, version: Version) -> Result<(), EncodeError> { match *self { @@ -215,6 +273,7 @@ impl Param for Filter { let mut inner = Encoder::new(&mut buf, version.into()); match version { Version::Draft18 => self.encode_tag(&mut inner, version)?, + Version::Draft20 => self.encode_fields(&mut inner)?, // Draft-22 drops the Length, since the Location Filter Type says which fields follow. _ => return self.encode_typed(w), } @@ -225,6 +284,8 @@ impl Param for Filter { fn param_decode(r: &mut Decoder<'_>, version: Version) -> Result { match version { Version::Draft18 => {} + // The field count is what carries the meaning, so the value is consumed whole. + Version::Draft20 => return Self::decode_fields(&mut Decoder::new(r.bytes()?, version.into())), _ => return Self::decode_typed(r), } @@ -242,6 +303,7 @@ mod tests { use super::*; const OLD: Version = Version::Draft18; + const FIELDS: Version = Version::Draft20; const TYPED: Version = Version::Draft22; fn round_trip(filter: Filter, version: Version) -> Filter { @@ -265,6 +327,117 @@ mod tests { crate::coding::decode_buf(&mut bytes, version, |r, _| Ok(r.bytes()?.to_vec())).expect("length prefix") } + #[test] + fn draft20_field_counts() { + // The number of fields present is what selects the meaning, so pin the bytes. + assert_eq!(value(Filter::NextObject, FIELDS), vec![0x00, 0x00]); + assert_eq!(value(Filter::Relative(0), FIELDS), vec![0x00]); + assert_eq!(value(Filter::Relative(1), FIELDS), vec![0x01]); + assert_eq!( + value( + Filter::Absolute { + start: Location { group: 7, object: 3 }, + end: None + }, + FIELDS + ), + vec![0x07, 0x03] + ); + // End is a delta from the start group, not an absolute group id. + assert_eq!( + value( + Filter::Absolute { + start: Location { group: 7, object: 3 }, + end: Some(EndLocation { group: 9, object: None }) + }, + FIELDS + ), + vec![0x07, 0x03, 0x02] + ); + } + + /// Draft-17 replaced QUIC's varint with a leading-1-bits one. They agree below 64, so a + /// wrong codec stays invisible until group or object ids grow past that. + #[test] + fn draft20_uses_leading_ones_varints_above_63() { + // 128 is 0x80_80 with leading ones, and 0x40_80 with the QUIC form. + assert_eq!(value(Filter::Relative(128), FIELDS), vec![0x80, 0x80]); + assert_eq!(round_trip(Filter::Relative(128), FIELDS), Filter::Relative(128)); + + let wide = Filter::Absolute { + start: Location { group: 300, object: 64 }, + end: None, + }; + assert_eq!(round_trip(wide, FIELDS), wide); + } + + #[test] + fn draft20_round_trips() { + for filter in [ + Filter::Unfiltered, + Filter::NextObject, + Filter::Relative(0), + Filter::Relative(5), + Filter::Absolute { + start: Location { group: 12, object: 0 }, + end: None, + }, + Filter::Absolute { + start: Location { group: 12, object: 4 }, + end: Some(EndLocation { + group: 20, + object: None, + }), + }, + ] { + assert_eq!(round_trip(filter, FIELDS), filter, "{filter:?}"); + } + } + + /// Absolute {0, 0} open ended is defined as equivalent to unfiltered, so it must not + /// collide with the two-zero-field spelling of NextObject. + #[test] + fn draft20_absolute_origin_is_unfiltered() { + let origin = Filter::Absolute { + start: Location::default(), + end: None, + }; + assert!(value(origin, FIELDS).is_empty()); + assert_eq!(round_trip(origin, FIELDS), Filter::Unfiltered); + assert_ne!(value(origin, FIELDS), value(Filter::NextObject, FIELDS)); + } + + /// The fourth field bounds the last object in the end group. Dropping it on decode + /// would let a publisher deliver past the Location the subscriber asked for. + #[test] + fn draft20_keeps_the_end_object() { + let bounded = Filter::Absolute { + start: Location { group: 7, object: 3 }, + end: Some(EndLocation { + group: 9, + object: Some(4), + }), + }; + assert_eq!(value(bounded, FIELDS), vec![0x07, 0x03, 0x02, 0x04]); + assert_eq!(round_trip(bounded, FIELDS), bounded); + + // Three fields leave the end group whole, which is a different filter. + let whole = Filter::Absolute { + start: Location { group: 7, object: 3 }, + end: Some(EndLocation { group: 9, object: None }), + }; + assert_eq!(value(whole, FIELDS), vec![0x07, 0x03, 0x02]); + assert_ne!(round_trip(bounded, FIELDS), whole); + } + + #[test] + fn draft20_rejects_too_many_fields() { + let mut buf = Vec::new(); + Encoder::new(&mut buf, FIELDS.into()).bytes(&[0u8; 5]).unwrap(); + let mut bytes = bytes::Bytes::from(buf); + assert!(crate::coding::decode_buf(&mut bytes, FIELDS, Filter::param_decode).is_err()); + } + #[test] fn draft18_uses_tags() { assert_eq!(value(Filter::NextObject, OLD), vec![tag::LARGEST_OBJECT as u8]); @@ -325,7 +498,7 @@ mod tests { start: Location { group: 9, object: 0 }, end: Some(EndLocation { group: 4, object: None }), }; - for version in [OLD, TYPED] { + for version in [OLD, FIELDS, TYPED] { let mut buf = Vec::new(); assert!( backwards @@ -583,7 +756,7 @@ mod fill_tests { #[test] fn fill_rejects_invalid_group_order() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let fill = Fill { group_order: Some(super::super::GroupOrder::Any), filter: None, @@ -643,7 +816,12 @@ mod fill_tests { #[test] fn round_trips() { - let version = NEW; + for version in [Version::Draft20, NEW] { + round_trips_on(version); + } + } + + fn round_trips_on(version: Version) { for filter in [ // An omitted filter (inherit the subscription's) and an explicit zero-length // one (the whole track) are distinct spellings and must stay distinct. @@ -679,6 +857,22 @@ mod fill_tests { assert_eq!(value(Filter::Relative(1), NEW), vec![0x01, 0x21, 0x01, 0x01]); } + /// Draft-20's nested LOCATION_FILTER is a Length and its field list. + #[test] + fn draft20_nested_filter_counts_its_fields() { + let range = Filter::Absolute { + start: Location { group: 128, object: 0 }, + end: Some(EndLocation { + group: 130, + object: None, + }), + }; + let version = Version::Draft20; + assert_eq!(value(Filter::Relative(1), version), vec![0x01, 0x21, 0x01, 0x01]); + assert_eq!(value(range, version), vec![0x01, 0x21, 0x04, 0x80, 0x80, 0x00, 0x02]); + assert_eq!(value(Filter::Unfiltered, version), vec![0x01, 0x21, 0x00]); + } + /// The nested LOCATION_FILTER carries its type instead of a Length, and the /// whole-track form the spec calls zero-length is type 0x00. #[test] diff --git a/rs/moq-net/src/ietf/group.rs b/rs/moq-net/src/ietf/group.rs index b36e7b17a4a..95013dbf0d9 100644 --- a/rs/moq-net/src/ietf/group.rs +++ b/rs/moq-net/src/ietf/group.rs @@ -538,7 +538,7 @@ mod tests { /// to survive decode rather than being stripped with the bit. #[test] fn first_object_round_trips() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for first_object in [true, false] { let flags = GroupFlags { first_object, diff --git a/rs/moq-net/src/ietf/object.rs b/rs/moq-net/src/ietf/object.rs index 7db2e973ab0..e16164882de 100644 --- a/rs/moq-net/src/ietf/object.rs +++ b/rs/moq-net/src/ietf/object.rs @@ -419,7 +419,7 @@ mod tests { #[test] fn key_six_is_opaque_on_every_draft() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for bytes in [ Bytes::from_static(&[0x06, 42]), Bytes::from_static(&[0x0b, 2, 0x06, 42]), @@ -532,7 +532,7 @@ mod tests { /// in the units the egress declares, not the ones it arrived in. #[test] fn mutable_timestamps_follow_the_egress_units() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let bytes = Bytes::from_static(&[0x10, 42, 0x20, 7]); let decoded = read(&bytes, version, Some(Timescale::MILLI)).unwrap(); let written = write( @@ -816,7 +816,7 @@ mod compression_tests { } #[test] fn sizes_are_known_and_unknown_properties_survive() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let unknown = property(0x8800, 7); let wire = compression(serialize([&unknown], version).unwrap(), version, Some(123)).unwrap(); let decoded = read(&wire.into(), version, None).unwrap(); @@ -829,7 +829,7 @@ mod compression_tests { } #[test] fn a_status_cannot_declare_an_inflated_size() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let size = property(super::super::flate::INFLATED, 0); for value in [ size.clone(), @@ -849,7 +849,7 @@ mod compression_tests { #[test] fn sealed_sizes_are_forwarded_or_refused_without_rewriting() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let sealed = Property { id: 0x0b, value: Value::Bytes( diff --git a/rs/moq-net/src/ietf/parameters.rs b/rs/moq-net/src/ietf/parameters.rs index e84544c4739..46c64e911e8 100644 --- a/rs/moq-net/src/ietf/parameters.rs +++ b/rs/moq-net/src/ietf/parameters.rs @@ -450,7 +450,7 @@ mod tests { #[test] fn setup_allows_repeated_unknown_options() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for kind in [0x20, 0x21, 0x9d, 0x11c] { let mut buf = Vec::new(); let mut w = Encoder::new(&mut buf, version.into()); @@ -472,7 +472,7 @@ mod tests { #[test] fn setup_rejects_repeated_known_options() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for bytes in [&[4, 1, 0, 2][..], &[7, 1, b'a', 0, 1, b'b'][..]] { assert!(matches!( Parameters::decode_slice(bytes, version), @@ -484,14 +484,14 @@ mod tests { #[test] fn setup_repeated_unknown_options_still_require_complete_values() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { assert!(Parameters::decode_slice(&[0x21, 1, b'a', 0, 2, b'b'], version).is_err()); } } #[test] fn group_order_parameter_rejects_values_outside_one_and_two() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for value in [0u8, 3, 255] { let bytes = [value]; let mut r = Decoder::new(&bytes, version.into()); diff --git a/rs/moq-net/src/ietf/properties.rs b/rs/moq-net/src/ietf/properties.rs index b0f3cfe22c2..c0f3ca51404 100644 --- a/rs/moq-net/src/ietf/properties.rs +++ b/rs/moq-net/src/ietf/properties.rs @@ -490,7 +490,7 @@ mod tests { #[test] fn publisher_priority_is_bounded_to_a_byte() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let mut buf = Vec::new(); Encoder::new(&mut buf, version.into()).varint(0x0eu64).unwrap(); Encoder::new(&mut buf, version.into()).varint(256u64).unwrap(); diff --git a/rs/moq-net/src/ietf/publish.rs b/rs/moq-net/src/ietf/publish.rs index c63e29efb13..b5669f30158 100644 --- a/rs/moq-net/src/ietf/publish.rs +++ b/rs/moq-net/src/ietf/publish.rs @@ -249,13 +249,13 @@ impl<'a> Message<'a> for Publish<'a> { // PROTOCOL_VIOLATION), and from draft-22 one of the subscription's parameters, which // moved here. The publisher's preference is a DEFAULT_PUBLISHER_GROUP_ORDER track // property instead. - let draft22 = Filter::is_draft22(version); + let draft20 = Filter::is_draft20(version); encode_params!(w, version, 0x09 => self.largest_location, 0x10 => self.forward, - 0x20 => self.subscriber_priority.filter(|_| draft22), - 0x21 => self.filter.filter(|_| draft22), - 0x22 => self.group_order.filter(|_| draft22), + 0x20 => self.subscriber_priority.filter(|_| draft20), + 0x21 => self.filter.filter(|_| draft20), + 0x22 => self.group_order.filter(|_| draft20), ); // Track Properties are the final field, so nothing may follow. @@ -278,15 +278,15 @@ impl<'a> Message<'a> for Publish<'a> { // session instead of letting the request reach NOT_SUPPORTED. The timeouts are // dropped. decode_params!(r, version, - 0x02 => _object_delivery_timeout: Option where Filter::is_draft22(version), + 0x02 => _object_delivery_timeout: Option where Filter::is_draft20(version), 0x03 => authorization_token: Vec, - 0x06 => _subgroup_delivery_timeout: Option where Filter::is_draft22(version), + 0x06 => _subgroup_delivery_timeout: Option where Filter::is_draft20(version), 0x08 => _expires: Option, 0x09 => largest_location: Option, 0x10 => forward: Option, - 0x20 => subscriber_priority: Option where Filter::is_draft22(version), - 0x21 => filter: Option where Filter::is_draft22(version), - 0x22 => group_order: Option where Filter::is_draft22(version), + 0x20 => subscriber_priority: Option where Filter::is_draft20(version), + 0x21 => filter: Option where Filter::is_draft20(version), + 0x22 => group_order: Option where Filter::is_draft20(version), ); let properties = Properties::decode(r, version)?; // Last, so a malformed field closes the session before a token refusal. @@ -327,7 +327,7 @@ impl<'a> Message<'a> for PublishOk { match version { // Draft-22 moved the subscription parameters out of PUBLISH_OK; they belong to // PUBLISH and REQUEST_UPDATE now, so a PUBLISH_OK carries none of them. - _ if Filter::is_draft22(version) => encode_params!(w, version,), + _ if Filter::is_draft20(version) => encode_params!(w, version,), _ => { // GROUP_ORDER left PUBLISH_OK in draft-22. Sending it there is a parameter // on the wrong message, which closes the session. @@ -354,12 +354,12 @@ impl<'a> Message<'a> for PublishOk { // moved the subscription parameters off PUBLISH_OK, GROUP_ORDER // included. decode_params!(r, version, - 0x02 => _delivery_timeout: Option where !Filter::is_draft22(version), + 0x02 => _delivery_timeout: Option where !Filter::is_draft20(version), 0x06 => _subgroup_delivery_timeout: Option where matches!(version, Version::Draft18), 0x08 => _expires: Option, - 0x10 => forward: Option where !Filter::is_draft22(version), - 0x20 => subscriber_priority: Option where !Filter::is_draft22(version), - 0x21 => filter: Option where !Filter::is_draft22(version), + 0x10 => forward: Option where !Filter::is_draft20(version), + 0x20 => subscriber_priority: Option where !Filter::is_draft20(version), + 0x21 => filter: Option where !Filter::is_draft20(version), 0x22 => group_order: Option where matches!(version, Version::Draft18), 0x32 => new_group: Option where matches!(version, Version::Draft18), ); @@ -507,7 +507,7 @@ mod tests { reason_phrase: "".into(), }; - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { assert!(done(0x2).end(version).is_ok(), "{version:?}"); assert!( matches!(done(0x1).end(version), Err(crate::Error::Unauthorized)), @@ -558,7 +558,7 @@ mod tests { #[test] fn publish_priority_property_bytes_on_every_draft() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let mut msg = Publish { request_id: RequestId(1), track_namespace: Path::from_static("ns"), diff --git a/rs/moq-net/src/ietf/publish_namespace.rs b/rs/moq-net/src/ietf/publish_namespace.rs index 8dfa0ade274..369a08bbe46 100644 --- a/rs/moq-net/src/ietf/publish_namespace.rs +++ b/rs/moq-net/src/ietf/publish_namespace.rs @@ -310,7 +310,7 @@ mod tests { assert_eq!(msg.hops, None, "an unchanged path is omitted"); assert_eq!(msg.cost, Some(0), "a cost of 0 is sent explicitly"); - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let encoded = encode_message(&msg, version); let decoded: PublishNamespaceUpdate = decode_message(&encoded, version).unwrap(); assert_eq!(decoded, msg, "{version}"); diff --git a/rs/moq-net/src/ietf/publisher.rs b/rs/moq-net/src/ietf/publisher.rs index ac0a14a8ca1..7aa08c017d8 100644 --- a/rs/moq-net/src/ietf/publisher.rs +++ b/rs/moq-net/src/ietf/publisher.rs @@ -1227,7 +1227,7 @@ impl Publisher { gate: crate::auth::Gate, ) -> impl std::future::Future> { // Register during dispatch, before either request task can be polled. - let join = (!Filter::is_draft22(self.version)).then(|| self.register_join(msg.request_id)); + let join = (!Filter::is_draft20(self.version)).then(|| self.register_join(msg.request_id)); async move { let _join = join; if let Some(error) = super::namespace::refusal(&msg.track_namespace, self.version) { @@ -1428,7 +1428,7 @@ impl Publisher { // subscription's cursor. let fill = msg .fill - .filter(|_| msg.forward && Filter::is_draft22(self.version)) + .filter(|_| msg.forward && Filter::is_draft20(self.version)) .map(|fill| (fill_range(fill, msg.filter, edge.largest), cache, timescale)); // Buffered whole before its first await, so however the subscription is @@ -1969,7 +1969,7 @@ impl Publisher { let mut range = subscribe_range(msg.filter, edge, self.version); let fill = msg .fill - .filter(|_| msg.forward && Filter::is_draft22(self.version)) + .filter(|_| msg.forward && Filter::is_draft20(self.version)) .map(|fill| fill_range(fill, msg.filter, edge.largest)); if let Some(next) = range.fill_tail(fill, edge) { range.start = Some(next); @@ -2145,7 +2145,7 @@ impl Publisher { Some(err) => Some(("REQUEST_UPDATE parameters not supported", err)), // A SUBSCRIBE serves the range it asked for. A subscription we initiated with // PUBLISH decodes those parameters itself. - None if update.fill.is_some() && !Filter::is_draft22(self.version) => { + None if update.fill.is_some() && !Filter::is_draft20(self.version) => { Some(("REQUEST_UPDATE parameters not supported", Error::Unsupported)) } None if update.authorization_token.is_some() @@ -2947,7 +2947,7 @@ impl Publisher { Ok(properties) => properties, Err(err) => return self.reject_fetch(stream, &err, &err.to_string()).await, }; - let draft22 = Filter::is_draft22(self.version); + let draft20 = Filter::is_draft20(self.version); // Only a finished track's final object ends it, never a live track's Largest Object. let end_of_track = !joined && group.complete && track.final_sequence() == group.sequence.checked_add(1); @@ -2960,7 +2960,7 @@ impl Publisher { .await; } end - } else if draft22 { + } else if draft20 { // Draft-22's End Location is inclusive. An empty answer still covers its start. let object = match range.until(group.sequence) { // The track's last object as this draft writes it, without a status object. @@ -4519,7 +4519,7 @@ impl TrackServe { // Unfiltered on an update widens back to zero. A fresh live join here // would discard history before an empty relay can request its fill. self.requested = match filter { - Filter::Unfiltered if Filter::is_draft22(self.version) => ServeRange { + Filter::Unfiltered if Filter::is_draft20(self.version) => ServeRange { start: Some(Location { group: 0, object: 0 }), end: None, }, @@ -5842,7 +5842,7 @@ mod group_priority_test { #[moq_clock::test] async fn exact_end_of_track_survives_the_final_group_fin() { use crate::lite::test_transport::Sent; - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for finished in [false, true] { let log = crate::lite::test_transport::Log::default(); let mut track = track::Producer::new( @@ -6846,7 +6846,7 @@ mod serve_tests { #[moq_clock::test] async fn a_subscription_keeps_its_goaway_count_until_the_final_marker() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let h = serve(version); let session = ScriptedSession::new(vec![0x10, 0, 2, 0, 0]); let mut stream = Stream::open(&mut crate::driver::Transport::new(session.clone()), version) @@ -6968,7 +6968,7 @@ mod serve_tests { #[moq_clock::test] async fn requester_fin_is_version_gated_for_subscriptions() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let h = serve(version); let session = ScriptedSession::per_stream_eof(vec![vec![]]); let mut stream = Stream::open(&mut crate::driver::Transport::new(session.clone()), version) @@ -7013,7 +7013,7 @@ mod serve_tests { /// A reset request stream still cancels the subscription on every draft. #[moq_clock::test] async fn requester_reset_cancels_subscriptions() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let h = serve(version); let session = ScriptedSession::per_stream_reset(vec![vec![]]); let mut stream = Stream::open(&mut crate::driver::Transport::new(session.clone()), version) @@ -7043,7 +7043,7 @@ mod serve_tests { /// when a dispatched task is cancelled or its message is refused. #[moq_clock::test] async fn drain_counts_dispatched_subscribe_and_fetch() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let h = serve(version); let mut subscribe_body = Vec::new(); subscribe(Filter::NextObject, None) @@ -7054,9 +7054,9 @@ mod serve_tests { request_id: FETCH_ID, subscriber_priority: 128, group_order: GroupOrder::Ascending, - // Draft-22 dropped the Fetch Type tag, leaving only the filtered form. + // Draft-20 dropped the Fetch Type tag, leaving only the filtered form. fetch_type: match version { - Version::Draft22 => FetchType::Filtered { + Version::Draft20 | Version::Draft22 => FetchType::Filtered { namespace: crate::Path::from_static("missing"), track: "video".into(), filter: Filter::Unfiltered, @@ -8150,7 +8150,7 @@ mod serve_tests { #[moq_clock::test] async fn subscription_track_property_filter_closes_the_session() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let h = serve(version); let session = ScriptedSession::new(vec![0x02, 0, 6, 2, 1, 0x29, 2, 0, 0]); let mut stream = Stream::open(&mut crate::driver::Transport::new(session.clone()), version) @@ -8188,7 +8188,7 @@ mod serve_tests { /// A source track failing to decode ends only the subscriptions it feeds, not the requester's session. #[moq_clock::test] async fn source_decode_failure_keeps_the_session() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let h = serve(version); let session = ScriptedSession::new(Vec::new()); let mut stream = Stream::open(&mut crate::driver::Transport::new(session.clone()), version) @@ -8221,7 +8221,7 @@ mod serve_tests { #[moq_clock::test] async fn namespace_updates_do_not_postpone_an_auth_withdrawal() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let h = serve(version); settle().await; let session = ScriptedSession::new(Vec::new()); @@ -8299,7 +8299,7 @@ mod serve_tests { #[moq_clock::test] async fn namespace_updates_move_the_prefix_after_acknowledgement() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let h = serve(version); let _old = h ._origin @@ -8359,7 +8359,7 @@ mod serve_tests { #[moq_clock::test] async fn namespace_requester_fin_is_version_gated() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let h = serve(version); moq_clock::sim::yield_now().await; let session = ScriptedSession::per_stream_eof(vec![vec![]]); @@ -8439,7 +8439,7 @@ mod serve_tests { /// origin's own, which is what carries a refusal the registry has no value for. #[moq_clock::test] async fn a_missing_broadcast_is_refused_with_the_draft_s_code() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let error_code = 0x10; let h = serve(version); @@ -8654,7 +8654,7 @@ mod serve_tests { } } - const ALL_VERSIONS: [Version; 2] = [Version::Draft18, Version::Draft22]; + const ALL_VERSIONS: [Version; 3] = [Version::Draft18, Version::Draft20, Version::Draft22]; fn track_status(namespace: &str, wanted: bool, version: Version) -> Vec { let msg = ietf::TrackStatus { @@ -8708,7 +8708,7 @@ mod serve_tests { let expected = match version { // Only draft-22 can carry the opt-out. - _ if !wanted && Filter::is_draft22(version) => ietf::Properties::default(), + _ if !wanted && Filter::is_draft20(version) => ietf::Properties::default(), _ => track_properties(&track::Info::timed(), true, version, true).unwrap(), }; assert_eq!( @@ -8992,7 +8992,7 @@ mod serve_tests { #[moq_clock::test] async fn range_filters_over_the_default_limit_get_invalid_filter() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let h = serve(version); for fetch in [false, true] { let stream = Stream::open(&mut crate::driver::Transport::new(h.session.clone()), version) @@ -9008,7 +9008,7 @@ mod serve_tests { request_id: RequestId(REQUEST_ID), subscriber_priority: 128, group_order: GroupOrder::Descending, - fetch_type: if Filter::is_draft22(version) { + fetch_type: if Filter::is_draft20(version) { FetchType::Filtered { namespace: crate::Path::from_static("room"), track: "video".into(), @@ -9047,7 +9047,7 @@ mod serve_tests { #[moq_clock::test] async fn rendezvous_wait_is_capped_at_zero_but_answers_timeout() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { // A wait applies only to a missing publisher; a missing track on a live one does not exist. for (namespace, track, publisher) in [("missing", "video", false), ("room", "audio", true)] { for wait in [None, Some(0), Some(7)] { @@ -10332,12 +10332,12 @@ mod serve_tests { } /// Every draft, each carrying a standalone FETCH or draft-22's filtered one. - const FETCH_DRAFTS: [Version; 2] = [Version::Draft18, Version::Draft22]; + const FETCH_DRAFTS: [Version; 3] = [Version::Draft18, Version::Draft20, Version::Draft22]; /// A bounded FETCH_OK's End Location: one past `last` before draft 22, /// and the object itself from then on. Whole-group answers use Object 0 before draft 22. fn end_location(version: Version, group: u64, last: u64) -> Location { - let object = match Filter::is_draft22(version) { + let object = match Filter::is_draft20(version) { true => last, false => last + 1, }; @@ -10413,7 +10413,7 @@ mod serve_tests { fn fetch_range(version: Version, track: &'static str, start: Location, end: Location) -> FetchType<'static> { let namespace = crate::Path::from_static("room"); let track = track.into(); - match Filter::is_draft22(version) { + match Filter::is_draft20(version) { true => FetchType::Filtered { namespace, track, @@ -10538,7 +10538,7 @@ mod serve_tests { ) .await; let (ok, objects) = fetch_answer(buf, version); - let end = match Filter::is_draft22(version) { + let end = match Filter::is_draft20(version) { true => Location { group: 2, object: 1 }, false => Location { group: 2, object: 0 }, }; @@ -10564,7 +10564,7 @@ mod serve_tests { for version in FETCH_DRAFTS { // Only draft-22's FETCH can carry the opt-out. - let opt_out = Filter::is_draft22(version).then_some(false); + let opt_out = Filter::is_draft20(version).then_some(false); for wanted in [Some(true), opt_out].into_iter().flatten() { let h = serve(version); let track = h._broadcast.create_track("timed", info.clone()).unwrap(); @@ -10822,7 +10822,7 @@ mod serve_tests { .await; let (ok, objects) = fetch_answer(buf, version); assert_eq!(objects, Vec::new(), "{version} end={end}"); - if Filter::is_draft22(version) { + if Filter::is_draft20(version) { assert_eq!( ok.end_location, Location { @@ -11049,7 +11049,7 @@ mod serve_tests { ) .await; let (ok, objects) = fetch_answer(buf, version); - let end = match Filter::is_draft22(version) { + let end = match Filter::is_draft20(version) { true => end_location(version, 4, 1), false => Location { group: 4, object: 0 }, }; @@ -11193,7 +11193,7 @@ mod serve_tests { let (ok, objects) = fetch_answer(buf, version); assert_eq!( ok.end_location, - if Filter::is_draft22(version) { + if Filter::is_draft20(version) { Location { group: 4, object: 1 } } else { Location { group: 4, object: 0 } @@ -12400,7 +12400,7 @@ mod serve_tests { /// subscription asked for. #[moq_clock::test] async fn subscribe_ok_announces_the_default_order() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for requested in [GroupOrder::Ascending, GroupOrder::Descending, GroupOrder::Any] { let mut h = serve(version); let mut msg = subscribe(Filter::NextObject, None); @@ -14698,7 +14698,7 @@ mod tests { /// plus STOP_SENDING. A FIN there is a protocol violation some peers close on. #[moq_clock::test] async fn publish_namespace_withdraws_by_reset() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let origin = crate::origin::Config::new(crate::Hop::new(1).unwrap()).produce(); let local = origin.announce("local-cam", crate::origin::Route::default()).unwrap(); settle().await; @@ -14947,7 +14947,7 @@ mod tests { #[moq_clock::test] async fn hidden_discovery_obeys_peer_setup_and_requested_prefix() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for declared in [false, true] { for solicit in [Some(false), Some(true)] { for scoped in [false, true] { @@ -16498,7 +16498,7 @@ mod tests { /// on a request we already refused. Finishing first makes the drop-time reset a no-op. #[moq_clock::test] async fn missing_broadcast_is_refused_without_resetting_the_stream() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let (writes, resets) = subscribe_missing(version).await; assert!(!writes.is_empty(), "{version}: nothing was sent"); @@ -16538,7 +16538,7 @@ mod tests { ] }; - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for (label, fetch_type) in refused() { let (writes, resets) = fetch_refused(version, fetch_type).await; @@ -16758,7 +16758,7 @@ struct GroupSlice { /// Next Object is honored on every draft so a joining FETCH owns the cached prefix. /// Other draft-18 filters retain their existing serving behavior. fn subscribe_range(filter: Filter, edge: LiveEdge, version: Version) -> ServeRange { - if !Filter::is_draft22(version) && filter != Filter::NextObject { + if !Filter::is_draft20(version) && filter != Filter::NextObject { if !matches!(filter, Filter::NextObject | Filter::Unfiltered) { tracing::warn!(?filter, "filter not supported before draft-22, ignoring"); } @@ -17425,7 +17425,7 @@ mod compression_tests { use super::*; #[test] fn sealed_compression_refuses_incompatible_egress() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let mut sealed = Vec::new(); let mut encoder = Encoder::new(&mut sealed, version.into()); encoder.varint(super::super::flate::COMPRESSION).unwrap(); diff --git a/rs/moq-net/src/ietf/publisher/tracks.rs b/rs/moq-net/src/ietf/publisher/tracks.rs index 16e44079959..0c261c6bff4 100644 --- a/rs/moq-net/src/ietf/publisher/tracks.rs +++ b/rs/moq-net/src/ietf/publisher/tracks.rs @@ -878,7 +878,7 @@ impl Publisher { let request_id = self.control.next_request_id(); // A joining FETCH needs the subscription forwarding. - let join = (!Filter::is_draft22(self.version)).then(|| self.register_join(request_id)); + let join = (!Filter::is_draft20(self.version)).then(|| self.register_join(request_id)); self.pause_join(join.as_ref()); tracing::debug!(id = %request_id, broadcast = %absolute, track = %name, "publish started"); @@ -966,7 +966,7 @@ impl Publisher { refused = Some(Served::UpdateFailed(Error::Unsupported)); } new_group = ok.new_group.or(params.new_group.filter(|_| dynamic)); - (ok.forward && !Filter::is_draft22(self.version)).then(|| Resume { + (ok.forward && !Filter::is_draft20(self.version)).then(|| Resume { fill: None, new_group: new_group.take(), answer: false, @@ -1261,7 +1261,7 @@ impl Publisher { } let fill = how .fill - .filter(|_| Filter::is_draft22(self.version)) + .filter(|_| Filter::is_draft20(self.version)) .map(|fill| fill_range(fill, params.filter, edge.largest)); if how.answer && self.write_request_ok(&mut stream.writer, edge.largest).await.is_err() { @@ -1337,7 +1337,7 @@ mod tests { const TIMEOUT: Duration = Duration::from_secs(10); - const DRAFTS: [Version; 2] = [Version::Draft18, Version::Draft22]; + const DRAFTS: [Version; 3] = [Version::Draft18, Version::Draft20, Version::Draft22]; /// A publisher whose origin holds broadcast `room/cam` listing `video` and `audio`, and /// the peer's end of its session. @@ -1870,7 +1870,7 @@ mod tests { /// are listed. #[moq_clock::test] async fn a_forwarding_listing_reads_only_as_skips_go_out() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for catalog in CATALOGS { let h = harness(version); let _extra: Vec<_> = (h.tracks.len()..catalog) @@ -2089,7 +2089,7 @@ mod tests { assert_eq!(next(&mut request).await.0, ietf::RequestOk::ID, "{version}"); let refused = ietf::SubscribeUpdate { filter: None, - forward: Filter::is_draft22(version).then_some(false), + forward: Filter::is_draft20(version).then_some(false), ..update(2, false) }; send(&mut request, &refused).await; @@ -2242,7 +2242,7 @@ mod tests { /// while forwarding as while paused. #[moq_clock::test] async fn a_pausing_new_group_is_refused() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let mut h = harness(version); let _live = h .broadcast @@ -2273,7 +2273,7 @@ mod tests { /// An update taken while forwarding outlives a pause: the next resume keeps it. #[moq_clock::test] async fn a_forwarding_update_outlives_a_pause() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let mut h = harness(version); let video = h.tracks.remove("video").unwrap(); let mut request = h.request(&listing(false)).await; @@ -2346,7 +2346,7 @@ mod tests { } } - /// From draft-22 each PUBLISH states the listing's subscription parameters, which the + /// From draft-20 each PUBLISH states the listing's subscription parameters, which the /// subscriber otherwise takes as the defaults; earlier drafts carry them on PUBLISH_OK. /// Draft-22 sends none of them on SUBSCRIBE_TRACKS. #[moq_clock::test] @@ -2370,7 +2370,7 @@ mod tests { assert_eq!(stream.reader.varint().await.unwrap(), ietf::Publish::ID); let body: ietf::Body = stream.reader.decode().await.unwrap(); let publish: ietf::Publish = body.message(version).unwrap(); - let stated = Filter::is_draft22(version); + let stated = Filter::is_draft20(version); assert_eq!(publish.subscriber_priority, stated.then_some(7), "{version}"); assert_eq!( publish.group_order, @@ -2385,7 +2385,7 @@ mod tests { /// than this stack's unset 127. #[moq_clock::test] async fn a_listing_without_a_priority_states_the_default() { - for version in DRAFTS.into_iter().filter(|version| Filter::is_draft22(*version)) { + for version in DRAFTS.into_iter().filter(|version| Filter::is_draft20(*version)) { let mut h = harness(version); let mut request = h.request(&listing(false)).await; assert_eq!(next(&mut request).await.0, ietf::RequestOk::ID, "{version}"); @@ -2402,7 +2402,7 @@ mod tests { /// has not ended, so neither does the PUBLISH cleanly. #[moq_clock::test] async fn an_unlisted_forwarding_publish_ends() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let mut h = harness(version); let video = h.tracks.remove("video").unwrap(); let mut request = h.request(&listing(false)).await; @@ -2451,7 +2451,7 @@ mod tests { /// withholds the credit its REQUEST_ERROR needs. #[moq_clock::test] async fn a_closing_listing_still_unlists() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let config = memory::Config { stream_buffer: 32, ..Default::default() @@ -2485,7 +2485,7 @@ mod tests { /// its prefix. #[moq_clock::test] async fn a_listing_waits_for_the_setup_answer() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let mut h = harness(version); let auth = crate::auth::Link::new(true); let _cred = auth.present(bytes::Bytes::from_static(b"cred"), true).unwrap(); @@ -2535,7 +2535,7 @@ mod tests { subscribe: crate::Patterns::new(), expires: None, }; - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let mut h = harness(version); let auth = crate::auth::Link::new(false); auth.handle().authorize(¬hing()); diff --git a/rs/moq-net/src/ietf/request.rs b/rs/moq-net/src/ietf/request.rs index f1a640a663d..d31ea854b01 100644 --- a/rs/moq-net/src/ietf/request.rs +++ b/rs/moq-net/src/ietf/request.rs @@ -128,7 +128,7 @@ mod tests { /// carries LARGEST_OBJECT; neither is rejected. #[test] fn test_request_ok_ignores_largest_object() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for bytes in [&[0x01, 0x08, 0x05][..], &[0x01, 0x09, 0x05, 0x03]] { let mut buf = Decoder::new(bytes, version.into()); RequestOk::decode_msg(&mut buf, version).unwrap_or_else(|e| panic!("{version}: {e}")); @@ -139,7 +139,7 @@ mod tests { #[test] fn test_request_ok_active_round_trips() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for count in [None, Some(0), Some(7)] { let msg = RequestOk { largest: None, diff --git a/rs/moq-net/src/ietf/request_stream.rs b/rs/moq-net/src/ietf/request_stream.rs index 025b138f842..fdb8c458127 100644 --- a/rs/moq-net/src/ietf/request_stream.rs +++ b/rs/moq-net/src/ietf/request_stream.rs @@ -265,7 +265,7 @@ impl Update { 0x10 => forward: Option, 0x20 => priority: Option, 0x21 => filter: Option, - 0x23 => fill: Option where Filter::is_draft22(version), + 0x23 => fill: Option where Filter::is_draft20(version), 0x25 => subgroup_filter: Vec where super::subscribe::has_range_filters(version), 0x26 => object_filter: Vec where super::subscribe::has_range_filters(version), 0x27 => priority_filter: Vec where super::subscribe::has_range_filters(version), @@ -363,7 +363,7 @@ impl<'a, const TRACKS: bool> Decode<'a, Version> for NamespaceUpdate { let request_id = super::RequestId::decode(&mut data, version)?; decode_params!(&mut data, version, 0x03 => token: Vec, - 0x10 => _forward: Option where TRACKS && super::Filter::is_draft22(version), + 0x10 => _forward: Option where TRACKS && super::Filter::is_draft20(version), 0x29 => _track_filter: Vec where TRACKS && super::subscribe::has_range_filters(version), 0x34 => prefix: Option, ); @@ -390,7 +390,7 @@ mod tests { #[moq_clock::test] async fn request_messages_keep_goaway_state_across_response_phases() { use crate::lite::test_transport::ScriptedSession; - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { // GOAWAY, REQUEST_OK, then another GOAWAY on the same stream. let script = vec![0x10, 0, 2, 0, 0, 0x07, 0, 0, 0x10, 0, 2, 0, 0]; let session = ScriptedSession::eof(script); @@ -434,7 +434,7 @@ mod tests { #[moq_clock::test] async fn a_goaway_does_not_cancel_a_pending_request() { use crate::lite::test_transport::ScriptedSession; - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let session = ScriptedSession::new(vec![0x10, 0, 2, 0, 0]); let mut stream = Stream::open(&mut crate::driver::Transport::new(session.clone()), version) .await @@ -471,7 +471,7 @@ mod tests { #[test] fn delivery_timeouts_on_subscription_updates_are_accepted() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { // Request ID 2; OBJECT_DELIVERY_TIMEOUT=7, SUBGROUP_DELIVERY_TIMEOUT=9. let mut buf = bytes::Bytes::from_static(&[2, 2, 0x02, 7, 0x04, 9]); let update = crate::coding::decode_buf(&mut buf, version, Update::decode_body).unwrap(); diff --git a/rs/moq-net/src/ietf/session.rs b/rs/moq-net/src/ietf/session.rs index e0467d3274a..a05307d8501 100644 --- a/rs/moq-net/src/ietf/session.rs +++ b/rs/moq-net/src/ietf/session.rs @@ -1435,7 +1435,7 @@ mod tests { #[moq_clock::test] async fn auth_ids_need_the_peers_parity() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for client in [false, true] { let first = u64::from(client); for requests in [vec![(true, first ^ 1)], vec![(false, first), (true, (first + 2) ^ 1)]] { @@ -2015,7 +2015,7 @@ mod tests { /// reset on draft-22: a peer that never closes it never sees the two overlap. #[moq_clock::test] async fn a_broader_watch_waits_for_the_narrower_to_leave_the_wire() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let subscribe = crate::origin::Config::new(crate::Hop::new(1).unwrap()).produce(); let _front = watch(&subscribe, "cam/front"); let (log, _driver) = client(version, subscribe.clone(), None).await; @@ -2861,7 +2861,7 @@ mod tests { /// Padding is read and dropped: no STOP_SENDING, and the session stays up. #[moq_clock::test] async fn a_padding_stream_is_discarded() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let (log, result) = dispatch_uni(version, uni_stream(version, PADDING), None).await; assert!( @@ -2932,7 +2932,7 @@ mod tests { /// The bidi dispatcher closes the session for an unknown full-width message type. #[moq_clock::test] async fn an_unknown_bidi_type_closes_the_session() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for kind in [0u64, 1 << 53] { let mut payload = Vec::new(); let mut w = crate::coding::Encoder::new(&mut payload, version.into()); @@ -2984,7 +2984,7 @@ mod tests { #[moq_clock::test] async fn an_invalid_group_order_closes_the_session() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for (value, nested) in [ (0u8, false), (3, false), @@ -3187,7 +3187,7 @@ mod tests { /// What a server may not send in its SETUP closes the session with the draft's code. #[moq_clock::test] async fn a_server_setup_with_path_or_authority_closes_the_session() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for (param, expected) in [ (ietf::ParameterBytes::Path, SessionError::InvalidPath), (ietf::ParameterBytes::Authority, SessionError::InvalidAuthority), @@ -3205,7 +3205,7 @@ mod tests { /// read as the value it carries (draft-22 section 9.1.4). #[moq_clock::test] async fn a_server_setup_token_decodes_by_the_setup_rules() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for (token, expected) in [ // An Alias Type of 4 does not exist. (&[0x04][..], Some(SessionError::KeyValueFormatting)), @@ -3224,7 +3224,7 @@ mod tests { /// is malformed, closes the session as a PROTOCOL_VIOLATION. One GOAWAY leaves it up. #[moq_clock::test] async fn the_setup_stream_carries_at_most_one_goaway() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let request_id = (version == Version::Draft18).then_some(0); let one = goaway(version, request_id); let two = [one.clone(), one.clone()].concat(); @@ -3271,7 +3271,7 @@ mod tests { #[moq_clock::test] async fn a_control_stream_fin_or_reset_is_a_protocol_violation() { use crate::lite::test_transport::{Close, DeadStreamSession, ScriptedSession}; - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let session = ScriptedSession::new(Vec::new()).with_incoming_unis(vec![setup_stream( version, ietf::Parameters::default(), @@ -3303,7 +3303,7 @@ mod tests { /// so an application leaving over it cannot close first, without our code. #[moq_clock::test] async fn a_goaway_with_more_behind_it_never_surfaces() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let request_id = (version == Version::Draft18).then_some(0); let two = [goaway(version, request_id), goaway(version, request_id)].concat(); let session = crate::lite::test_transport::ScriptedSession::new(Vec::new()).with_incoming_unis(vec![two]); @@ -3510,7 +3510,7 @@ mod tests { /// its length. #[moq_clock::test] async fn a_malformed_request_closes_the_session() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let subscribe = |body: &[u8]| frame(version, ietf::Subscribe::ID, body); // Request ID 1, the namespace "n", the name "x", and no parameters. let valid = [1, 1, 1, b'n', 1, b'x', 0]; @@ -3581,7 +3581,7 @@ mod tests { /// message, closes the session as a PROTOCOL_VIOLATION. #[moq_clock::test] async fn a_request_stream_carries_at_most_one_goaway() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let one = goaway(version, None); let two = [one.clone(), one.clone()].concat(); @@ -3610,7 +3610,7 @@ mod tests { /// closes the session as a PROTOCOL_VIOLATION. #[moq_clock::test] async fn a_request_stream_goaway_redirects_only_from_a_server() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let mut body = Vec::new(); ietf::GoAway { new_session_uri: "https://example.com/moq".into(), diff --git a/rs/moq-net/src/ietf/subscribe.rs b/rs/moq-net/src/ietf/subscribe.rs index 840e8c589a3..29b0c0a6c87 100644 --- a/rs/moq-net/src/ietf/subscribe.rs +++ b/rs/moq-net/src/ietf/subscribe.rs @@ -97,13 +97,13 @@ impl<'a> Message<'a> for Subscribe<'a> { 0x20 => subscriber_priority: Option, 0x21 => filter: Option, 0x22 => group_order: Option, - 0x23 => fill: Option where Filter::is_draft22(version), + 0x23 => fill: Option where Filter::is_draft20(version), 0x25 => subgroup_filter: Vec where has_range_filters(version), 0x26 => object_id_filter: Vec where has_range_filters(version), 0x27 => priority_filter: Vec where has_range_filters(version), 0x28 => object_property_filter: Vec where has_range_filters(version), 0x32 => new_group: Option, - 0x35 => include_properties: Option where Filter::is_draft22(version), + 0x35 => include_properties: Option where Filter::is_draft20(version), epoch::EPOCH_PARAM => epoch: Option, super::max_age::PARAMETER => max_age: Option, ); @@ -156,12 +156,12 @@ impl<'a> Message<'a> for Subscribe<'a> { // FILL_PARAMETERS arrived in draft-22. Sending it to an older peer would be an // unknown parameter, which is a protocol violation, so it is dropped instead. // A subscriber there simply joins mid-group, which is what it did all along. - let fill = self.fill.filter(|_| Filter::is_draft22(version)); + let fill = self.fill.filter(|_| Filter::is_draft20(version)); // INCLUDE_PROPERTIES defaults to 1, so only the opt-out is worth bytes. It // arrived in draft-22, and an older peer would read it as an unknown // parameter, which is a protocol violation. - let include_properties = (!self.properties_wanted && Filter::is_draft22(version)).then_some(false); + let include_properties = (!self.properties_wanted && Filter::is_draft20(version)).then_some(false); // Only a session that negotiated MoQ Epoch names one. let epoch = self.epoch.clone(); @@ -266,7 +266,7 @@ impl<'a> Message<'a> for SubscribeUpdate { 0x10 => self.forward, 0x20 => self.subscriber_priority, 0x21 => self.filter, - 0x23 => self.fill.filter(|_| Filter::is_draft22(version)), + 0x23 => self.fill.filter(|_| Filter::is_draft20(version)), 0x32 => self.new_group, super::max_age::PARAMETER => self.max_age, ); @@ -286,7 +286,7 @@ impl<'a> Message<'a> for SubscribeUpdate { 0x10 => forward: Option, 0x20 => subscriber_priority: Option, 0x21 => filter: Option, - 0x23 => fill: Option where Filter::is_draft22(version), + 0x23 => fill: Option where Filter::is_draft20(version), 0x25 => _subgroup_filter: Vec where has_range_filters(version), 0x26 => _object_id_filter: Vec where has_range_filters(version), 0x27 => _priority_filter: Vec where has_range_filters(version), @@ -327,7 +327,7 @@ mod tests { #[test] fn subscriber_max_age_round_trips() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for max_age in [None, Some(0), Some(250), Some(super::super::max_age::MAX_MILLIS)] { let msg = Subscribe { max_age, @@ -398,7 +398,7 @@ mod tests { } /// Build a SUBSCRIBE body carrying a single RENDEZVOUS_TIMEOUT parameter. - const VERSIONS: [Version; 2] = [Version::Draft18, Version::Draft22]; + const VERSIONS: [Version; 3] = [Version::Draft18, Version::Draft20, Version::Draft22]; /// NEW_GROUP_REQUEST survives SUBSCRIBE and REQUEST_UPDATE. #[test] @@ -465,7 +465,7 @@ mod tests { /// SUBSCRIBE. #[test] fn rendezvous_timeout_retains_whether_a_wait_was_requested() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for millis in [0, 5000] { let encoded = subscribe_with_rendezvous(millis, version); let msg: Subscribe = decode_message(&encoded, version) @@ -515,7 +515,7 @@ mod tests { epoch: None, }; - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { // The reader has to be able to see a 0x04, or its absence below proves nothing. assert_eq!( first_param_key(&subscribe_with_rendezvous(5000, version), version), @@ -576,7 +576,7 @@ mod tests { #[test] fn test_subscribe_ok_accepts_largest_object() { let payload = [0x04, 0x01, 0x09, 0x05, 0x00]; - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let decoded: SubscribeOk = decode_message(&payload, version).unwrap(); assert_eq!(decoded.track_alias, 4, "{version}"); @@ -630,7 +630,7 @@ mod tests { /// instead of letting the request reach its answer. #[test] fn subscribe_accepts_the_delivery_timeouts() -> Result<(), EncodeError> { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let mut body = Vec::new(); let w = &mut Encoder::new(&mut body, version.into()); RequestId(1).encode(w, version)?; @@ -719,7 +719,7 @@ mod tests { /// stack's unset 127, so a relay forwards it unchanged. #[test] fn test_subscribe_omitted_priority_is_128() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let mut bytes = vec![0x00]; // request_id bytes.extend_from_slice(b"\x01\x0bnonexistent\x0dno-such-track"); // namespace, name bytes.push(0x00); // no parameters @@ -775,7 +775,7 @@ mod tests { /// decoder returns the same wire value. #[test] fn subscribe_ok_priority_property_bytes_on_every_draft() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let mut msg = SubscribeOk { track_alias: 42, largest: None, @@ -974,7 +974,7 @@ mod tests { /// FORWARD=0 is legal on every draft, a paused request rather than a session error. #[test] fn subscribe_decodes_forward_zero() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let msg = Subscribe { new_group: None, max_age: None, @@ -1008,7 +1008,7 @@ mod tests { 0x01, // Number of Parameters 0x03, 0x03, 0x03, 0x00, 0xAA, // AUTHORIZATION TOKEN ]); - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let wire = body.clone(); let mut buf = Decoder::new(&wire, version.into()); Subscribe::decode_msg(&mut buf, version).unwrap_or_else(|e| panic!("{version}: {e}")); @@ -1075,7 +1075,7 @@ mod cache_duration_tests { #[test] fn max_cache_duration_is_read_in_each_drafts_field() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for age in [0u64, 30_000] { let mut payload = vec![0, 0, 4]; Encoder::new(&mut payload, version.into()).varint(age).unwrap(); @@ -1093,7 +1093,7 @@ mod cache_duration_tests { #[test] fn cache_duration_preserves_optional_value() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for age in [None, Some(Duration::ZERO), Some(Duration::from_secs(30))] { let ok = SubscribeOk { track_alias: 0, diff --git a/rs/moq-net/src/ietf/subscribe_tracks.rs b/rs/moq-net/src/ietf/subscribe_tracks.rs index 25772e046cb..48265e26a6d 100644 --- a/rs/moq-net/src/ietf/subscribe_tracks.rs +++ b/rs/moq-net/src/ietf/subscribe_tracks.rs @@ -51,15 +51,20 @@ impl<'a> Message<'a> for SubscribeTracks { self.request_id.encode(w, version)?; encode_namespace(w, &self.prefix)?; // Absent means 1, so only a paused listing writes it. - let include_properties = (!self.properties_wanted && Filter::is_draft22(version)).then_some(false); - // Draft-18 allows only AUTHORIZATION_TOKEN and FORWARD here. Draft-22 section 9.18 - // lists GROUP_ORDER but no longer SUBSCRIBER_PRIORITY, LOCATION_FILTER, - // FILL_PARAMETERS, or NEW_GROUP_REQUEST, which a resuming REQUEST_UPDATE carries. + let include_properties = (!self.properties_wanted && Filter::is_draft20(version)).then_some(false); + // Draft-18 allows only AUTHORIZATION_TOKEN and FORWARD here. Draft-20 allows any + // subscription parameter (section 10.20.1). Draft-22 section 9.18 lists GROUP_ORDER + // but no longer SUBSCRIBER_PRIORITY, LOCATION_FILTER, FILL_PARAMETERS, or + // NEW_GROUP_REQUEST, which a resuming REQUEST_UPDATE carries. let defaults = version != Version::Draft18; + let subscription = version == Version::Draft20; encode_params!(w, version, 0x03 => self.authorization_token.clone(), 0x10 => (!self.forward).then_some(false), + 0x20 => self.subscriber_priority.filter(|_| subscription), + 0x21 => self.filter.filter(|_| subscription), 0x22 => self.group_order.filter(|_| defaults), + 0x32 => self.new_group.filter(|_| subscription), 0x35 => include_properties, ); Ok(()) @@ -68,7 +73,7 @@ impl<'a> Message<'a> for SubscribeTracks { fn decode_msg(r: &mut Decoder<'a>, version: Version) -> Result { let request_id = RequestId::decode(r, version)?; let prefix = decode_namespace(r)?; - // From draft-22 any parameter a SUBSCRIBE takes is legal here (section 3.6.2); + // From draft-20 any parameter a SUBSCRIBE takes is legal here (section 3.6.2 of draft-22); // draft-18 allows only AUTHORIZATION_TOKEN and FORWARD. Those that only make sense // on one subscription, such as RENDEZVOUS_TIMEOUT or a delivery timeout, are read // and dropped. @@ -84,14 +89,14 @@ impl<'a> Message<'a> for SubscribeTracks { 0x22 => group_order: Option where defaults, // Each PUBLISH starts paused, where a fill opens nothing, even once resumed // (draft-22 section 3.4.1), so FILL_PARAMETERS is read and dropped. - 0x23 => _fill: Option where Filter::is_draft22(version), + 0x23 => _fill: Option where Filter::is_draft20(version), 0x25 => subgroup_filter: Vec where has_range_filters(version), 0x26 => object_id_filter: Vec where has_range_filters(version), 0x27 => priority_filter: Vec where has_range_filters(version), 0x28 => object_property_filter: Vec where has_range_filters(version), 0x29 => track_property_filter: Vec where has_range_filters(version), 0x32 => new_group: Option where defaults, - 0x35 => include_properties: Option where Filter::is_draft22(version), + 0x35 => include_properties: Option where Filter::is_draft20(version), ); let range_filters = [ subgroup_filter, @@ -182,7 +187,7 @@ mod tests { #[test] fn a_paused_listing_round_trips() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let decoded: SubscribeTracks = decode(&encode(&paused(), version), version).unwrap(); assert_eq!(decoded.request_id, RequestId(4), "{version}"); assert_eq!(decoded.prefix.as_str(), "room", "{version}"); @@ -228,6 +233,25 @@ mod tests { assert!(decode::(&bytes, Version::Draft18).is_err()); } + /// Draft-20 allows any subscription parameter on SUBSCRIBE_TRACKS, so the listing's + /// defaults are sent and read back. + #[test] + fn draft_20_carries_the_subscription_parameters() { + let listing = SubscribeTracks { + subscriber_priority: Some(7), + group_order: Some(GroupOrder::Ascending), + filter: Some(Filter::NextObject), + new_group: Some(0), + ..paused() + }; + let version = Version::Draft20; + let decoded: SubscribeTracks = decode(&encode(&listing, version), version).unwrap(); + assert_eq!(decoded.subscriber_priority, Some(7)); + assert_eq!(decoded.group_order, Some(GroupOrder::Ascending)); + assert_eq!(decoded.filter, Some(Filter::NextObject)); + assert_eq!(decoded.new_group, Some(0)); + } + /// Draft-22 section 9.18 no longer lists SUBSCRIBER_PRIORITY, LOCATION_FILTER, /// FILL_PARAMETERS, or NEW_GROUP_REQUEST, so none is sent there; GROUP_ORDER still is. /// Section 3.6.2 still allows any subscription parameter, so one received is read. @@ -258,7 +282,7 @@ mod tests { #[test] fn publish_skipped_round_trips() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let msg = PublishSkipped { suffix: Path::from_static("cam"), track_name: "video".into(), diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index ce304f6b913..409531f8c35 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -3658,7 +3658,7 @@ impl Subscriber { _ => false, }; let ranges = if bounds != sent_bounds { - let mut join = if Filter::is_draft22(self.version) { + let mut join = if Filter::is_draft20(self.version) { match subscribe_join(bounds.0, bounds.1, self.version) { Ok(join) => join, Err(err) => return Poll::Ready(End::Invalid(err)), @@ -3681,7 +3681,7 @@ impl Subscriber { fetch: false, } }; - if widened && Filter::is_draft22(self.version) { + if widened && Filter::is_draft20(self.version) { join.fill = Some(ietf::Fill { filter: Some(match bounds.0 { None => Filter::Relative(1), @@ -5431,7 +5431,7 @@ impl Subscriber { let validity = self.validity.start(); let last = run.end - 1; let start = fill.frame_start(run.start); - let draft22 = Filter::is_draft22(self.version); + let draft20 = Filter::is_draft20(self.version); // The owning subscribe/linger loop enforces its admitted gate, including a // token-authorized announce outside the session scope. Its abort ends this job. @@ -5466,7 +5466,7 @@ impl Subscriber { group: run.start, object: start, }; - let fetch_type = match draft22 { + let fetch_type = match draft20 { // No End Object includes the whole End Group. true => FetchType::Filtered { namespace, @@ -5552,7 +5552,7 @@ impl Subscriber { // Draft-22's End Location is inclusive; older drafts spell a bounded object one past it. let mut end = ok.end_location; - if draft22 { + if draft20 { let Some(object) = end.object.checked_add(1) else { fill.reject_groups(run, Error::ProtocolViolation); let _ = stream.writer.close().await; @@ -5563,12 +5563,12 @@ impl Subscriber { // Before draft-22, Object 0 covers the whole named group. Legacy answers one // group past it still pass the exclusive comparison below. - let whole_last = !draft22 && end.group == last && end.object == 0; + let whole_last = !draft20 && end.group == last && end.object == 0; // Draft-22's answer ends at or after its start and never past the requested end, which // a publisher following section 9.11 cuts at the Largest Object. Validate before accepting a group or letting End of // Track mark where the track ends. - if draft22 && (end.group < run.start || end.group > last || (end.group == run.start && end.object <= start)) { + if draft20 && (end.group < run.start || end.group > last || (end.group == run.start && end.object <= start)) { let err = Error::ProtocolViolation; tracing::warn!(groups = ?run, ?end, "FETCH_OK's End Location is outside the requested range"); self.session.clone().close( @@ -5853,7 +5853,7 @@ impl Subscriber { // a complete one. Draft-22's End Location is the range covered, not the last object // sent: objects missing before it do not exist (section 9.11). Before draft-22 the // stream must reach the bounded group at all, not just its objects. - if !Filter::is_draft22(self.version) + if !Filter::is_draft20(self.version) && let Some(end) = writer.fetch.end && (writer.sequence() != Some(writer.fetch.last) || next < end) { @@ -6428,7 +6428,7 @@ mod tests { /// and there is no answer to wait for. #[moq_clock::test] async fn a_namespace_request_stalled_on_credit_ends_when_cancelled() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let session = crate::lite::test_transport::ScriptedSession::new(Vec::new()).with_send_window(1); let log = session.log.clone(); let (tasks, _task_set) = crate::util::TaskSet::new(); @@ -7544,7 +7544,7 @@ mod tests { /// cancels the subscribe at once, not once the peer answers or acknowledges the cancel. #[moq_clock::test] async fn a_revocation_never_waits_behind_subscribe_ok() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { // A peer that accepts the stream and then says nothing at all, not even // acknowledging the cancellation's FIN. let session = crate::lite::test_transport::ScriptedSession::new(Vec::new()).with_unacked_fin(); @@ -8324,7 +8324,7 @@ mod tests { } } - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let origin = crate::origin::Config::new(crate::Hop::new(1).unwrap()).produce(); let source = origin.publish("broadcast", Default::default()).unwrap(); let resolved = origin.consume().request("broadcast", None).await.unwrap(); @@ -8350,7 +8350,7 @@ mod tests { /// including NOT_SUPPORTED and undefined codes, without opening a subscription. #[moq_clock::test] async fn a_refused_track_status_never_subscribes() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for code in [3, u64::from(u32::MAX)] { for fetching in [false, true] { let refused = message( @@ -8419,8 +8419,8 @@ mod tests { #[moq_clock::test] async fn a_resumed_subscribe_opts_out_of_known_properties() { let declared = Timescale::new(90_000).unwrap(); - for version in [Version::Draft18, Version::Draft22] { - let opts_out = ietf::Filter::is_draft22(version); + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { + let opts_out = ietf::Filter::is_draft20(version); let declares = |yes: bool| ietf::Properties { timescale: yes.then_some(declared), ..Default::default() @@ -9072,7 +9072,7 @@ mod tests { #[moq_clock::test] async fn publish_namespace_requester_fin_keeps_the_route() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { for reset in [false, true] { let origin = crate::origin::Config::new(crate::Hop::new(1).unwrap()).produce(); let consumer = origin.consume(); @@ -10451,7 +10451,7 @@ mod tests { /// only afterwards. #[moq_clock::test] async fn a_revoked_token_retracts_an_announce_whose_ok_is_blocked() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let gate = kio::Producer::new(false); let session = crate::lite::test_transport::SinkSession::gated_bi(gate.consume()); let (mut subscriber, mut requests, _cred, consumer, session) = @@ -12129,7 +12129,7 @@ struct Join { /// A start group we already know is absolute on draft-22 and needs no fill: the /// subscription's own range covers it, which is what our publisher serves from its cache. fn subscribe_join(start: Option, end: Option, version: Version) -> Result { - if !Filter::is_draft22(version) { + if !Filter::is_draft20(version) { if end.is_some() { return Err(Error::Unsupported); } @@ -12885,7 +12885,7 @@ mod stitch_tests { ); let mut body = Vec::new(); let id = if let Some((start, end)) = fetch { - let fetch_type = if Filter::is_draft22(egress) { + let fetch_type = if Filter::is_draft20(egress) { ietf::FetchType::Filtered { namespace: Path::from_static("room"), track: "video".into(), @@ -13098,7 +13098,7 @@ mod stitch_tests { let ok = ietf::FetchOk::decode(&mut decoder, version).unwrap(); assert_eq!( ok.end_location.object, - if Filter::is_draft22(version) { 8 } else { 9 }, + if Filter::is_draft20(version) { 8 } else { 9 }, "{version} start={start}" ); assert_eq!(decoder.varint().unwrap(), ietf::FetchHeader::TYPE); @@ -13150,13 +13150,13 @@ mod stitch_tests { let mut decoder = Decoder::new(&bytes, version.into()); assert_eq!(decoder.varint().unwrap(), ietf::FetchOk::ID, "{version}"); let ok = ietf::FetchOk::decode(&mut decoder, version).unwrap(); - let last = if Filter::is_draft22(version) { 8 } else { 9 }; + let last = if Filter::is_draft20(version) { 8 } else { 9 }; assert_eq!(ok.end_location.object, last, "{version}"); assert_eq!(decoder.varint().unwrap(), ietf::FetchHeader::TYPE); ietf::FetchHeader::decode(&mut decoder, version).unwrap(); // The next relay reads the same objects into its cache, up to the same end. - let end = last + u64::from(Filter::is_draft22(version)); + let end = last + u64::from(Filter::is_draft20(version)); let mut run = GroupFetchRun::new(version, decoder.rest().to_vec()).await; let mut reader = run .recv_cached(Some(end), None) @@ -13304,7 +13304,7 @@ mod stitch_tests { #[moq_clock::test] async fn passthrough_preserves_immutable_bytes() { - for ingress in [Version::Draft18, Version::Draft22] { + for ingress in [Version::Draft18, Version::Draft20, Version::Draft22] { let mut inner = Vec::new(); let mut encoder = Encoder::new(&mut inner, ingress.into()); for value in [2u64, 96_000, 2, 128, 1] { @@ -13315,7 +13315,7 @@ mod stitch_tests { let mut encoder = Encoder::new(&mut properties, ingress.into()); encoder.varint(0x0bu64).unwrap(); encoder.bytes(&inner).unwrap(); - for egress in [Version::Draft18, Version::Draft22] { + for egress in [Version::Draft18, Version::Draft20, Version::Draft22] { let script = object_stream(ingress, true, &[(0, &properties, None)]); let (bytes, log) = relay_passthrough_stream(script, ingress, egress).await; assert!(log.resets().is_empty()); @@ -14609,7 +14609,7 @@ mod stitch_tests { async fn a_group_fetch_stays_within_its_end_location() { const END: u64 = 3; for version in [Version::Draft18, VERSION] { - let short = Filter::is_draft22(version); + let short = Filter::is_draft20(version); for (count, complete) in [(2, short), (3, true), (4, false)] { let payloads: Vec<&[u8]> = [b"a", b"b", b"c", b"d"][..count].iter().map(|p| &p[..]).collect(); let mut run = GroupFetchRun::new(version, group_fetch_objects(SEQUENCE, 0, &payloads)).await; @@ -14673,7 +14673,7 @@ mod stitch_tests { end: Some(2), })); let res = run.subscriber.recv_group_fetch(&mut run.stream, slot).await; - match Filter::is_draft22(version) { + match Filter::is_draft20(version) { false => assert!( matches!(res, Err(Error::ProtocolViolation)), "{version} empty={empty}: {res:?}" @@ -14731,7 +14731,7 @@ mod stitch_tests { /// caches the supplied groups and reports the gaps between them as misses. #[moq_clock::test] async fn a_range_fetch_caches_the_groups_with_the_groups_between_dropped() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let mut objects = group_fetch_objects(4, 0, &[b"4-0", b"4-1"]); // Later Group IDs are deltas, so 1 advances from group 4 to group 6. objects.extend(group_fetch_objects(1, 0, &[b"6-0", b"6-1"])); @@ -15974,11 +15974,11 @@ mod joining_fetch_tests { const GROUP: u64 = 4; const START: u64 = 2; const LAST: u64 = START + 1; - let draft22 = Filter::is_draft22(version); + let draft20 = Filter::is_draft20(version); // The whole group, as each draft answers it: draft 22 names the last object, and // older drafts name the whole group with Object 0. - let end_location = match draft22 { + let end_location = match draft20 { true => ietf::Location { group: GROUP, object: LAST, @@ -16095,7 +16095,7 @@ mod joining_fetch_tests { }; match msg.fetch_type { // No End Object is the whole End Group. - FetchType::Filtered { filter, .. } if draft22 => assert_eq!( + FetchType::Filtered { filter, .. } if draft20 => assert_eq!( filter, Filter::Absolute { start: from, @@ -16107,7 +16107,7 @@ mod joining_fetch_tests { "{version}: through the end of the group" ), // An End Object of 0 is the whole End Group. - FetchType::Standalone { start, end, .. } if !draft22 => { + FetchType::Standalone { start, end, .. } if !draft20 => { assert_eq!(start, from, "{version}"); assert_eq!( end, @@ -16570,7 +16570,7 @@ mod track_property_tests { }; /// The newest draft and an older one, both with a request stream per subscription. - const VERSIONS: [Version; 2] = [Version::Draft18, Version::Draft22]; + const VERSIONS: [Version; 3] = [Version::Draft18, Version::Draft20, Version::Draft22]; /// Subscribe to one track through a relay on `version`, whose publisher answers with /// `block` as SUBSCRIBE_OK's Track Properties, returning what the subscriber got. @@ -16768,7 +16768,7 @@ mod full_track_name_tests { /// session carries the next one. #[moq_clock::test] async fn an_unencodable_track_name_fails_only_its_subscription() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let (session, peer) = memory::pair(memory::Config::default()); let (tasks, _task_set) = TaskSet::new(); let subscriber = Subscriber::new( @@ -16834,7 +16834,7 @@ mod compression_negotiation_tests { compress: true, ..Default::default() }; - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { assert!(matches!( refused(&properties, version, false), Some(Error::UnsupportedExtension) diff --git a/rs/moq-net/src/ietf/subscriber/tracks.rs b/rs/moq-net/src/ietf/subscriber/tracks.rs index 9aa4a9d9f82..f572b88e1d1 100644 --- a/rs/moq-net/src/ietf/subscriber/tracks.rs +++ b/rs/moq-net/src/ietf/subscriber/tracks.rs @@ -1475,7 +1475,7 @@ mod tests { /// and a reader leaving meanwhile stops waiting for it. #[moq_clock::test] async fn churn_under_withheld_credit_buffers_one_resume_and_pause() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { // One message in flight per stream, so a peer that stops reading withholds credit. let config = memory::Config { stream_buffer: 0, @@ -1618,7 +1618,7 @@ mod tests { /// A skipped track is listed through a paused SUBSCRIBE of ours, once it answers. #[moq_clock::test] async fn a_skipped_track_lists_once_its_paused_subscribe_answers() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let mut h = harness(version); let mut listing = h.establish().await; let skipped = ietf::PublishSkipped { @@ -1717,7 +1717,7 @@ mod tests { /// objects refused unseen. On draft-18 our PUBLISH_OK pauses it. #[moq_clock::test] async fn a_forwarding_publish_fails_the_listing_on_draft_22() { - for version in [Version::Draft18, Version::Draft22] { + for version in [Version::Draft18, Version::Draft20, Version::Draft22] { let mut h = harness(version); let _listing = h.establish().await; let forwarding = ietf::Publish { diff --git a/rs/moq-net/src/ietf/token.rs b/rs/moq-net/src/ietf/token.rs index cbb3d5d58ab..f3e40de5eac 100644 --- a/rs/moq-net/src/ietf/token.rs +++ b/rs/moq-net/src/ietf/token.rs @@ -201,7 +201,7 @@ mod tests { )); } - const VERSIONS: [Version; 2] = [Version::Draft18, Version::Draft22]; + const VERSIONS: [Version; 3] = [Version::Draft18, Version::Draft20, Version::Draft22]; fn token() -> Token { // A kind past one varint byte and a value that is not text, so neither is mistaken diff --git a/rs/moq-net/src/ietf/track.rs b/rs/moq-net/src/ietf/track.rs index 093c6617f7d..3dec6d9b87d 100644 --- a/rs/moq-net/src/ietf/track.rs +++ b/rs/moq-net/src/ietf/track.rs @@ -51,7 +51,7 @@ impl<'a> Message<'a> for TrackStatus<'a> { // Only the opt-out is worth bytes, and an older peer would read the // parameter as unknown, which is a protocol violation. - let include_properties = (!self.properties_wanted && Filter::is_draft22(version)).then_some(false); + let include_properties = (!self.properties_wanted && Filter::is_draft20(version)).then_some(false); let epoch = self.epoch.clone(); encode_params!(w, version, 0x35 => include_properties, @@ -177,7 +177,7 @@ mod tests { assert_eq!(decoded.track_name, "video"); } - const ALL: [Version; 2] = [Version::Draft18, Version::Draft22]; + const ALL: [Version; 3] = [Version::Draft18, Version::Draft20, Version::Draft22]; /// INCLUDE_PROPERTIES only exists from draft-22, so the opt-out is dropped before it, /// and the default (1) is never written. @@ -195,7 +195,7 @@ mod tests { let wire = encode_message(&msg, version); let decoded: TrackStatus = decode_message(&wire, version).unwrap_or_else(|e| panic!("{version}: {e}")); - let expected = wanted || !Filter::is_draft22(version); + let expected = wanted || !Filter::is_draft20(version); assert_eq!(decoded.properties_wanted, expected, "{version} wanted={wanted}"); } } diff --git a/rs/moq-net/src/ietf/version.rs b/rs/moq-net/src/ietf/version.rs index 5dc59eaa762..85a226afb63 100644 --- a/rs/moq-net/src/ietf/version.rs +++ b/rs/moq-net/src/ietf/version.rs @@ -6,12 +6,14 @@ use std::fmt; pub enum Version { Draft18, Draft22, + Draft20, } impl fmt::Display for Version { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Draft18 => write!(f, "moq-transport-18"), + Self::Draft20 => write!(f, "moq-transport-20"), Self::Draft22 => write!(f, "moq-transport-22"), } } diff --git a/rs/moq-net/src/server.rs b/rs/moq-net/src/server.rs index d18e3e2ab33..ec3feac5997 100644 --- a/rs/moq-net/src/server.rs +++ b/rs/moq-net/src/server.rs @@ -6,8 +6,8 @@ use crate::origin; use crate::time::{Deadlines, Instant}; use crate::transport::poll::Session as _; use crate::{ - ALPN_18, ALPN_22, ALPN_LITE, ALPN_LITE_03, ALPN_LITE_04, ALPN_LITE_05, ALPN_LITE_06, ALPN_LITE_07_WIP, Consume, - Error, NEGOTIATED, Session, SessionError, Version, Versions, + ALPN_18, ALPN_20, ALPN_22, ALPN_LITE, ALPN_LITE_03, ALPN_LITE_04, ALPN_LITE_05, ALPN_LITE_06, ALPN_LITE_07_WIP, + Consume, Error, NEGOTIATED, Session, SessionError, Version, Versions, coding::{Encode, Stream}, ietf, lite, setup::{self, Role}, @@ -319,9 +319,10 @@ impl Server { async fn handshake(&self, runtime: Deadlines, mut session: Transport) -> Result { let supported = match session.protocol() { - Some(alpn @ (ALPN_22 | ALPN_18)) => { + Some(alpn @ (ALPN_22 | ALPN_20 | ALPN_18)) => { let draft = match alpn { ALPN_22 => ietf::Version::Draft22, + ALPN_20 => ietf::Version::Draft20, _ => ietf::Version::Draft18, }; diff --git a/rs/moq-net/src/test_interop.rs b/rs/moq-net/src/test_interop.rs index 7ac8e15015a..70ac5f1675b 100644 --- a/rs/moq-net/src/test_interop.rs +++ b/rs/moq-net/src/test_interop.rs @@ -36,8 +36,8 @@ fn ietf_range_updates_interop() { responses: Vec>, streams: Vec>, } - for version in [ietf::Version::Draft18, ietf::Version::Draft22] { - let draft22 = Filter::is_draft22(version); + for version in [ietf::Version::Draft18, ietf::Version::Draft20, ietf::Version::Draft22] { + let draft20 = Filter::is_draft20(version); let range = |start, end: Option| Filter::Absolute { start: Location { group: start, @@ -54,7 +54,7 @@ fn ietf_range_updates_interop() { track_name: "video".into(), subscriber_priority: 127, group_order: ietf::GroupOrder::Ascending, - filter: if draft22 { range(4, None) } else { Filter::Unfiltered }, + filter: if draft20 { range(4, None) } else { Filter::Unfiltered }, fill: None, properties_wanted: false, forward: true, @@ -86,7 +86,7 @@ fn ietf_range_updates_interop() { bytes }; let mut updates = Vec::new(); - if draft22 { + if draft20 { updates.push(update( 2, range(3, None), @@ -113,13 +113,13 @@ fn ietf_range_updates_interop() { assert_eq!(r.varint().unwrap(), ietf::SubscribeOk::ID); let ok = ietf::SubscribeOk::decode(&mut r, version).unwrap(); assert_eq!(ok.track_alias, 0); - assert_eq!(ok.largest, draft22.then_some(Location { group: 3, object: 1 })); + assert_eq!(ok.largest, draft20.then_some(Location { group: 3, object: 1 })); } else { assert_eq!(r.varint().unwrap(), ietf::RequestOk::ID); let ok = ietf::RequestOk::decode(&mut r, version).unwrap(); assert_eq!( ok.largest, - if draft22 { + if draft20 { Some(Location { group: index as u64 + 2, object: 1, @@ -136,7 +136,7 @@ fn ietf_range_updates_interop() { for bytes in &served.streams { let mut r = Decoder::new(bytes, version.into()); if r.varint().unwrap() == ietf::FetchHeader::TYPE { - assert!(draft22); + assert!(draft20); assert_eq!( ietf::FetchHeader::decode(&mut r, version).unwrap().request_id, RequestId(2) @@ -182,7 +182,7 @@ fn ietf_range_updates_interop() { groups.sort_unstable(); assert_eq!( groups, - if draft22 { + if draft20 { vec![(3, vec![]), (4, vec![0, 1]), (6, vec![0, 1]), (7, vec![0, 1])] } else { vec![(6, vec![0, 1]), (7, vec![0, 1])] @@ -191,7 +191,7 @@ fn ietf_range_updates_interop() { ); assert_eq!( filled, - if draft22 { + if draft20 { (3..4).flat_map(|group| [(group, 0), (group, 1)]).collect::>() } else { vec![] @@ -429,8 +429,11 @@ fn ietf_datagram_interop() { use crate::coding::Decode; use crate::{Timescale, Timestamp}; - let all = [ietf::Version::Draft18, ietf::Version::Draft22]; - for (draft, version) in [18, 22].into_iter().zip(all) { + for (draft, version) in [ + (18, ietf::Version::Draft18), + (20, ietf::Version::Draft20), + (22, ietf::Version::Draft22), + ] { let mut properties = Vec::new(); let mut w = Encoder::new(&mut properties, version.into()); ietf::encode_object_time(&mut w, Timestamp::from_millis(1234).unwrap(), Timescale::MILLI).unwrap(); @@ -594,8 +597,11 @@ fn ietf_track_status_interop() { use crate::coding::Decode; use crate::ietf::error::request; - let all = [ietf::Version::Draft18, ietf::Version::Draft22]; - for (draft, version) in [18, 22].into_iter().zip(all) { + for (draft, version) in [ + (18, ietf::Version::Draft18), + (20, ietf::Version::Draft20), + (22, ietf::Version::Draft22), + ] { let request = |id: u64, namespace: &str, wanted: bool| { let mut buf = Vec::new(); let mut w = Encoder::new(&mut buf, version.into()); @@ -630,8 +636,8 @@ fn ietf_track_status_interop() { assert!(r.is_empty(), "{version}: trailing bytes"); let expected = match version { - // Only draft-22 can carry the opt-out. - _ if !wanted && ietf::Filter::is_draft22(version) => ietf::Properties::default(), + // Draft 20 and later can carry the opt-out. + _ if !wanted && ietf::Filter::is_draft20(version) => ietf::Properties::default(), _ => ietf::Properties { unknown: Default::default(), dynamic_groups: false, diff --git a/rs/moq-net/src/version.rs b/rs/moq-net/src/version.rs index bb4f869219a..9df3014994d 100644 --- a/rs/moq-net/src/version.rs +++ b/rs/moq-net/src/version.rs @@ -33,6 +33,7 @@ pub const ALPNS: &[&str] = &[ ALPN_LITE_03, ALPN_LITE, ALPN_22, + ALPN_20, ALPN_18, ]; @@ -44,9 +45,10 @@ pub(crate) const ALPN_LITE_05: &str = "moq-lite-05"; pub(crate) const ALPN_LITE_06: &str = "moq-lite-06"; pub(crate) const ALPN_LITE_07_WIP: &str = "moq-lite-07-wip"; pub(crate) const ALPN_18: &str = "moqt-18"; +pub(crate) const ALPN_20: &str = "moqt-20"; pub(crate) const ALPN_22: &str = "moqt-22"; -const ALL: [Version; 9] = [ +const ALL: [Version; 10] = [ Version::Lite(lite::Version::Lite07), Version::Lite(lite::Version::Lite06), Version::Lite(lite::Version::Lite05), @@ -55,6 +57,7 @@ const ALL: [Version; 9] = [ Version::Lite(lite::Version::Lite02), Version::Lite(lite::Version::Lite01), Version::Ietf(ietf::Version::Draft22), + Version::Ietf(ietf::Version::Draft20), Version::Ietf(ietf::Version::Draft18), ]; @@ -98,6 +101,7 @@ impl Version { Self::Lite(lite::Version::Lite06) => "moq-lite-06", Self::Lite(lite::Version::Lite07) => "moq-lite-07-wip", Self::Ietf(ietf::Version::Draft18) => "moq-transport-18", + Self::Ietf(ietf::Version::Draft20) => "moq-transport-20", Self::Ietf(ietf::Version::Draft22) => "moq-transport-22", } } @@ -113,6 +117,7 @@ impl Version { 0xff0dad06 => Some(Self::Lite(lite::Version::Lite06)), 0xff0dad07 => Some(Self::Lite(lite::Version::Lite07)), 0xff000012 => Some(Self::Ietf(ietf::Version::Draft18)), + 0xff000014 => Some(Self::Ietf(ietf::Version::Draft20)), 0xff000016 => Some(Self::Ietf(ietf::Version::Draft22)), _ => None, } @@ -129,6 +134,7 @@ impl Version { Self::Lite(lite::Version::Lite06) => 0xff0dad06, Self::Lite(lite::Version::Lite07) => 0xff0dad07, Self::Ietf(ietf::Version::Draft18) => 0xff000012, + Self::Ietf(ietf::Version::Draft20) => 0xff000014, Self::Ietf(ietf::Version::Draft22) => 0xff000016, } } @@ -143,6 +149,7 @@ impl Version { Self::Lite(lite::Version::Lite03) => ALPN_LITE_03, Self::Lite(lite::Version::Lite01 | lite::Version::Lite02) => ALPN_LITE, Self::Ietf(ietf::Version::Draft18) => ALPN_18, + Self::Ietf(ietf::Version::Draft20) => ALPN_20, Self::Ietf(ietf::Version::Draft22) => ALPN_22, } } diff --git a/rs/moq-net/tests/integration/tracks_ietf.rs b/rs/moq-net/tests/integration/tracks_ietf.rs index 0d6c60c7c91..5e6fa458633 100644 --- a/rs/moq-net/tests/integration/tracks_ietf.rs +++ b/rs/moq-net/tests/integration/tracks_ietf.rs @@ -17,7 +17,7 @@ use support::harness::{MockConnectOptions, MockPair, connect_mock}; const TIMEOUT: Duration = Duration::from_secs(10); /// Every draft that has SUBSCRIBE_TRACKS. -const DRAFTS: [&str; 2] = ["moq-transport-18", "moq-transport-22"]; +const DRAFTS: [&str; 3] = ["moq-transport-18", "moq-transport-20", "moq-transport-22"]; /// SUBSCRIBE (0x03), as the first byte of a request stream. const SUBSCRIBE: u8 = 0x03; diff --git a/rs/moq-relay/src/websocket.rs b/rs/moq-relay/src/websocket.rs index 8c8742ed0d1..06759799ba6 100644 --- a/rs/moq-relay/src/websocket.rs +++ b/rs/moq-relay/src/websocket.rs @@ -136,7 +136,7 @@ const QMUX_VERSIONS: &[qmux::Version] = &[qmux::Version::QMux01, qmux::Version:: /// moq-transport-18 and newer require qmux-01, so we never pair them with qmux-00. /// Mirrors `js/net`'s `connect.ts` and moq-tokio's `websocket_subprotocols`. -const QMUX01_ONLY_ALPNS: &[&str] = &["moqt-18", "moqt-22"]; +const QMUX01_ONLY_ALPNS: &[&str] = &["moqt-18", "moqt-20", "moqt-22"]; /// Subprotocols to advertise on the WebSocket upgrade. /// @@ -147,7 +147,7 @@ const QMUX01_ONLY_ALPNS: &[&str] = &["moqt-18", "moqt-22"]; /// resolve a moq version from it, and the relay silently downgrades clients to /// Lite02 via SETUP-based negotiation. /// -/// `qmux-00.moqt-{18,22}` is excluded: moq-transport-18 and newer require +/// `qmux-00.moqt-{18,20,22}` is excluded: moq-transport-18 and newer require /// qmux-01, so those pairs are illegal. fn supported_subprotocols(alpns: &[&str]) -> Vec { let mut out = Vec::with_capacity(QMUX_VERSIONS.len() * alpns.len() + qmux::Version::ALL.len()); @@ -382,8 +382,8 @@ mod tests { #[test] fn supported_subprotocols_lists_full_matrix() { // Guard the literals: they must stay the IETF draft-18-and-newer ALPNs - // (wire 0xff000012 and 0xff000016). - let drafts: Vec<_> = [0xff000012, 0xff000016] + // (wire 0xff000012, 0xff000014, and 0xff000016). + let drafts: Vec<_> = [0xff000012, 0xff000014, 0xff000016] .into_iter() .map(|code| moq_net::Version::from_code(code).unwrap().alpn()) .collect(); @@ -397,7 +397,7 @@ mod tests { assert_eq!(list.first().map(String::as_str), Some(expected_first.as_str())); // Every moq ALPN must appear under every qmux wire version, except the - // illegal `qmux-00.moqt-{18,22}` pairs (moq-transport-18 and newer need qmux-01). + // illegal `qmux-00.moqt-{18,20,22}` pairs (moq-transport-18 and newer need qmux-01). for &version in QMUX_VERSIONS { for &alpn in moq_net::ALPNS { let entry = format!("{}{alpn}", version.prefix()); diff --git a/rs/moq-tokio/src/connect.rs b/rs/moq-tokio/src/connect.rs index 4cc3ed12aed..f252d50f29e 100644 --- a/rs/moq-tokio/src/connect.rs +++ b/rs/moq-tokio/src/connect.rs @@ -216,6 +216,7 @@ pub(crate) struct Legacy { "moq-lite-06", "moq-lite-07-wip", "moq-transport-18", + "moq-transport-20", "moq-transport-22" ), hide = true @@ -617,6 +618,7 @@ pub struct Config { "moq-lite-06", "moq-lite-07-wip", "moq-transport-18", + "moq-transport-20", "moq-transport-22" ) )] diff --git a/rs/moq-tokio/src/listen.rs b/rs/moq-tokio/src/listen.rs index 7f5f6e841a6..a4ac473d50c 100644 --- a/rs/moq-tokio/src/listen.rs +++ b/rs/moq-tokio/src/listen.rs @@ -134,6 +134,7 @@ pub struct Config { "moq-lite-06", "moq-lite-07-wip", "moq-transport-18", + "moq-transport-20", "moq-transport-22" ) )] @@ -319,6 +320,7 @@ pub(crate) struct Legacy { "moq-lite-06", "moq-lite-07-wip", "moq-transport-18", + "moq-transport-20", "moq-transport-22" ), hide = true diff --git a/rs/moq-tokio/src/websocket.rs b/rs/moq-tokio/src/websocket.rs index 7608d2eb04d..8c501fae1e7 100644 --- a/rs/moq-tokio/src/websocket.rs +++ b/rs/moq-tokio/src/websocket.rs @@ -531,7 +531,7 @@ async fn connect_tls_override( /// moq-transport-18 and newer require qmux-01, so we never pair them with qmux-00. /// This mirrors the policy in `js/net`'s `connect.ts`. Every other ALPN returns /// `&[]`, which qmux expands to every draft it knows about. -const QMUX01_ONLY_ALPNS: &[&str] = &["moqt-18", "moqt-22"]; +const QMUX01_ONLY_ALPNS: &[&str] = &["moqt-18", "moqt-20", "moqt-22"]; fn qmux_versions_for(alpn: &str) -> &'static [qmux::Version] { if QMUX01_ONLY_ALPNS.contains(&alpn) { @@ -978,7 +978,7 @@ mod tests { fn moqt_18_and_newer_pin_to_qmux01() { // The literals in `qmux_versions_for` must stay the IETF draft ALPNs; // otherwise the pin silently stops matching. - let drafts: Vec<_> = [0xff000012, 0xff000016] + let drafts: Vec<_> = [0xff000012, 0xff000014, 0xff000016] .into_iter() .map(|code| moq_net::Version::from_code(code).unwrap().alpn()) .collect(); diff --git a/test/interop/ietf-range-updates.ts b/test/interop/ietf-range-updates.ts index 70a45236a9e..9d3e1594306 100644 --- a/test/interop/ietf-range-updates.ts +++ b/test/interop/ietf-range-updates.ts @@ -61,12 +61,12 @@ async function stream() { } let serving: Promise | undefined; try { - if (input.draft === 22) for (let i = 0; i < 4; i++) publishGroup(); + if (input.draft >= 20) for (let i = 0; i < 4; i++) publishGroup(); await client.writer.write(Uint8Array.from(input.subscribe)); assert.equal(await server.reader.u53(), Subscribe.id); serving = publisher.runSubscribe(await Subscribe.decode(server.reader, version), server); await response(4); // SUBSCRIBE_OK - if (input.draft === 22) { + if (input.draft >= 20) { await client.writer.write(Uint8Array.from(input.updates[0])); await response(RequestOk.id); publishGroup(); // Group 4 follows the filled snapshot, still on the original subscription. @@ -81,8 +81,8 @@ try { await client.writer.write(Uint8Array.from(narrowing)); await response(RequestOk.id); // Draft-18 must replay both groups skipped below the old floor, rather than silently - // joining only the newest cached group. Draft-22 also verifies subsequent live delivery. - if (input.draft === 22) for (let i = 5; i < 9; i++) publishGroup(); + // joining only the newest cached group. Draft-20 and later also verify subsequent live delivery. + if (input.draft >= 20) for (let i = 5; i < 9; i++) publishGroup(); for (let i = 0; i < 2; i++) await stream(); } finally { client.close(); diff --git a/test/interop/interop.sh b/test/interop/interop.sh index 32d1102b659..d7b9375b891 100755 --- a/test/interop/interop.sh +++ b/test/interop/interop.sh @@ -80,7 +80,7 @@ FINISH_ONLY=0 # except the clients the harness reads a grant from, which offer $AUTH_VERSION alone. Any other # entry pins every client in its pass to that version, and `ietf` expands to IETF_VERSIONS. VERSIONS="auto" -IETF_VERSIONS="moq-transport-18,moq-transport-22" +IETF_VERSIONS="moq-transport-18,moq-transport-20,moq-transport-22" # Cargo profile for the relay/cli/moq-c builds. Debug compiles faster, which is # what an interop test wants; the workload (320x240@30) is trivial either way. diff --git a/test/interop/interop.toml b/test/interop/interop.toml index d696d7aff77..6e7ef4c7171 100644 --- a/test/interop/interop.toml +++ b/test/interop/interop.toml @@ -19,6 +19,7 @@ version = [ "moq-lite-02", "moq-lite-01", "moq-transport-22", + "moq-transport-20", "moq-transport-18", ]