[repo] Clean room: allowed and forbidden sources, GPL-provenance rule, source log

This commit is contained in:
2026-11-25 11:26:30 +01:00
parent 526dc80975
commit b53b9e0be1
+73
View File
@@ -0,0 +1,73 @@
# Clean room
DomiStream is a clean-room implementation of the GameStream protocol (the one Moonlight clients and Sunshine hosts
speak). The protocol is written from public protocol notes and our own measurements, never from the code of a
GPL-licensed implementation. This file says what may be read, what may not, and logs every source used.
## Allowed sources
| Source | Licence | How we may use it |
| :-- | :-- | :-- |
| [Wolf protocol docs](https://games-on-whales.github.io/wolf/stable/protocols/index.html) and their sub-pages (pairing/HTTP, RTSP, control, RTP video, RTP Opus, input) | Docs site: CC BY-SA 4.0 "except where otherwise noted"; repo: MIT (see [research/open-point-2.md](research/open-point-2.md)) | Read for facts. Restate facts in our own words with a link. Never paste prose or diagrams. The diagram sources (PlantUML, bytefield, wavedrom) are part of the docs pages and may be read the same way. |
| [Moonshine](https://github.com/hgaiser/moonshine) | BSD-2-Clause | May be read. Facts taken are logged below. Code is not copied; if a snippet is ever borrowed, it keeps Moonshine's copyright line and licence text in the file that holds it. |
| RFCs and standards (RTP RFC 3550, RTSP RFC 2326, SDP RFC 4566, Opus RFC 6716 / RFC 7845, AES FIPS 197, GCM/CBC NIST SP 800-38D/38A, PKCS #1 RFC 8017, X.509 RFC 5280) | open standards | Read freely. |
| Crate docs (docs.rs, crates.io, crate READMEs) | per crate | Read freely. |
| Our own measurements | ours | Captures between our client and a host on a **lab machine** (never Mark's PC, never Mark's TV, never 192.168.100.217). Captures stay out of git; only the facts and test vectors derived from them go in, with the date and setup. |
| READMEs and wikis of forbidden projects | n/a | For facts only (licence, release notes, compatibility statements). Never their source files. |
### Proposed additions (need the build lead's yes before use)
| Source | Licence | Why |
| :-- | :-- | :-- |
| [Stock ENet](https://github.com/lsalzman/enet) (`protocol.h`, `protocol.c`) | MIT | The ENet 1.3 wire format is not documented anywhere else in prose. The Wolf docs do not describe it. |
| [tokio-enet](https://github.com/hgaiser/tokio-enet) source | BSD-2-Clause | A pure-Rust ENet 1.3 used by Moonshine to talk to Moonlight clients. Its `src/protocol/` files were read for the command list (logged below, S-10). |
| [fec-rs](https://github.com/hgaiser/fec-rs) source | BSD-2-Clause | Its README says its field setup is compatible with Moonlight. Reading its matrix construction would settle UNKNOWN U14 (video FEC). |
## Forbidden
Never open, read, paste or port code from: **Sunshine, Moonlight (any client: Qt, Android, iOS, embedded, moonlight-tv),
moonlight-common-c, Moonlight's ENet fork, Apollo, Vibeshine, Rubylight, chiaki** (and forks of them). That also
means their source files on GitHub. Their READMEs and wikis are fine for facts.
### Second-hand GPL facts
Moonshine credits Sunshine for "groundwork" on the host side, and a few Moonshine comments cite Sunshine or
moonlight-common-c as the origin of a value. We treat such a value as **GPL-provenance**: it is logged, never
copied into DomiStream, and settled by our own measurement instead. Known cases:
| Where in Moonshine | What | What we do |
| :-- | :-- | :-- |
| `src/session/stream/audio/encoder.rs` | the fixed 2x4 Reed-Solomon parity matrix for audio FEC; the comment cites a moonlight-common-c file | Not taken. I saw the constant while reading the file; it is not in this repo. U16 in [PROTOCOL.md](PROTOCOL.md) says how to measure it ourselves. |
| `src/session/stream/control/mod.rs` | HDR mode payload "matches Sunshine's" struct | Field layout logged as `[M*]`, confirm by measurement before relying on it |
| `src/rtsp.rs` | `surround-params` digit packing "matching moonlight-common-c" | The Wolf example `surround-params=21101` gives the same packing independently, so we use the Wolf source |
## How code gets written
1. Every fact in [PROTOCOL.md](PROTOCOL.md) carries a source tag that points to the log below.
2. A fact without a tag is UNKNOWN until a log entry or a measurement backs it.
3. Code comments cite the PROTOCOL.md section, not the outside source directly.
4. Anything borrowed (more than a fact) is attributed in the file that holds it and listed here.
5. A PR that adds a source adds a row to the log in the same PR.
## Source log
All entries by the DomiStream protocol engineer. Pinned commits are the ones read.
| # | Date | Source | What was taken |
| :-- | :-- | :-- | :-- |
| S-1 | 2026-11-25 | [Wolf: protocols index](https://games-on-whales.github.io/wolf/stable/protocols/index.html) | The six protocols, their default ports, which are encrypted (control AES-GCM 128, audio AES-CBC 128, video plain), that ports other than HTTP/S are dynamic. Licence footer (CC BY-SA 4.0). |
| S-2 | 2026-11-25 | [Wolf: HTTP/S pairing](https://games-on-whales.github.io/wolf/stable/protocols/http-pairing.html) incl. its PlantUML diagram sources | Phases 1-5; AES key from SHA-256(salt + PIN); the hash inputs of phase 2 and phase 4; field names `plaincert`, `challengeresponse`, `serverchallengeresp`, `pairingsecret`, `pairchallenge`, `paired`; phase 5 runs over HTTPS with the client certificate. |
| S-3 | 2026-11-25 | [Wolf: RTSP](https://games-on-whales.github.io/wolf/stable/protocols/rtsp.html) incl. diagram | Method order OPTIONS, DESCRIBE, SETUP (audio, video, control), ANNOUNCE, PLAY; message layout (start line, `CSeq`, options, empty line, payload); example `X-GS-ClientVersion: 14`, `a=fmtp:97 surround-params=21101`. |
| S-4 | 2026-11-25 | [Wolf: control](https://games-on-whales.github.io/wolf/stable/protocols/control-specs.html) incl. bytefield sources | ENet fork with IPv4 + IPv6; encrypted frame `type 0x0001 / len / seq / 16-byte tag / payload`, little-endian, seq used for the IV; message type codes; payloads of rumble, rumble triggers, motion event, RGB LED. |
| S-5 | 2026-11-25 | [Wolf: RTP video](https://games-on-whales.github.io/wolf/stable/protocols/rtp-video.html) incl. diagrams | PING to the negotiated port; packetSize default 1024 + 16-byte RTP header; 16-byte NV video header layout; flags (picture data 1, EOF 2, SOF 4); 8-byte frame prefix `01 37 63 68 61 72 73 73`; FEC example (4 KB, 1024, 50 % = 4 + 2); parity packets have flags 0; IDR requests over control. |
| S-6 | 2026-11-25 | [Wolf: RTP Opus](https://games-on-whales.github.io/wolf/stable/protocols/rtp-opus.html) incl. diagrams | 12-byte RTP header; 12-byte FEC header (shard index, payload type, base seq, base timestamp, SSRC); 4 data + 2 parity; AES-CBC with key and IV from the launch call, same key as control; PING. |
| S-7 | 2026-11-25 | [Wolf: input](https://games-on-whales.github.io/wolf/stable/protocols/input-data.html) incl. bytefield sources | INPUT_DATA layout (size BE, type LE); input type codes; layouts and example bytes for mouse move rel/abs, buttons, keys, scroll, hscroll, controller arrival, controller multi; key code table; button flags; controller types and capability bits. |
| S-8 | 2026-11-25 | GitHub API for [games-on-whales/wolf](https://github.com/games-on-whales/wolf) (`/repos`, `/git/trees/beta`, `LICENSE`, `docs/README.adoc`) | Repo licence MIT; the docs live in `docs/modules/protocols/pages/*.adoc` of the same repo; latest tag `v2026.11`. No source files of Wolf were read. |
| S-9 | 2026-11-25 | [Moonshine](https://github.com/hgaiser/moonshine) at `f184d5e3693e09c3a6ab1025bde6cdb67f36a6bc`: `LICENSE`, `README.md`, `Cargo.toml`, `src/clients.rs`, `src/crypto.rs`, `src/webserver/pairing.rs`, `src/webserver/mod.rs`, `src/rtsp.rs`, `src/session/stream/control/mod.rs`, `src/session/stream/audio/{mod,encoder}.rs`, `src/session/stream/video/{mod,packetizer,shard_batch}.rs` | Facts tagged `[M]` in PROTOCOL.md: pairing query names, AES-128-ECB, key = first 16 bytes of SHA-256(salt + PIN), 16-byte salt/challenge/secret, RSA PKCS#1 v1.5 SHA-256, "certificate signature" = X.509 signatureValue bytes; serverinfo, applist and launch XML and query fields; SDP attribute names, SETUP reply headers, encryption flag bits; control IV layout and direction bytes, START_B starts the streams, INVALIDATE_REF_FRAMES and termination layouts, ENet host settings; audio IV, payload types 97/127, millisecond timestamps; video RTP/NV header byte layout, FEC bit fields and block split, video encryption prefix and IV; `PING` payload. Moonshine depends on `tokio-enet` for the control channel. |
| S-10 | 2026-11-25 | [tokio-enet](https://github.com/hgaiser/tokio-enet) at `364628ed754760c99e0df7bcc88e479ad91475c4`: `README.md`, `CHANGELOG.md`, `src/protocol/{mod,header,commands}.rs` | Claims wire compatibility with C ENet 1.3.x, BSD-2; ENet command numbers 1-12, command sizes, header flags (compressed 1<<14, sent time 1<<15, session bits 12-13), 4-byte command header, big-endian fields. Pending approval as an allowed source (see above). |
| S-11 | 2026-11-25 | crates.io API for `enet`, `enet-rs`, `nsys-enet`, `rusty_enet`, `tokio-enet`, `enet-sys`, `henet`, `enet-cs-sys`, `fec-rs`, `reed-solomon-erasure` and the RustCrypto crates | Licences, versions, repositories (see research/open-point-2.md and the Cargo manifest). |
| S-12 | 2026-11-25 | [docs.rs: rusty_enet](https://docs.rs/rusty_enet/latest/rusty_enet/) | Transpiled from C ENet; caller-supplied `Socket` trait and `HostSettings::time`; optional crc32 checksum; MIT. |
| S-13 | 2026-11-25 | [fec-rs README](https://github.com/hgaiser/fec-rs) | GF(2^8) with polynomial 0x1D (0x11D), "compatible with the Moonlight streaming protocol", reconstruction supported, BSD-2. |
| S-14 | 2026-11-25 | [moonlight-common-c README](https://github.com/moonlight-stream/moonlight-common-c) (README only) | Needs its bundled ENet; other ENet versions are incompatible; GPL-3.0. |
| S-15 | 2026-11-25 | [cgutman/enet](https://github.com/cgutman/enet) repository page (description only) | Forked from lsalzman/enet, has a `moonlight` branch. No files opened. |
| S-16 | 2026-11-25 | Roadmap brief §3.2 ([moonlight-android releases](https://github.com/moonlight-stream/moonlight-android/releases)) | Moonlight Android 12.1 added end-to-end stream encryption with Sunshine. |