Repository navigation
pjsua: preserve ephemeral TLS and IPv6 ports - #5325
Conversation
nanangizz
left a comment
There was a problem hiding this comment.
Thanks, the fix works for the --no-udp case. Tested as an unprivileged user on Linux, with --local-port=0:
| Options | master | this PR |
|---|---|---|
--no-udp --use-tls |
TLS listener: Permission denied (port 1) | ephemeral ports |
--no-udp --ipv6 --use-tls |
TCP6 listener: Permission denied (port 10) | ephemeral ports |
--ipv6 --use-tls (UDP on) |
UDP6 5060, TCP 5060, TCP6 5070, TLS 5071, TLS6 5080 | same |
With UDP enabled, the UDP6 block still maps port 0 to a fixed 5060 (udp_cfg.port = 5060), which is then copied into tcp_cfg.port, so none of the new checks apply and every port is fixed. A second instance started the same way fails with "address in use". Could you handle it the same way, i.e. if (udp_cfg.port != 0) udp_cfg.port += 10;? The 5060 dates back to a 2010 SIPit change (3f4b8d7), so it doesn't look like intended behaviour for port 0.
|
Thanks, good catch. Pushed bf0352b - the UDP6 block no longer maps port 0 to 5060. It now only adds the +10 offset when the port is nonzero. Tested on macOS (arm64, OpenSSL,
Two instances started with Terminal output
|
Description
Closes #5324
When
pjsuais configured with--local-port=0, port0should be preserved for transports that use automatic port selection.Currently, pjsua derives IPv6 and TLS transport ports by applying fixed offsets:
When the base port is
0, this can result in fixed ports such as10,1, or11instead of OS-selected ephemeral ports. This may cause startup failures for unprivileged users and makes--local-port=0behave unexpectedly.This change applies the offsets only when the configured port is nonzero. Existing behavior for explicitly configured ports is unchanged.
Testing
pjsuasuccessfully on macOS.