feat(engine): bind and publish both ingest ports by default - #123
Merged
Conversation
RTMP bound only when some enabled source was configured for it; SRT bound unconditionally. That was not a policy. It was two histories preserved side by side — `ffmpeg -listen 1` had held 1935 only while an RTMP source existed, and the SRT listener had always been up — and the gate's own comment gave the game away: it justified itself by not wanting to expose a port on "a fresh install that has not chosen an ingest mode yet", on an install where SRT was already bound for exactly that reason. Verified on a genuinely fresh container: ingest "not chosen yet", 6000 open, 1935 closed. It also disagreed with our own instructions. docs/HARDWARE.md and docs/TROUBLESHOOTING.md have always told operators to run `-p 6000:6000/udp -p 1935:1935`, so we documented publishing a port that might not be listening. datarhei Restreamer opens both. install.sh now matches, and this is the part that makes the change coherent rather than just wider: it asks for an RTMP port the way it asks for an SRT one instead of a yes/no, publishes 1935 by default, and takes `--rtmp-port 0` to decline. The port is the switch on both sides — internal/engine already treated 0 as off — where before there was a yes/no in the installer and a port in the settings meaning the same thing two different ways. Tested: default publishes 1935, `--rtmp-port 0` omits it, `--rtmp-port 1936` uses that. THE EXPOSURE THIS ADDS IS NARROW AND WORTH STATING. A host with no firewall at all now has 1935 reachable, where the source list was closing it by accident. Everywhere else the ufw rule and the compose publish decide, which is what they always claimed to do — the installer prompt said "expose", and exposure is what it controlled. Both listeners refuse an unknown token or key in constant time, both require Target.Ready before admitting anything, and a connection that opens and says nothing dies on the handshake timeout. anyRTMPSource is deleted rather than left unused. It had no test — the gate it implemented was never verified in its whole life, which is its own argument. TestBothListenersBindWithoutBeingAskedTo asserted the old behaviour and now asserts the new one, through the real Manager. Claude-Session: https://claude.ai/code/session_01HeLrWaDmsNeeNSbHQfEofX
|
There was a problem hiding this comment.
Pull request overview
This PR makes ingest behavior and installation defaults consistent by binding both RTMP and SRT listeners by default (with port 0 intended as the explicit “off” switch), and updating the installer and changelog to reflect that both ingest ports are published by default.
Changes:
- Engine: remove RTMP “gate” based on configured sources and always reconcile the RTMP listener (like SRT).
- Installer: prompt for an RTMP port (default 1935) instead of a yes/no, and document
--rtmp-port 0to decline RTMP exposure. - Documentation: add an Unreleased changelog entry describing the new default exposure/binding behavior and rationale.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| scripts/install.sh | Switches RTMP exposure from yes/no to a port-based toggle; defaults to publishing RTMP. |
| internal/engine/manager.go | Removes RTMP source-based gating so RTMP reconciliation mirrors SRT. |
| internal/engine/manager_test.go | Updates listener-binding expectations to match new always-bind behavior. |
| CHANGELOG.md | Documents the behavioral change and operational/security implications. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
256
to
258
| rtmpPort := st.Listeners.RTMPPort | ||
| wantRTMP := true | ||
| if rows, err := m.store.ListSources(); err != nil { | ||
| // Read failure: leave the listener as it is rather than tearing it down | ||
| // on a transient error. An RTMP encoder that is mid-broadcast must not | ||
| // lose its socket because a settings read blipped. | ||
| m.log.Warn("cannot list sources for the rtmp listener gate; leaving it as-is", "err", err) | ||
| wantRTMP = rtmpAddr != "" | ||
| } else { | ||
| wantRTMP = anyRTMPSource(rows) | ||
| } | ||
| rtmp, rtmpAddr = reconcileListener(m.log, "rtmp", rtmpPort, wantRTMP, rtmp, rtmpAddr, | ||
| rtmp, rtmpAddr = reconcileListener(m.log, "rtmp", rtmpPort, true, rtmp, rtmpAddr, | ||
| (*rtmpserver.Server).Stop, |
Comment on lines
+578
to
582
| # The port IS the switch, server-side too: internal/engine binds both | ||
| # listeners and treats 0 as off. Asking a yes/no here and a port there meant | ||
| # two different ways to say the same thing. | ||
| case "$RTMP_PORT" in 0|"") ENABLE_RTMP="no" ;; *) ENABLE_RTMP="yes" ;; esac | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



RTMP bound only when a source was configured for it; SRT bound unconditionally. Not a policy — two histories preserved side by side. The gate's own comment justified itself by not exposing a port on "a fresh install that has not chosen an ingest mode yet", on an install where SRT was already bound for exactly that reason.
It also disagreed with our own docs, which have always said to run
-p 6000:6000/udp -p 1935:1935. Restreamer opens both.install.shnow asks for an RTMP port like it asks for SRT, publishes 1935 by default, and takes--rtmp-port 0to decline. The port is the switch on both sides.Exposure added, stated plainly: a host with no firewall now has 1935 reachable, where the source list was closing it by accident. Everywhere else ufw and the compose publish still decide — which is what the prompt always said it controlled.
anyRTMPSourceis deleted. It had no test in its whole life.