1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-12-22 15:25:48 +01:00

Implement option -udp-range.

This commit is contained in:
Juliusz Chroboczek 2021-04-29 22:02:36 +02:00
parent cd6920d7e2
commit 99026c0e48
2 changed files with 25 additions and 0 deletions

View file

@ -2,6 +2,7 @@ package main
import (
"flag"
"fmt"
"log"
"os"
"os/signal"
@ -20,6 +21,7 @@ import (
func main() {
var cpuprofile, memprofile, mutexprofile, httpAddr, dataDir string
var udpRange string
flag.StringVar(&httpAddr, "http", ":8443", "web server `address`")
flag.StringVar(&webserver.StaticRoot, "static", "./static/",
@ -40,6 +42,8 @@ func main() {
"store memory profile in `file`")
flag.StringVar(&mutexprofile, "mutexprofile", "",
"store mutex profile in `file`")
flag.StringVar(&udpRange, "udp-range", "",
"UDP port `range`")
flag.BoolVar(&group.UseMDNS, "mdns", false, "gather mDNS addresses")
flag.BoolVar(&ice.ICERelayOnly, "relay-only", false,
"require use of TURN relays for all media traffic")
@ -47,6 +51,21 @@ func main() {
"built-in TURN server `address` (\"\" to disable)")
flag.Parse()
if udpRange != "" {
var min, max uint16
n, err := fmt.Sscanf(udpRange, "%v-%v", &min, &max)
if err != nil {
log.Printf("UDP range: %v", err)
os.Exit(1)
}
if n != 2 || min <= 0 || max <= 0 || min > max {
log.Printf("UDP range: bad range")
os.Exit(1)
}
group.UDPMin = min
group.UDPMax = max
}
if cpuprofile != "" {
f, err := os.Create(cpuprofile)
if err != nil {

View file

@ -18,6 +18,7 @@ import (
var Directory string
var UseMDNS bool
var UDPMin, UDPMax uint16
var ErrNotAuthorised = errors.New("not authorised")
@ -247,6 +248,11 @@ func APIFromCodecs(codecs []webrtc.RTPCodecCapability) (*webrtc.API, error) {
continue
}
}
if UDPMin > 0 && UDPMax > 0 {
s.SetEphemeralUDPPortRange(UDPMin, UDPMax)
}
return webrtc.NewAPI(
webrtc.WithSettingEngine(s),
webrtc.WithMediaEngine(&m),