[domistream] Host: ENet accepting side and control host #11

Merged
mnovak merged 7 commits from feature/host-enet-control into main 2026-12-04 12:48:09 +01:00
Owner

Lumen L1, host side of the control channel: enet::host (the accepting side of the ENet-1.3-compatible layer, one peer per client address, the caller demultiplexes) and control::host (AES-GCM client frames with the 'C' nonce and replay refusal, typed client messages, host messages, a stop deadline), tests first. PROTOCOL.md 3.1 gains "The accepting side", 3.3 a host-side paragraph.

  • EnetHostPeer: accept/verify connect, session ids, MTU/window/channel clamping, reliable/unreliable/unsequenced channels, 64 KiB fragments, acks, pings, retransmission, timeouts, disconnect both ways (queued packets flushed first). Not implemented: checksum, compression, host-side throttling, unreliable fragments (dropped).
  • ControlHost: StartB, PeriodicPing, Input (via input::parse_input), IdrRequest, InvalidateRefFrames, Loss/FrameStats raw, Unknown skipped; sends rumble, trigger rumble, motion, RGB LED, extended termination. HDR_MODE returns Unsupported: its layout is GPL-provenance [M*] until measured.
  • Found in the client (not changed here): EnetClient stores the verify's session ids the other way round from stock ENet; harmless while both are equal (our case). Follow-up: a one-line fix with a test in a client PR.

Evidence: 55 new tests (our EnetClient/ControlStream against the host over an in-memory wire with loss, duplication, reorder and simulated time; 16-bit wrap with 66,000 packets each way; replay/forgery/reflection dropped; properties). Rebased on PRs #9 and #10: 364 passed / 0 failed; clippy and fmt clean. Fuzz: enet_host 2,534,001 runs / 60 s and 26,839,291 runs / 600 s, control_host 611,513 runs / 60 s, 0 crashes.

Clean-room checklist

  • Sources read: stock ENet v1.3.18 2662c0d host-side functions of protocol.c and enet.h window constants (MIT, approved; S-34). Earlier facts S-10, S-17, S-21.
  • No Moonlight ENet fork, no GPL source; no [M*] value used (HDR_MODE refused).
  • Constants trace to PROTOCOL.md 3.x and stock ENet.
  • Public repo: nothing private.

Self-review: rebase conflicts were append-only (fuzz bins, source log rows; both kept). Checked that unknown/malformed frames inside the encrypted frame are skipped and outside are dropped, as 3.3 says; the duplicated receive/retransmit code (host vs client) is a known follow-up, not a defect. U9/U10/U11/U21/U23 open questions are listed for the black-box measurement.

Lumen L1, host side of the control channel: `enet::host` (the accepting side of the ENet-1.3-compatible layer, one peer per client address, the caller demultiplexes) and `control::host` (AES-GCM client frames with the 'C' nonce and replay refusal, typed client messages, host messages, a stop deadline), tests first. PROTOCOL.md 3.1 gains "The accepting side", 3.3 a host-side paragraph. - `EnetHostPeer`: accept/verify connect, session ids, MTU/window/channel clamping, reliable/unreliable/unsequenced channels, 64 KiB fragments, acks, pings, retransmission, timeouts, disconnect both ways (queued packets flushed first). Not implemented: checksum, compression, host-side throttling, unreliable fragments (dropped). - `ControlHost`: StartB, PeriodicPing, Input (via `input::parse_input`), IdrRequest, InvalidateRefFrames, Loss/FrameStats raw, Unknown skipped; sends rumble, trigger rumble, motion, RGB LED, extended termination. **HDR_MODE returns `Unsupported`**: its layout is GPL-provenance [M*] until measured. - Found in the client (not changed here): `EnetClient` stores the verify's session ids the other way round from stock ENet; harmless while both are equal (our case). Follow-up: a one-line fix with a test in a client PR. Evidence: 55 new tests (our `EnetClient`/`ControlStream` against the host over an in-memory wire with loss, duplication, reorder and simulated time; 16-bit wrap with 66,000 packets each way; replay/forgery/reflection dropped; properties). Rebased on PRs #9 and #10: 364 passed / 0 failed; clippy and fmt clean. Fuzz: `enet_host` 2,534,001 runs / 60 s and 26,839,291 runs / 600 s, `control_host` 611,513 runs / 60 s, 0 crashes. **Clean-room checklist** - [x] Sources read: stock ENet v1.3.18 `2662c0d` host-side functions of `protocol.c` and `enet.h` window constants (MIT, approved; S-34). Earlier facts S-10, S-17, S-21. - [x] No Moonlight ENet fork, no GPL source; no [M*] value used (HDR_MODE refused). - [x] Constants trace to PROTOCOL.md 3.x and stock ENet. - [x] Public repo: nothing private. **Self-review**: rebase conflicts were append-only (fuzz bins, source log rows; both kept). Checked that unknown/malformed frames inside the encrypted frame are skipped and outside are dropped, as 3.3 says; the duplicated receive/retransmit code (host vs client) is a known follow-up, not a defect. U9/U10/U11/U21/U23 open questions are listed for the black-box measurement.
mnovak added 7 commits 2026-12-04 12:48:01 +01:00
EnetHostPeer is the accepting side, one peer per client address. The tests drive our EnetClient against it with simulated time, loss, duplication and reordering, plus a scripted client for the stock ENet 1.3 facts (verify connect fields, session ids, what is acknowledged when). They fail against the stubs.
Input arrives typed and byte-identical to what the client encoded; host rumble, trigger rumble, LED, motion and termination reach the client; replays, forgeries and malformed messages are dropped; the stop deadline ends a session without PERIODIC_PING. Alloc caps for the host parsers. They fail against the stubs.
One peer per client address. CONNECT answered with a reliable VERIFY CONNECT as stock ENet 1.3 does it (session ids picked from the client's offer, MTU, window and channels clamped, throttle echoed); connected once the client acknowledges the verify; reliable, unreliable and unsequenced delivery with fragment reassembly under the existing caps; duplicate unsequenced groups dropped; pings when the client is quiet; retransmission and timeout as the client; disconnect both ways. Shares the client's channel, fragment and in-flight types.
parse_client_message types START_B, PERIODIC_PING, INPUT_DATA (through input::parse_input), IDR, INVALIDATE_REF_FRAMES, LOSS_STATS and FRAME_STATS (raw bodies) and skips anything else as Unknown. encode_host_message sends rumble, trigger rumble, motion, RGB LED and the extended termination; the plain termination (U10) and HDR_MODE (GPL-provenance layout) stay Unsupported. StopDeadline ends a session without PERIODIC_PING (default 60 s).
enet_host: accept on the first datagram or a canned connect (optionally acknowledged), then datagrams, some with our header; asserts outgoing datagrams parse within the MTU and deliveries stay under the cap. control_host: a connected ControlHost fed sealed arbitrary plaintexts, replayed sequence numbers, arbitrary frames in valid commands and raw datagrams; asserts parse_client_message invariants and that no message appears without a sealed frame. 60 s each, 0 crashes.
mnovak force-pushed feature/host-enet-control from 4415ab58e1 to f0aac13f12 2026-12-04 12:48:01 +01:00 Compare
mnovak merged commit 7b9b1f4e9c into main 2026-12-04 12:48:09 +01:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mnovak/DomiStream#11