Use -udp-range for both range and multiplexing.

This commit is contained in:
Juliusz Chroboczek
2025-03-30 23:20:39 +02:00
parent c17cca15e9
commit a7fbe6a2ae
3 changed files with 30 additions and 30 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ Galene 0.97 (unreleased)
* Upgrade to Pion v4. * Upgrade to Pion v4.
* Add support for ETags and ICE restarts to the WHIP server. * Add support for ETags and ICE restarts to the WHIP server.
* Implement UDP multiplexing and the option "-udp". * Implement UDP multiplexing.
8 March 2025: Galene 0.96.3 8 March 2025: Galene 0.96.3
+4 -4
View File
@@ -74,15 +74,15 @@ traffic to and from:
For good performance, your firewall should allow incoming and outgoing For good performance, your firewall should allow incoming and outgoing
traffic from the UDP ports used for media transfer. By default, these are traffic from the UDP ports used for media transfer. By default, these are
all high-numbered (ephemeral) ports, but they can be restricted using the all high-numbered (ephemeral) ports, but they can be restricted using one
following options: of the following options:
* the `-udp-range port1-port2` option restricts the UDP ports to be in * the `-udp-range port1-port2` option restricts the UDP ports to be in
the range from port1 to port2 inclusive; this should be a large range, the range from port1 to port2 inclusive; this should be a large range,
on the order of a few tens of thousands of ports; on the order of a few tens of thousands of ports;
* the `-udp port` option makes the server use just a single port, and * the `-udp-range port` option makes the server use just a single port,
demultiplex the traffic in userspace. and demultiplex the traffic in userspace.
If your server is behind NAT (which is not recommended), then the NAT must If your server is behind NAT (which is not recommended), then the NAT must
forward, at the very least, port 8443 to your server. Ideally, you should forward, at the very least, port 8443 to your server. Ideally, you should
+16 -16
View File
@@ -10,6 +10,7 @@ import (
"runtime" "runtime"
"runtime/pprof" "runtime/pprof"
"strconv" "strconv"
"strings"
"syscall" "syscall"
"time" "time"
@@ -24,7 +25,7 @@ import (
func main() { func main() {
var cpuprofile, memprofile, mutexprofile, httpAddr string var cpuprofile, memprofile, mutexprofile, httpAddr string
var udp, udpRange string var udpRange string
flag.StringVar(&httpAddr, "http", ":8443", "web server `address`") flag.StringVar(&httpAddr, "http", ":8443", "web server `address`")
flag.StringVar(&webserver.StaticRoot, "static", "./static/", flag.StringVar(&webserver.StaticRoot, "static", "./static/",
@@ -43,8 +44,8 @@ func main() {
"store memory profile in `file`") "store memory profile in `file`")
flag.StringVar(&mutexprofile, "mutexprofile", "", flag.StringVar(&mutexprofile, "mutexprofile", "",
"store mutex profile in `file`") "store mutex profile in `file`")
flag.StringVar(&udp, "udp", "", "UDP port") flag.StringVar(&udpRange, "udp-range", "",
flag.StringVar(&udpRange, "udp-range", "", "UDP port `range`") "UDP `port` (multiplexing) or port1-port2 (range)")
flag.BoolVar(&group.UseMDNS, "mdns", false, "gather mDNS addresses") flag.BoolVar(&group.UseMDNS, "mdns", false, "gather mDNS addresses")
flag.BoolVar(&ice.ICERelayOnly, "relay-only", false, flag.BoolVar(&ice.ICERelayOnly, "relay-only", false,
"require use of TURN relays for all media traffic") "require use of TURN relays for all media traffic")
@@ -52,22 +53,11 @@ func main() {
"built-in TURN server `address` (\"\" to disable)") "built-in TURN server `address` (\"\" to disable)")
flag.Parse() flag.Parse()
if udp != "" {
if udpRange != "" { if udpRange != "" {
log.Fatalf("Cannot specify both -udp and -udp-range") if strings.ContainsRune(udpRange, '-') {
}
port, err := strconv.Atoi(udp)
if err != nil {
log.Fatalf("UDP: %v", err)
}
err = group.SetUDPMux(port)
if err != nil {
log.Fatalf("UDP: %v", err)
}
} else if udpRange != "" {
var min, max uint16 var min, max uint16
n, err := fmt.Sscanf(udpRange, "%v-%v", &min, &max) n, err := fmt.Sscanf(udpRange, "%v-%v", &min, &max)
if err != nil { if err != nil || n != 2 {
log.Fatalf("UDP range: %v", err) log.Fatalf("UDP range: %v", err)
} }
if n != 2 || min <= 0 || max <= 0 || min > max { if n != 2 || min <= 0 || max <= 0 || min > max {
@@ -75,6 +65,16 @@ func main() {
} }
group.UDPMin = min group.UDPMin = min
group.UDPMax = max group.UDPMax = max
} else {
port, err := strconv.Atoi(udpRange)
if err != nil {
log.Fatalf("UDP: %v", err)
}
err = group.SetUDPMux(port)
if err != nil {
log.Fatalf("UDP: %v", err)
}
}
} }
if cpuprofile != "" { if cpuprofile != "" {