Skip to content

Log actual TcpListener local addresses for clarity#189

Open
DOCtorActoAntohich wants to merge 1 commit intoharlanc:masterfrom
DOCtorActoAntohich:log-proper-ports
Open

Log actual TcpListener local addresses for clarity#189
DOCtorActoAntohich wants to merge 1 commit intoharlanc:masterfrom
DOCtorActoAntohich:log-proper-ports

Conversation

@DOCtorActoAntohich
Copy link
Copy Markdown

consider the following minimal config

[rtmp]
enabled = true
port = 0

# for simplicity, let's imagine rtsp and other stuff is just disabled

[httpapi]
port = 0

specifying port 0 means the system will assign any free port. this is cool and all but the logs don't reflect the truth

$ xiu --config the-config-from-above.toml
[2026-04-28T07:43:58Z INFO  rtmp::rtmp] Rtmp server listening on tcp://0.0.0.0:0
[2026-04-28T07:43:58Z INFO  xiu::api] Http api server listening on http://0.0.0.0:0

this is just wrong information because: we can't actually bind to port 0, and we can't have two sockets on one port.

instead, here's the truth:

lsof -i -P | grep xiu
xiu       89412  doc    9u  IPv4 0xccdde83db1f0d39a      0t0    TCP *:60689 (LISTEN)
xiu       89412  doc   10u  IPv4 0xa36499b626ff5706      0t0    TCP *:60690 (LISTEN)

so as we see, the system properly assigns the ports, but logs don't reflect it.

the fix is simple: instead of printing the info from the config, we can show the actual port the TcpListener binds to

this change can make the app more automation-friendly...


also no reason to parse SocketAddr from string when you know you can use the UNSPECIFIED address, and the port is already given

if we log ports from config files, we get wrong information...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant