proxy: Add ICE ephemeral ports range setting CLI flag

This commit is contained in:
KokaKiwi 2022-09-30 17:52:07 +02:00 committed by KokaKiwi
parent 5e564f36ff
commit 47f9392645
No known key found for this signature in database
GPG key ID: 09A5A2688F13FAC1
2 changed files with 28 additions and 1 deletions

View file

@ -114,6 +114,9 @@ type SnowflakeProxy struct {
KeepLocalAddresses bool
// RelayURL is the URL of the Snowflake server that all traffic will be relayed to
RelayURL string
// Ephemeral*Port limits the pool of ports that ICE UDP connections can allocate from
EphemeralMinPort uint16
EphemeralMaxPort uint16
// RelayDomainNamePattern is the pattern specify allowed domain name for relay
// If the pattern starts with ^ then an exact match is required.
// The rest of pattern is the suffix of domain name.
@ -350,6 +353,10 @@ func (d dataChannelHandlerWithRelayURL) datachannelHandler(conn *webRTCConn, rem
func (sf *SnowflakeProxy) makeWebRTCAPI() *webrtc.API {
settingsEngine := webrtc.SettingEngine{}
if sf.EphemeralMinPort != 0 && sf.EphemeralMaxPort != 0 {
settingsEngine.SetEphemeralUDPPortRange(sf.EphemeralMinPort, sf.EphemeralMaxPort)
}
settingsEngine.SetICEMulticastDNSMode(ice.MulticastDNSModeDisabled)
return webrtc.NewAPI(webrtc.WithSettingEngine(settingsEngine))