fix(server): bind UDP media to the TCP port so self-host needs one forward rule
media_port defaulted to 0 (OS-assigned) and --port only set the TCP bind_port, so the UDP relay bound a random high port and advertised it to clients in HELLO. Self-hosters forwarding only 8384/udp saw connect-OK-but-no-voice, contradicting docs/deployment.md (control and media share one port). Media now follows bind_port when media_port is unset; 0=OS-assigned survives when bind_port is also 0 so ephemeral-port tests are unaffected. Banner now reads TCP :8384 UDP :8384. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -69,8 +69,12 @@ int Server::run() {
|
||||
|
||||
// ── UDP media relay (M2) ─────────────────────────────────────────────────
|
||||
auto media_relay = std::make_shared<MediaRelay>(io, registry);
|
||||
if (!media_relay->bind(cfg_.media_port)) {
|
||||
std::fprintf(stderr, "[server] failed to bind UDP media port %u\n", cfg_.media_port);
|
||||
// Control and media share one port number on TCP+UDP (docs/deployment.md): when media_port
|
||||
// is left at 0, follow bind_port so a single forward rule covers both. If bind_port is also 0
|
||||
// (tests), this stays 0 and the OS picks the UDP port (reported via on_media_ready).
|
||||
uint16_t media_want = cfg_.media_port != 0 ? cfg_.media_port : cfg_.bind_port;
|
||||
if (!media_relay->bind(media_want)) {
|
||||
std::fprintf(stderr, "[server] failed to bind UDP media port %u\n", media_want);
|
||||
return 1;
|
||||
}
|
||||
media_relay->start();
|
||||
|
||||
Reference in New Issue
Block a user