Skip to content

Commit a7fbe6a

Browse files
committed
Use -udp-range for both range and multiplexing.
1 parent c17cca1 commit a7fbe6a

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

CHANGES

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Galene 0.97 (unreleased)
22

33
* Upgrade to Pion v4.
44
* Add support for ETags and ICE restarts to the WHIP server.
5-
* Implement UDP multiplexing and the option "-udp".
5+
* Implement UDP multiplexing.
66

77
8 March 2025: Galene 0.96.3
88

INSTALL

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ traffic to and from:
7474

7575
For good performance, your firewall should allow incoming and outgoing
7676
traffic from the UDP ports used for media transfer. By default, these are
77-
all high-numbered (ephemeral) ports, but they can be restricted using the
78-
following options:
77+
all high-numbered (ephemeral) ports, but they can be restricted using one
78+
of the following options:
7979

8080
* the `-udp-range port1-port2` option restricts the UDP ports to be in
8181
the range from port1 to port2 inclusive; this should be a large range,
8282
on the order of a few tens of thousands of ports;
8383

84-
* the `-udp port` option makes the server use just a single port, and
85-
demultiplex the traffic in userspace.
84+
* the `-udp-range port` option makes the server use just a single port,
85+
and demultiplex the traffic in userspace.
8686

8787
If your server is behind NAT (which is not recommended), then the NAT must
8888
forward, at the very least, port 8443 to your server. Ideally, you should

galene.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"runtime"
1111
"runtime/pprof"
1212
"strconv"
13+
"strings"
1314
"syscall"
1415
"time"
1516

@@ -24,7 +25,7 @@ import (
2425

2526
func main() {
2627
var cpuprofile, memprofile, mutexprofile, httpAddr string
27-
var udp, udpRange string
28+
var udpRange string
2829

2930
flag.StringVar(&httpAddr, "http", ":8443", "web server `address`")
3031
flag.StringVar(&webserver.StaticRoot, "static", "./static/",
@@ -43,38 +44,37 @@ func main() {
4344
"store memory profile in `file`")
4445
flag.StringVar(&mutexprofile, "mutexprofile", "",
4546
"store mutex profile in `file`")
46-
flag.StringVar(&udp, "udp", "", "UDP port")
47-
flag.StringVar(&udpRange, "udp-range", "", "UDP port `range`")
47+
flag.StringVar(&udpRange, "udp-range", "",
48+
"UDP `port` (multiplexing) or port1-port2 (range)")
4849
flag.BoolVar(&group.UseMDNS, "mdns", false, "gather mDNS addresses")
4950
flag.BoolVar(&ice.ICERelayOnly, "relay-only", false,
5051
"require use of TURN relays for all media traffic")
5152
flag.StringVar(&turnserver.Address, "turn", "auto",
5253
"built-in TURN server `address` (\"\" to disable)")
5354
flag.Parse()
5455

55-
if udp != "" {
56-
if udpRange != "" {
57-
log.Fatalf("Cannot specify both -udp and -udp-range")
58-
}
59-
port, err := strconv.Atoi(udp)
60-
if err != nil {
61-
log.Fatalf("UDP: %v", err)
62-
}
63-
err = group.SetUDPMux(port)
64-
if err != nil {
65-
log.Fatalf("UDP: %v", err)
66-
}
67-
} else if udpRange != "" {
68-
var min, max uint16
69-
n, err := fmt.Sscanf(udpRange, "%v-%v", &min, &max)
70-
if err != nil {
71-
log.Fatalf("UDP range: %v", err)
72-
}
73-
if n != 2 || min <= 0 || max <= 0 || min > max {
74-
log.Fatalf("UDP range: bad range")
56+
if udpRange != "" {
57+
if strings.ContainsRune(udpRange, '-') {
58+
var min, max uint16
59+
n, err := fmt.Sscanf(udpRange, "%v-%v", &min, &max)
60+
if err != nil || n != 2 {
61+
log.Fatalf("UDP range: %v", err)
62+
}
63+
if n != 2 || min <= 0 || max <= 0 || min > max {
64+
log.Fatalf("UDP range: bad range")
65+
}
66+
group.UDPMin = min
67+
group.UDPMax = max
68+
} else {
69+
port, err := strconv.Atoi(udpRange)
70+
if err != nil {
71+
log.Fatalf("UDP: %v", err)
72+
}
73+
err = group.SetUDPMux(port)
74+
if err != nil {
75+
log.Fatalf("UDP: %v", err)
76+
}
7577
}
76-
group.UDPMin = min
77-
group.UDPMax = max
7878
}
7979

8080
if cpuprofile != "" {

0 commit comments

Comments
 (0)