Repository navigation
fix(gateways): bound WebRTC mux and RTMP pre-play state, accept SDP MIME params, end HLS holds and transcoder on close - #9342
Conversation
…les.md Quest-Claim: 38cb1098de0e53e7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 9 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
ℹ️ No critical issues — two rough edges inline.
Approach: sound. Each finding is fixed at its source: a per-session address list in the mux, a shared MIME check, writing owed replies before reading in feed_input, and lifecycle hooks in HLS and the transcoder.
Reviewed changes
I reviewed all 8 files across the 9 commits, including the mux routing paths, the Play::accept call sites of feed_input, play_selection's use of enabled(), HLS sync after close, and the transcoder serve loop.
- WebRTC mux bounds: each session keeps at most
MAX_ADDRS(16) held or claimed addresses, dropping the least recently signed.releaseonly removes an entry that still points to its ownArc<Entry>, so stale entries in a dead holder's list are harmless, and teardown no longer sweeps every session. is_sdpdedup: oneserver::is_sdpnow serves both WHIP and WHEP. It compares only the MIME type, ignoring parameters such ascharset, case-insensitively.- RTMP pre-play backpressure:
feed_inputwrites the replies it owes before it reads again. It uses singlewritecalls and trims the sent bytes, so dropping it insideselect!loses no bytes. - RTMP disabled renditions: single-track selection now only considers
enabled()renditions.enabled()isranked()filtered, so the codec named in the refusal is still the best-ranked one. - HLS holds:
clear,finishandcutnow emptystate.waiting. Afterclose,synccan't refill it becausestate.write()fails. - Transcoder: the serve loop now stops on
source.closed()and finishes the derived catalog cleanly.
claude-opus-5-5 | 𝕏
|
quest land watch: ended this pull request's pick, disarming its auto-merge, since its head e67e5f2 is held by finding by pullfrog[bot]: (written by quest land watch) |
… doc on delete Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
I reviewed the one new commit since the prior pullfrog review (e67e5f2..57902a5).
- RTMP pre-play stop:
feed_inputnow checks all ofworkfor a queuedPlayStreamFinishedbefore any write and returns at once. A stop behind a reply the viewer never reads ends the wait, anda_stop_behind_an_unread_reply_ends_the_waitpins it with a 1-byte pipe. is_sdpdoc placement:is_sdpnow sits abovedelete's doc comment, so each item keeps its own docs.
claude-sonnet-5-5 | 𝕏

Fixes five pre-cut audit findings in the gateways (the
gateways-bounds-and-lifecyclesquest, finished by this PR).Changes
MAX_ADDRS(16). The address it signed least recently goes first. Only a binding request signed with the session's own ICE password caches an address, so the attacker is a session's own peer signing from rotating spoofed sources. That peer now fills only its own 16 slots. Consent checks re-sign the address in use every few seconds, so a real peer keeps it. A session's teardown removes its own entries in O(16) instead of sweeping every session's entries.is_sdpmerge intoserver::is_sdp, which accepts MIME parameters (application/sdp; charset=utf-8).PLAY_RESOLVE_TIMEOUT),feed_inputused to queue every session result. A client flooding commands that owe replies grew that queue without limit. It now writes owed replies before reading more, soworkholds at most one read's results and a client that floods without reading stalls on its own TCP window. To stay safe to drop insideselect!, it uses singlewritecalls and trims the sent bytes off the front packet. It drops events, which nothing before playback acts on.play_selectionnow checks only enabled renditions. Before, a client that could play only a disabled rendition was accepted, then got no video, becauseselectnever picks disabled tracks. It is now refused and told which FourCC is missing. With no enabled renditions of a kind, nothing is refused.clear,finish, andcutreleasestate.waiting, the subscriptions held for a catalog that has no join interval yet. Before, a set that ended before declaring an interval kept every track subscribed for as long as any consumer held the shared state.Transcoder::run's serve loop breaks onsource.closed(). Before, a source that closed while its catalog track stayed open hung the transcoder. It now winds down the same way a catalog end does: it finishes the derived catalog.Public API: none. Wire: none.
Validation
server::mux::tests::a_session_holds_its_most_recent_addresses: 1,000 spoofed sources leave 16. The address the peer keeps refreshing survives. Teardown leaves the other session's address.server::tests::sdp_content_type_ignores_parametersserver::tests::a_flooding_viewer_cannot_grow_the_pre_play_queue: the oldfeed_inputqueued 4,882 replies. The new one holds at most 1, and the flooder blocks.play_selection_picks_the_best_playable_{rendition,audio}, extended with disabled-only cases.export::renditions::tests::an_ended_set_releases_its_held_tracks: the old code fails with "the hold outlived the set".tests::a_closed_source_ends_the_serve_loop: the old code timed out after 5 s.moq --listen-unix-bind … --auth-public "" --broadcast cam import webrtc --listen 127.0.0.1:18080, then POSTed an Opus offer with curl:application/sdp→ 201 with an SDP answerapplication/sdp; charset=utf-8→ 201 with an SDP answertext/plain→ 400invalid SDP: expected Content-Type: application/sdpcargo testformoq-webrtc(server),moq-rtmp,moq-hls --lib, andmoq-transcode --lib, plusjust check: all pass.Decisions
is_sdpnow sits abovedelete's doc comment, andfeed_inputreturns on a queued stop before writing any reply, so a stop behind a reply the viewer never reads ends the wait (a_stop_behind_an_unread_reply_ends_the_wait).Choices made without asking
MAX_ADDRS = 16per session, evicting the least recently signed address. A WebRTC peer has a handful of candidates. Total mux state is now sessions × 16.Cancel, since there a source gone before its ladder exists is no clean end.Caused by
Content-Typeexactly (found by check)sync(found by check)Follow-ups
None.
Models
Size: M
Implementer: Claude Code, claude-opus-5-5, unknown effort (arm A)
Implementer: Claude Code, claude-opus-5-5, unknown effort (iterate, XS, arm A)
🤖 Generated with Claude Code
Review
Rewritten by
quest reviewafter each round.Head: 57902a5
Base: origin/main at f1b6e06
Risk: medium,
Gateway routing, RTMP playback, HLS cleanup, and transcoder shutdown changes could disrupt streams for users, but preserve public APIs and wire formats and are fully undone by a revert.Classified: medium by Codex, gpt-6.1-sol, low effort, session
01a201d6-2232-7373-befb-cc25d2c54b44Reviewer: Codex, gpt-6.1-sol, high effort
Session:
01a20188-bdfd-7b53-be0a-a07d4a0524d2, round 3Score: 10/10,
The incremental changes correctly prioritize queued playback stops and fix misplaced documentation, with no new issues found by code inspection; builds and tests were not run.Rounds: 3; first round 1 (medium 1); findings 1 (medium 1): fixed 1, refuted 0, open 0
Findings: none