diff --git a/docs/CLEAN_ROOM.md b/docs/CLEAN_ROOM.md index 1290647..24120d4 100644 --- a/docs/CLEAN_ROOM.md +++ b/docs/CLEAN_ROOM.md @@ -80,3 +80,4 @@ All entries by the DomiStream protocol engineer. Pinned commits are the ones rea | S-18 | 2026-11-25 | [fec-rs](https://github.com/hgaiser/fec-rs) at `402f41f970bb8c3ef7c88639821032e3b6460f63`: `LICENSE`, `README.md`, `build.rs` (field tables), `src/galois.rs` (`exp`), `src/matrix.rs` (`vandermonde`), `src/reed_solomon.rs` (`build_matrix`, `new`) | BSD-2. Field GF(2^8) with polynomial 0x11D, generator 2; systematic code whose parity rows are the Cauchy matrix `P[j][i] = 1 / ((m + i) XOR j)`. Its tests also contain the GPL-provenance audio matrix (not taken). | | S-19 | 2026-11-25 | GitHub release API: [Moonlight PC v6.2.0](https://api.github.com/repos/moonlight-stream/moonlight-qt/releases/latest), [Sunshine v2026.914.233613](https://api.github.com/repos/SunshineStream/Sunshine/releases/tags/v2026.914.233613) | Asset names, sizes and sha256 digests for the lab capture pins. Release metadata only. | | S-20 | 2026-11-25 | ArenaTV `docs/research/sunshine-api.md` and `docs/research/this-pc.md` (Domi's own research from LizardByte's docs) | Sunshine's API calls, `--creds`, `bind_address`, port offsets, first-run behaviour, this PC's adapters and old install. | +| S-21 | 2026-11-30 | [Moonshine](https://github.com/hgaiser/moonshine) at `f184d5e` (same pin as S-9): `src/session/stream/control/mod.rs` again (client message parsing and the control loop), `src/session/stream/mod.rs` (`StreamConfig`), `src/session/stream/video/mod.rs` (PING handling), `src/config.rs` (nothing relevant); the repository tree listing | BSD-2. U10, as facts only: the host reads **no body** from START_B (0x0307), Ping (0x0200), LOSS_STATS, FRAME_STATS or the IDR request; START_A (0x0305) is not a type it knows; inside the encrypted frame an unknown type or a failed decryption is skipped, outside it an unknown type or a bad length ends the session; INVALIDATE_REF_FRAMES `first`/`last` at message bytes 4..8 and 12..16 (LE), short bodies mean "from 0"; each Ping resets a stop deadline, `StreamConfig.timeout` default 60 s; the client-to-host IV is `seq LE ‖ 6 zero ‖ 'C' 'C'`; host messages go reliable on channel 0; the video receiver waits for START_B and takes exactly the 4 bytes `PING`, each PING updating the client address. No value in these parts cites Sunshine or moonlight-common-c (the HDR payload's Sunshine note is the known S-9 case). Used for the probe's default bodies (all empty) and the PROTOCOL.md 3.3 facts. | diff --git a/docs/LIVE-INTEROP.md b/docs/LIVE-INTEROP.md index 659d074..ed168f8 100644 --- a/docs/LIVE-INTEROP.md +++ b/docs/LIVE-INTEROP.md @@ -4,7 +4,9 @@ Status: **prepared 2026-11-30, not run.** The probe (`tools/gs-probe`) is built to a host: no Sunshine existed when it was written. This sitting settles the open UNKNOWNs of [PROTOCOL.md](PROTOCOL.md) §8 live, in one go, and answers the black-box -checks of Arena `docs/PLAY-REMOTELY.md` §8 and §17 that a GameStream client can answer. The host is the pinned Sunshine +checks a GameStream client can answer from Arena `docs/PLAY-REMOTELY.md`. That list lives in its handover ("Next on +RESUME", item 3), §8 (the `pairing_id` call, the clients list) and §15 (the test-PC checks); §17 is the installer +spec and is not part of this sitting. The host is the pinned Sunshine `v2026.914.233613`, installed by arena-host at Turn on to `E:\Apps\Sunshine` and bound to `192.168.100.140`. The client is our probe, which runs DomiStream `stream-v0.1.0`'s state machines over real sockets from this PC. No Moonlight, no TV and no other machine take part. @@ -44,7 +46,7 @@ Moonlight, no TV and no other machine take part. - **Arena Domi's own first-stream toast** (PLAY-REMOTELY §7.4). It can appear if the Arena window is running when Sunshine's prep-cmd hook reports the probe's stream. Mark dismisses it. - **Mark's part:** be present, agree on the game for `launch` beforehand (a light one from the `apps` list), and keep - hands off mouse and keyboard while the stream runs (about 30 s per launch). + hands off mouse and keyboard while the stream runs (90 s for the first launch, about 30 s for any variant). ## 2. Before the sitting (without Mark) @@ -52,8 +54,8 @@ Moonlight, no TV and no other machine take part. | :-- | :-- | :-- | | P1 | Probe built | `cd tools\gs-probe`, `CARGO_BUILD_BUILD_DIR=F:\build\play-remotely\cargo-build-probe`, `TEMP`/`TMP=F:\build\play-remotely\tmp\protocol`, load gate (CPU and RAM < 90 %, D: and F: < 95 %), then `cargo test --offline -j 2` and `cargo build --offline --release -j 2`. Binary: `tools\gs-probe\target\release\probe.exe`. | | P2 | Sunshine as arena-host left it (read-only) | `Get-NetTCPConnection -State Listen \| ? LocalPort -in 47984,47989,47990,48010` shows each on `192.168.100.140` only: nothing on `0.0.0.0` or loopback on Day 1 (PLAY-REMOTELY §4). `Get-NetUDPEndpoint \| ? LocalPort -in 47998,47999,48000` is empty while idle (PLAY-REMOTELY §9). | -| P3 | **Open: a way to call Sunshine's API without seeing the credentials** | Needed for the PIN (step S2) and checks B1–B3. Agents never type passwords, and Mark should see nothing, so the build lead picks before the sitting: **(a, recommended)** a dev-only arena-host entry point `sunshine-api [json]` that takes the credentials from Custos, calls `https://192.168.100.140:47990` with arena-host's pinned client (§3, §4) and prints the answer with secrets redacted (its first call also answers §15's "does `pc` cover a self-connection to .140"); **(b)** Sunshine's own web UI in our browser pane, logged in by Mark (he would see it); **(c)** none, and the sitting ends after S1. This file writes the calls as `sunshine-api …`. | -| P4 | U10 bodies | Read Moonshine's control handler (BSD-2, allowed, [M]) for what a host reads from START_A, START_B and PERIODIC_PING. Write the candidate bodies into table V (section 3) **before** the sitting. If Moonshine ignores the bodies, empty bodies (the probe's default) are the first try. Never from GPL sources. | +| P3 | Sunshine's API without seeing the credentials (**decided: a**, build lead 2026-11-30) | Needed for the PIN (step S2) and checks B1–B3. The host engineer writes a dev-only `sunshine-api [json]` command in arena-host (Play remotely's own crate), behind a cargo feature that never ships. It takes the credentials from Custos (never typed, printed or logged), calls `https://192.168.100.140:47990` with arena-host's pinned client (§3, §4) and prints the answer with secrets redacted. Its first call also answers §15's "does `pc` cover a self-connection to .140". It must be built and checked before the sitting; this file writes the calls as `sunshine-api …`. | +| P4 | U10 bodies (**done** 2026-11-30, CLEAN_ROOM S-21) | Moonshine (BSD-2) reads **no body** from START_B, PERIODIC_PING or the IDR request, ignores LOSS_STATS and FRAME_STATS, and does not know START_A. Inside the encrypted frame, an unknown type is skipped, not fatal. Each PERIODIC_PING pushes its stop deadline out (60 s by default). Nothing taken has GPL provenance. The probe's defaults follow: START_A and START_B empty, PERIODIC_PING empty every 500 ms, an empty IDR request on frame loss. Table V holds what to try if Sunshine differs. | | P5 | Game | Agree the `launch` game with Mark (a light one) and note its app id after S4. | Shell variables used below (PowerShell): @@ -121,7 +123,10 @@ Each step names the command, the UNKNOWNs it settles and what to look for. "Log" - **Settles:** nothing new. It confirms HTTPS with the pinned certificate (U24 again). - **Look for:** the agreed game's id (P5); `Desktop`, if listed, is the fallback. -### S4. `& $P launch --host $H --out $O --seconds 30 --nudge-mouse` +### S4. `& $P launch --host $H --out $O --seconds 90 --nudge-mouse` + +90 s outlasts Moonshine's 60 s no-ping deadline. A stream that lives to the end shows Sunshine accepts the default +empty PERIODIC_PING, or does not need one within 90 s; `sunshine.log` tells which (U10). Variants use `--seconds 30`. - **Mark sees** the game start. - **Settles:** @@ -147,7 +152,8 @@ Each step names the command, the UNKNOWNs it settles and what to look for. "Log" | `rtsp.announce` | U6 | 200 means our 19 attributes are accepted as they are | | `ping` + `video.first` / `audio.first` | U8 | Payload `PING`; `pings_before` and the source port of the first packet | | `control.datagram` (first 64 each way) | U9 | Decoded ENet: our connect, the host's verify connect (channel count, MTU, window, flags), anything stock 1.3 lacks (`unparsed: …` or `parse_error`) | - | `control.start_a`, `control.start_b` | U10 | What we sent. Video then flowing means the host accepted it | + | `control.start_a`, `control.start_b` | U10 | What we sent (empty bodies by default). Video then flowing means the host accepted it | + | `control.periodic_ping` (first 3), `launch.summary` `control.ended` | U10 | The empty ping every 500 ms; `ended` null after 90 s means the pings kept the session alive | | `control.host` | U10, U11, U23 | Every decrypted host message: type, sequence, body | | `video.frame` (first 16) | U13 | `header_raw`: Wolf's constant `0137636861727373` or Moonshine's fields | | `launch.summary` | U14 | `u14_*`: whole-packet parity matches (5.3 confirmed), or payload-only, or neither | @@ -178,10 +184,11 @@ most 6 launches in the sitting, and the same variant is never tried twice. | Symptom (log) | Variant | | :-- | :-- | | ANNOUNCE not 200 (U6) | `--encryption 1`, then `--codec hevc`, then `--packet-size 1392`. Attribute values beyond the CLI need a code change: stop and report | -| No verify connect, ENet `timed_out` (U9) | `--enet-channels 48`, then `--enet-connect-data ` | -| Connected but no video within 5 s of START_B (U10) | The bodies from P4 (`--start-a`/`--start-b `), one pair per launch | -| Video stops after N s, host disconnects (U10) | `--periodic-ping --periodic-ping-ms 100` | -| Frames lost and never recovered (U10) | `--rfi`, if DESCRIBE has `refPicInvalidation`; else `--idr ` | +| No verify connect, ENet `timed_out` (U9) | `--enet-channels 48`. Nothing else is known about the connect fields: stop and report | +| Connected, but the host ends the session right after START_A, or `sunshine.log` names an unknown control message (U10) | `--start-a none` (Moonshine has no START_A) | +| Connected but no video within 5 s of START_B (U10) | Read `sunshine.log` for what it says about START_B. If it names a body or a length, give that body with `--start-b ` (one try). Otherwise stop and report: P4 found no body, and none is guessed | +| Video stops after N s, host disconnects (U10) | `--periodic-ping-ms 100`; if it still stops, `--periodic-ping none` (to see whether the empty ping is what the host refuses), then stop and report | +| Frames lost and never recovered (U10) | `--rfi`, if DESCRIBE has `refPicInvalidation`; else `--idr none`, to compare with the default empty request | | Surround (U26), only if time allows | `--audio 5.1` | ### S5. U28, a refused pairing (optional, 2 min) @@ -261,8 +268,8 @@ One JSON object per line, flushed as written: gate first). 5. **Re-run the probe** against Sunshine with the patched crate: `launch` with **no** variant flags must give `decode_ready_frames > 0`, audio packets, and no `stop`. Then release `stream-v0.1.1` (HANDOVER). -6. **Arena:** B1–B5 answers go to Arena `docs/PLAY-REMOTELY.md` §8/§15/§17, through the Arena build lead (Arena's - files are theirs). +6. **Arena:** B1–B5 answers go to Arena `docs/PLAY-REMOTELY.md` (handover, §8, §15). That file and arena-host are Play + remotely's own, so we write them; the seam files stay the Arena build lead's. **Not settled by the probe:** - U20, U21, U22: no keyboard, touch or gamepad input beyond the one mouse nudge. @@ -311,7 +318,7 @@ Then wait. | :-- | :-- | :-- | | 0:00 | S0, S1: read-only checks, `serverinfo` | nothing | | 0:02 | S2: the probe pairs (we submit the PIN through Sunshine's API). Sunshine may show a notification | nothing | -| 0:05 | S3, S4: the agreed game starts on his PC and streams to the probe for 30 s; then we close it | hands off mouse and keyboard while it runs | +| 0:05 | S3, S4: the agreed game starts on his PC and streams to the probe for 90 s; then we close it | hands off mouse and keyboard while it runs | | 0:07-0:15 | Variants, only if needed (up to 6 launches, each about 1 min) | same | | 0:15 | S5 (optional), clean-up | nothing | | later | Analysis offline; the game frames are deleted | nothing | diff --git a/docs/PROTOCOL.md b/docs/PROTOCOL.md index 088fab8..220e9a4 100644 --- a/docs/PROTOCOL.md +++ b/docs/PROTOCOL.md @@ -298,13 +298,13 @@ Every control message is wrapped [W4] (little-endian): | Type | Name | Direction | Body | | :-- | :-- | :-- | :-- | -| 0x0305 | START_A | client → host | UNKNOWN U10 | -| 0x0307 | START_B | client → host | UNKNOWN U10. The host starts video and audio when it arrives [M] | -| 0x0200 | PERIODIC_PING | client → host | UNKNOWN U10. Keeps the session alive; the host stops after a timeout without one [M] | -| 0x0201 | LOSS_STATS | client → host | UNKNOWN U10 | -| 0x0204 | FRAME_STATS | client → host | UNKNOWN U10 | +| 0x0305 | START_A | client → host | UNKNOWN U10. Moonshine has no such type; inside the encrypted frame it skips an unknown type [M] | +| 0x0307 | START_B | client → host | Moonshine reads no body [M]. The host starts video and audio when it arrives [M]; Moonshine's video receiver (and so its PING handling) only runs from then on [M] | +| 0x0200 | PERIODIC_PING | client → host | Moonshine reads no body [M]. Each one pushes the host's stop deadline out; Moonshine stops a stream after 60 s without one (its default) [M] | +| 0x0201 | LOSS_STATS | client → host | Moonshine ignores it [M]; body UNKNOWN U10 | +| 0x0204 | FRAME_STATS | client → host | Moonshine ignores it [M]; body UNKNOWN U10 | | 0x0206 | INPUT_DATA | client → host | section 4 | -| 0x0302 | IDR_FRAME (request) | client → host | UNKNOWN U10 (Moonshine ignores the body) | +| 0x0302 | IDR_FRAME (request) | client → host | Moonshine reads no body [M] | | 0x0301 | INVALIDATE_REF_FRAMES | client → host | `first u32`, `reserved u32`, `last u32`, `reserved 12 bytes`, LE [M] | | 0x0100 | TERMINATION | host → client | UNKNOWN U10 | | 0x0109 | TERMINATION (extended) | host → client | `error_code u32 BE`; `0x80030023` = graceful [M] | @@ -317,6 +317,11 @@ Every control message is wrapped [W4] (little-endian): UNKNOWN U23: Wolf states "all data is little-endian" for the frame; we assume LE for the host event bodies too. +How Moonshine treats what a client sends on control [M]: a message whose type it does not know, or whose length field +does not match, **ends the session** when it arrives outside the encrypted frame; inside the encrypted frame the same +message is skipped, and so is a frame that fails decryption. Whether Sunshine reads bodies (and which) is what U10 +still settles live: the probe sends empty bodies first ([LIVE-INTEROP.md](LIVE-INTEROP.md), table V). + --- ## 4. Input and gamepad packets @@ -569,7 +574,7 @@ client and Sunshine on a lab machine, not Mark's PC, his Sunshine or his TV); th | U7 | Extra headers in SETUP replies | B | capture | | U8 | UDP ping payload and repeat interval | B | capture | | U9 | Narrowed (3.1): only what Sunshine's ENet may add when *sending*; the client's channel count, MTU, connect data | B | capture, decode with our parser | -| U10 | Bodies of START_A, START_B, PERIODIC_PING, LOSS_STATS, FRAME_STATS, IDR request, TERMINATION; ping interval | B | capture, decrypted with the session's `rikey` | +| U10 | Narrowed (3.3): Moonshine reads no body from START_B, PERIODIC_PING or the IDR request and ignores START_A, LOSS_STATS and FRAME_STATS; what Sunshine reads, the ping interval it needs, TERMINATION's body | B | live sitting: empty bodies first, then the hex variants | | U11 | First control sequence number; host's replay rules | | capture | | U13 | Video frame header: Wolf's constant or Moonshine's fields | | capture | | U14 | Video RS matrix: **settled** (5.3, Cauchy from fec-rs) | | capture confirms: our parity = captured parity | diff --git a/tools/gs-probe/src/args.rs b/tools/gs-probe/src/args.rs index 1345e79..e18aab6 100644 --- a/tools/gs-probe/src/args.rs +++ b/tools/gs-probe/src/args.rs @@ -38,9 +38,10 @@ launch: --ping-ms 500 (UDP ping to the video and audio ports) --enet-channels 1 --enet-mtu 1392 --enet-connect-data 0 --control-channel 0 --first-control-seq 0 + Control message bodies (U10; defaults from Moonshine, which reads no body from any of them, PROTOCOL.md 3.3): --start-a empty --start-b empty - --periodic-ping off --periodic-ping-ms 100 - --idr off (body of an IDR request sent on frame loss) + --periodic-ping empty --periodic-ping-ms 500 + --idr empty (IDR request on frame loss, unless --rfi and the host offers invalidation) --nudge-mouse send one relative mouse move +1/-1 after the first decodable frame "; @@ -157,9 +158,9 @@ impl Default for Options { first_control_seq: 0, start_a: Body::Bytes(Vec::new()), start_b: Body::Bytes(Vec::new()), - periodic_ping: Body::None, - periodic_ping_ms: 100, - idr: Body::None, + periodic_ping: Body::Bytes(Vec::new()), + periodic_ping_ms: 500, + idr: Body::Bytes(Vec::new()), nudge_mouse: false, } } @@ -375,7 +376,12 @@ mod tests { assert_eq!((o.width, o.height, o.fps, o.bitrate_kbps, o.packet_size), (1920, 1080, 60, 20_000, 1024)); assert_eq!((o.encryption, o.seconds, o.enet_channels, o.enet_mtu), (7, 20, 1, 1392)); assert_eq!(o.start_a, Body::Bytes(vec![])); - assert_eq!(o.periodic_ping, Body::None); + // U10 candidates (PROTOCOL.md 3.3): every body empty, a ping every 500 ms. + assert_eq!( + (o.start_b, o.periodic_ping, o.idr), + (Body::Bytes(vec![]), Body::Bytes(vec![]), Body::Bytes(vec![])) + ); + assert_eq!(o.periodic_ping_ms, 500); assert!(!o.wrong_pin && !o.nudge_mouse && !o.rfi); } @@ -406,11 +412,11 @@ mod tests { #[test] fn launch_options_parse_and_are_ranged() { let o = ok("launch 1 --host ::1 --out o --mode 1280x720x30 --codec hevc --audio 5.1 --seconds 600 \ - --start-b 0a0B --start-a none --idr empty --enet-channels 48 --control-channel 47 --hdr --rfi") + --start-b 0a0B --start-a none --idr none --enet-channels 48 --control-channel 47 --hdr --rfi") .options; assert_eq!((o.width, o.height, o.fps), (1280, 720, 30)); assert_eq!((o.codec, o.audio), (VideoCodec::Hevc, AudioLayout::Surround51)); - assert_eq!((o.start_a, o.start_b, o.idr), (Body::None, Body::Bytes(vec![0x0a, 0x0b]), Body::Bytes(vec![]))); + assert_eq!((o.start_a, o.start_b, o.idr), (Body::None, Body::Bytes(vec![0x0a, 0x0b]), Body::None)); assert!(o.hdr && o.rfi); assert!(err("launch 1 --host ::1 --out o --seconds 601").contains("outside")); assert!(err("launch 1 --host ::1 --out o --encryption 8").contains("outside")); diff --git a/tools/gs-probe/src/stream.rs b/tools/gs-probe/src/stream.rs index 0d678ae..9df67a7 100644 --- a/tools/gs-probe/src/stream.rs +++ b/tools/gs-probe/src/stream.rs @@ -35,7 +35,9 @@ use crate::fec::{VideoFecCheck, VideoOutcome}; use crate::log::{J, Kind, Log, bytes, hex}; use crate::{Ctx, rtsp}; -/// Control message types the probe sends with command-line bodies (PROTOCOL.md 3.3). +/// Control message types the probe sends with command-line bodies (PROTOCOL.md 3.3). The default bodies are empty: +/// Moonshine reads no body from START_B, PERIODIC_PING or the IDR request and skips an unknown type such as START_A +/// inside the encrypted frame (U10, [M] S-21); Sunshine is settled live. const START_A: u16 = 0x0305; const START_B: u16 = 0x0307; const PERIODIC_PING: u16 = 0x0200; @@ -1135,6 +1137,57 @@ mod tests { assert!(raw_message(IDR_REQUEST, &vec![0; 70_000]).is_none()); } + /// The U10 candidates the probe sends by default, as plaintext messages: a bare 4-byte header each, which is + /// what Moonshine's parser accepts (length field = bytes after the header). + #[test] + fn default_candidates_are_bare_headers() { + let o = Options::default(); + let cases = [ + (START_A, &o.start_a, [0x05, 0x03, 0x00, 0x00]), + (START_B, &o.start_b, [0x07, 0x03, 0x00, 0x00]), + (PERIODIC_PING, &o.periodic_ping, [0x00, 0x02, 0x00, 0x00]), + (IDR_REQUEST, &o.idr, [0x02, 0x03, 0x00, 0x00]), + ]; + for (t, body, want) in cases { + let m = raw_message(t, body_of(body).unwrap()).unwrap(); + assert_eq!(m, want); + let parsed = parse_message(&m).unwrap(); + assert_eq!((parsed.message_type, parsed.body.len()), (t, 0)); + } + } + + /// Sealed with a test key, each candidate is the documented encrypted frame (PROTOCOL.md 3.2): type 0x0001, + /// length 4 + 16 + 4, the sequence LE, tag, 4 bytes of ciphertext; the nonce is Moonshine's client-to-host IV + /// (sequence LE, six zeros, 'C', 'C'). + #[test] + fn sealed_candidates_follow_the_frame_layout() { + use domistream::control::frame::nonce; + let cipher = ControlCipher::new([0x11; 16]); + for (seq, t) in [(0u32, START_A), (1, START_B), (2, PERIODIC_PING), (0x0102_0304, IDR_REQUEST)] { + let plain = raw_message(t, &[]).unwrap(); + let frame = cipher.seal(seq, Direction::ClientToHost, &plain).unwrap(); + assert_eq!(frame.len(), 28); + assert_eq!(frame[..4], [0x01, 0x00, 24, 0x00]); + assert_eq!(frame[4..8], seq.to_le_bytes()); + assert_eq!(cipher.open(Direction::ClientToHost, &frame).unwrap(), (seq, plain)); + let mut iv = [0u8; 12]; + iv[..4].copy_from_slice(&seq.to_le_bytes()); + iv[10] = b'C'; + iv[11] = b'C'; + assert_eq!(nonce(seq, Direction::ClientToHost).unwrap(), iv); + } + } + + /// The crate's INVALIDATE_REF_FRAMES (sent with --rfi) puts `first` and `last` where Moonshine reads them: + /// message bytes 4..8 and 12..16, little-endian. + #[test] + fn invalidate_ref_frames_layout() { + let m = encode_client_message(&ClientMessage::InvalidateRefFrames { first: 7, last: 0x0A0B_0C0D }).unwrap(); + assert_eq!(m[..2], [0x01, 0x03]); + assert_eq!(m[4..8], 7u32.to_le_bytes()); + assert_eq!(m[12..16], 0x0A0B_0C0Du32.to_le_bytes()); + } + #[test] fn clock_conversions_round_trip() { let epoch = StdInstant::now();