Limit WebRTC UDP ports

This commit is contained in:
Alexandre Iooss 2020-09-29 14:11:56 +02:00
parent 19a331b9e0
commit d46efaae3c
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
1 changed files with 9 additions and 1 deletions

View File

@ -45,7 +45,15 @@ func newPeerHandler(remoteSdp webrtc.SessionDescription) webrtc.SessionDescripti
}
// Create a new PeerConnection
api := webrtc.NewAPI(webrtc.WithMediaEngine(mediaEngine))
settingsEngine := webrtc.SettingEngine{}
if err := settingsEngine.SetEphemeralUDPPortRange(10000, 11000); err != nil {
log.Println("Failed to set min/max UDP ports", err)
return webrtc.SessionDescription{}
}
api := webrtc.NewAPI(
webrtc.WithMediaEngine(mediaEngine),
webrtc.WithSettingEngine(settingsEngine),
)
peerConnection, err := api.NewPeerConnection(webrtc.Configuration{
ICEServers: []webrtc.ICEServer{
{