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