go2rtc
go2rtc copied to clipboard
Config appears to ignore certain WebRTC settings
When configuring the "listen" option, and specifying a port, UDP does not appear to be restricted to the specified port, regardless of whether I specify ":8555", ":8555/udp", or [ ":8555/tcp", ":8555/udp" ], UDP ports will still be selected at random. I verified this by testing against a loopback interface while running a packet capture. This is problematic because in the actual environment I want to deploy in, I need to specify ports to be made available, which I can't do if I can't restrict them.
My current workaround for this issue it to restrict to TCP, as TCP does seem to respect the port specification (or maybe it doesn't use random ports to begin with). Of note, this _also _ doesn't work totally cleanly either. In particular, the tcp4 and udp4 options do seemingly nothing, IPv6 candidates will still be advertised and used unless they are otherwise preempted. Additionally tcp4 does not totally disable UDP, a UDP listener is still spawned, UDP candidates are still advertised, and are still selected sometimes (as tested against a loopback), however in the environment where limited ports are available (which was causing problems when it was advertising random UDP ports), it seems to reliably select TCP mode only when I specify this option, otherwise it will insistently try to use the random UDP ports, and obviously fail.
Basically what I'm asking for is either more clear documentation on what these settings actually do, or for these settings to actually do what they say they do.
Check this and tell if there are any questions left: https://github.com/AlexxIT/go2rtc/blob/master/internal/webrtc/README.md
This is the file that I read that lead to these questions/issues. The config options I specified in the original post aren't working as I would expect after reading that.
Re-reading it now, I do notice that it mentions that "udp_ports" is not related to "listen", however "listen" specifically mentions that it can be used to specify a fixed UDP port... Additional clarification is needed with regards to what listen: ":8555/udp" actually does in that case. Additionally, the rest of what I said about the tcp4 and udp4 filters seemingly not fully disabling IPv6 or UDP still stands.
There are three types of connections: host, stun, turn. Most users don't have a TURN server, so that leaves only two types left: host, stun.
listen can manage the host connection. If listen is empty, it will be a random UDP port. If not empty, it will be a static UDP or TCP port or both.
You cannot manage stun ports. They will always be random UDP ports. UDP hole punching technology.
You can disable the stun connection if you don't need it.
I didn't invent all of this. This is how WebRTC technology works and how the pion library used in this project works.
This is my first time working with WebRTC, but I am very familiar with the underlying network concepts. I guess my next question comes down to, under which connection types do which configurations apply, and, what process is used when selecting a candidate? So, obviously there are some circumstances under which "listen" isn't respected, and some circumstances under which "networks" isn't either. I know you didn't invent WebRTC, and I'm sorry if it sounds like I did, if the handling of this config is largely copied from an upstream library, just let me know and I'll check that documentation instead.
Most config params, but not all, used here https://github.com/AlexxIT/go2rtc/blob/master/pkg/webrtc/api.go