From 5148abfcc3d39e1267b908207480f726087a3cf8 Mon Sep 17 00:00:00 2001 From: mnovak Date: Wed, 25 Nov 2026 11:26:31 +0100 Subject: [PATCH] [repo] Open point 2: Wolf docs licence, Rust ENet crates, own sans-I/O ENet recommended --- docs/research/open-point-2.md | 96 +++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 docs/research/open-point-2.md diff --git a/docs/research/open-point-2.md b/docs/research/open-point-2.md new file mode 100644 index 0000000..a1b7732 --- /dev/null +++ b/docs/research/open-point-2.md @@ -0,0 +1,96 @@ +# Open point 2: Wolf docs licence, Rust ENet crates, and a clean ENet + +Roadmap open point 2 asks three things before Day 1 code: the licence of the Wolf protocol docs, the licences of the +Rust ENet crates, and whether Moonlight's ENet changes can be met by a clean Rust implementation. +Checked 2026-11-25. Source numbers (S-n) refer to the log in [../CLEAN_ROOM.md](../CLEAN_ROOM.md). + +## 1. Wolf: docs and repo + +| What | Licence | Evidence | +| :-- | :-- | :-- | +| Docs site `games-on-whales.github.io/wolf` | **CC BY-SA 4.0**, "except where otherwise noted" | Footer of every page: "Copyright © ABeltramo and GOW contributors. Except where otherwise noted, docs are licensed under the Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)." ([index](https://games-on-whales.github.io/wolf/stable/protocols/index.html), S-1) | +| Repo `games-on-whales/wolf` | **MIT** | [`LICENSE`](https://github.com/games-on-whales/wolf/blob/beta/LICENSE), GitHub API reports `MIT` (S-8). The docs sources live in the same repo (`docs/modules/protocols/pages/*.adoc`). | + +The two statements overlap: the `.adoc` files sit in an MIT repo, and the rendered site says CC BY-SA 4.0. We take the +stricter one (CC BY-SA 4.0) for the docs. + +What that means for DomiStream (judgment, not legal advice): +- **Facts are free.** Port numbers, field layouts, message codes and algorithms are facts and methods. We can + implement them under CPAL-1.0. +- **Prose and diagrams are not ours to copy.** CC BY-SA content pasted into our docs would make that part + share-alike, and CC BY-SA 4.0 is not compatible with CPAL-1.0. So PROTOCOL.md restates the facts in our own words + and links each section to its Wolf page (attribution is good practice anyway). +- **Example bytes** (the input packet examples) are short functional data needed to interoperate. QA may rebuild + them from the documented field layout instead of copying the example lines; both give the same bytes. + +## 2. Rust ENet crates + +| Crate | Version (date) | Licence | What it is | Fits DomiStream? | +| :-- | :-- | :-- | :-- | :-- | +| [`rusty_enet`](https://github.com/jabuwu/rusty_enet) | 0.4.1 (2026-11-01) | MIT | Stock C ENet transpiled to Rust; caller supplies the `Socket` and a time function (`HostSettings::time`); optional crc32 checksum ([docs.rs](https://docs.rs/rusty_enet/latest/rusty_enet/), S-12) | Licence fits. Socket and time are pluggable, so it can run in memory. But it is transpiled C (pointer-heavy, `unsafe` inside), stock ENet only, and its API is the C host/peer model rather than bytes in/events out. Good as a **test oracle**, weak as the parser of hostile input. | +| [`tokio-enet`](https://github.com/hgaiser/tokio-enet) | 0.1.1 (2026-06-14) | BSD-2-Clause | Pure-Rust ENet, "wire-compatible with the C ENet v1.3.x protocol" ([README](https://github.com/hgaiser/tokio-enet), S-10). **Moonshine uses it for its control stream with Moonlight clients** (S-9). | Licence fits. Bound to tokio sockets and the clock, so not sans-I/O; cannot run on webOS without tokio. Its existence is the strongest evidence for the compatibility question below. | +| [`enet`](https://github.com/futile/enet-rs) | 0.3.0 (2022-03-30) | MIT OR Apache-2.0 | Bindings to the C library through `enet-sys` | Not pure Rust, not sans-I/O, stock ENet. No. | +| [`enet-sys`](https://github.com/ruabmbua/enet-sys) | 1.0.5 (2026-03-16) | MIT | Raw FFI to C ENet | No (C, FFI, stock). | +| [`enet-rs`](https://github.com/ZTzTopia/enet-rs) | 1.3.171 (2021-08-29) | ISC | Bindings for C ENet 1.3.17 | No (C, unmaintained). | +| [`nsys-enet`](https://github.com/spearman/enet-rs) | 0.2.2 (2026-07-07) | Apache-2.0 | Rust interface to C ENet | No (C). | +| [`enet-cs-sys`](https://github.com/Kalkatral/enet-cs-sys) | 0.1.1 (2023-02-25) | MIT | Bindings to ENet-CSharp, a different, incompatible ENet fork | No. | +| [`henet`](https://github.com/dehorsed/henet) | 0.1.0 (published 2026-11-25) | MIT OR Apache-2.0 | "Idiomatic Rust implementation of ENet" | Too new to judge; first release today. | + +All licences above (MIT, Apache-2.0, BSD-2-Clause, ISC) are permissive and fit a CPAL-1.0 project as dependencies. +None of these crates is GPL. None is a port of Moonlight's ENet fork. + +## 3. Can Moonlight's ENet semantics be met by a clean Rust implementation? + +What is documented: +- Wolf: the control stream "runs over UDP via a custom fork of ENET that supports IPV4 and IPV6" and every message + inside is AES-GCM framed ([control](https://games-on-whales.github.io/wolf/stable/protocols/control-specs.html), S-4). + Wolf documents nothing else about the fork: no wire change, no extra command. +- moonlight-common-c README: the client "requires the specific version of ENet that is bundled" and other versions + are "incompatible", with a crash warning against recent GeForce Experience (S-14). It does not say which bytes differ. +- IPv6 support is a socket-address change in the C library. It does not appear on the ENet wire: ENet datagrams + carry no addresses. + +What is measured by others: +- Moonshine (BSD-2) serves real Moonlight clients with `tokio-enet`, a stock ENet 1.3 wire implementation + (S-9, S-10): one peer, `channel_limit 0x30`, every host message sent reliable on channel 0. So **whatever the fork + changes, a stock-1.3 wire host interoperates with Moonlight clients**. + +What is not known (UNKNOWN U9 in PROTOCOL.md): +- whether Sunshine (which ships the fork on the host side) *sends* anything a stock 1.3 peer would reject: a + checksum, a different `connect`/`verify connect` field, a different MTU, window or timeout default; +- which `connect data` value, channel count and MTU a client must offer. + +Settled by our own measurement: a capture of the control channel between a GameStream client and Sunshine on a +lab machine (not Mark's PC), decoded with our own ENet parser. One session is enough to see the handshake fields. + +**Answer: yes.** Nothing documented points at a wire change, and a stock-wire Rust ENet already talks to +Moonlight clients. The fork's differences that matter to us can be found by measurement; we do not need its code. + +### What we write ourselves + +A sans-I/O ENet 1.3 **client** subset in `domistream::enet`, `#![forbid(unsafe_code)]`: + +| Part | Scope | +| :-- | :-- | +| Datagram codec | protocol header (peer id, session bits, compressed flag rejected, optional sent time), command header, all 12 commands; strict lengths, caps (`MAX_DATAGRAM_BYTES` 4096, 32 commands per datagram) | +| Connection | connect, verify connect, disconnect (incl. disconnect-later), ping, timeout | +| Reliability | reliable sequence numbers per channel, acknowledgements, retransmission with RTT-based timeout, reliable window | +| Delivery | reliable, unreliable sequenced, unsequenced, fragments (send + reassembly, capped) | +| Throttle | parse `throttle configure` and `bandwidth limit`; honour the window; no bandwidth shaping beyond that (the control channel is tiny) | +| Not written | host side, many peers, compression (refused), the crc32 checksum (UNKNOWN whether used; refused until measured) | + +About 1,500-2,500 lines with tests. Tests: our client against `rusty_enet` (MIT) as a **dev-dependency** host over an +in-memory socket (no network, deterministic time), plus fuzzing of the datagram codec, plus the lab capture as a +recorded vector once it exists. + +## Recommendation + +1. **Write the ENet client ourselves** (`domistream::enet`, sans-I/O, no unsafe). Do not depend on an ENet crate at + runtime: the only pure-Rust ones are either tokio-bound (`tokio-enet`) or transpiled C (`rusty_enet`), and this + code parses hostile datagrams. +2. **Use `rusty_enet` (MIT) as a dev-dependency** for in-memory interop tests only. +3. **Approve stock ENet (MIT) and tokio-enet (BSD-2) as reference sources** in CLEAN_ROOM.md, because the ENet wire + format is documented nowhere else. Moonlight's fork stays forbidden. +4. **Book one lab capture** (client to Sunshine on a lab machine) to settle U9 and the other measurement-only + unknowns in PROTOCOL.md in one go. It must not be Mark's PC, his Sunshine install or his TV. +5. **Docs licence:** treat the Wolf docs as CC BY-SA 4.0: facts only, our own words, link every section.