mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Merge remote-tracking branch 'gitlab/mr/102'
This commit is contained in:
commit
56063efbba
2 changed files with 45 additions and 7 deletions
|
@ -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.
|
||||
|
@ -347,6 +350,18 @@ func (d dataChannelHandlerWithRelayURL) datachannelHandler(conn *webRTCConn, rem
|
|||
d.sf.datachannelHandler(conn, remoteAddr, d.RelayURL)
|
||||
}
|
||||
|
||||
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))
|
||||
}
|
||||
|
||||
// Create a PeerConnection from an SDP offer. Blocks until the gathering of ICE
|
||||
// candidates is complete and the answer is available in LocalDescription.
|
||||
// Installs an OnDataChannel callback that creates a webRTCConn and passes it to
|
||||
|
@ -356,9 +371,7 @@ func (sf *SnowflakeProxy) makePeerConnectionFromOffer(sdp *webrtc.SessionDescrip
|
|||
dataChan chan struct{},
|
||||
handler func(conn *webRTCConn, remoteAddr net.Addr)) (*webrtc.PeerConnection, error) {
|
||||
|
||||
s := webrtc.SettingEngine{}
|
||||
s.SetICEMulticastDNSMode(ice.MulticastDNSModeDisabled)
|
||||
api := webrtc.NewAPI(webrtc.WithSettingEngine(s))
|
||||
api := sf.makeWebRTCAPI()
|
||||
pc, err := api.NewPeerConnection(config)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("accept: NewPeerConnection: %s", err)
|
||||
|
@ -446,9 +459,7 @@ func (sf *SnowflakeProxy) makePeerConnectionFromOffer(sdp *webrtc.SessionDescrip
|
|||
func (sf *SnowflakeProxy) makeNewPeerConnection(config webrtc.Configuration,
|
||||
dataChan chan struct{}) (*webrtc.PeerConnection, error) {
|
||||
|
||||
s := webrtc.SettingEngine{}
|
||||
s.SetICEMulticastDNSMode(ice.MulticastDNSModeDisabled)
|
||||
api := webrtc.NewAPI(webrtc.WithSettingEngine(s))
|
||||
api := sf.makeWebRTCAPI()
|
||||
pc, err := api.NewPeerConnection(config)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("accept: NewPeerConnection: %s", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue