mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Disable trickle ICE.
https://bugs.torproject.org/33984 OnICEGatheringStateChange is no longer called when candidate gathering is complete. SetLocalDescription kicks off the gathering process. https://bugs.torproject.org/28942#comment:28 https://bugs.torproject.org/33157#comment:2
This commit is contained in:
parent
73173cb698
commit
6c2e3adc41
1 changed files with 2 additions and 19 deletions
|
@ -165,10 +165,7 @@ func (c *WebRTCPeer) preparePeerConnection() error {
|
||||||
c.pc = nil
|
c.pc = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
s := webrtc.SettingEngine{}
|
pc, err := webrtc.NewPeerConnection(*c.config)
|
||||||
s.SetTrickle(true)
|
|
||||||
api := webrtc.NewAPI(webrtc.WithSettingEngine(s))
|
|
||||||
pc, err := api.NewPeerConnection(*c.config)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("NewPeerConnection ERROR: %s", err)
|
log.Printf("NewPeerConnection ERROR: %s", err)
|
||||||
return err
|
return err
|
||||||
|
@ -178,22 +175,11 @@ func (c *WebRTCPeer) preparePeerConnection() error {
|
||||||
pc.OnICECandidate(func(candidate *webrtc.ICECandidate) {
|
pc.OnICECandidate(func(candidate *webrtc.ICECandidate) {
|
||||||
if candidate == nil {
|
if candidate == nil {
|
||||||
log.Printf("WebRTC: Done gathering candidates")
|
log.Printf("WebRTC: Done gathering candidates")
|
||||||
|
c.offerChannel <- pc.LocalDescription()
|
||||||
} else {
|
} else {
|
||||||
log.Printf("WebRTC: Got ICE candidate: %s", candidate.String())
|
log.Printf("WebRTC: Got ICE candidate: %s", candidate.String())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
pc.OnICEGatheringStateChange(func(state webrtc.ICEGathererState) {
|
|
||||||
if state == webrtc.ICEGathererStateComplete {
|
|
||||||
log.Println("WebRTC: ICEGatheringStateComplete")
|
|
||||||
c.offerChannel <- pc.LocalDescription()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// This callback is not expected, as the Client initiates the creation
|
|
||||||
// of the data channel, not the remote peer.
|
|
||||||
pc.OnDataChannel(func(channel *webrtc.DataChannel) {
|
|
||||||
log.Println("OnDataChannel")
|
|
||||||
panic("Unexpected OnDataChannel!")
|
|
||||||
})
|
|
||||||
c.pc = pc
|
c.pc = pc
|
||||||
go func() {
|
go func() {
|
||||||
offer, err := pc.CreateOffer(nil)
|
offer, err := pc.CreateOffer(nil)
|
||||||
|
@ -226,9 +212,6 @@ func (c *WebRTCPeer) establishDataChannel() error {
|
||||||
Ordered: &ordered,
|
Ordered: &ordered,
|
||||||
}
|
}
|
||||||
dc, err := c.pc.CreateDataChannel(c.id, dataChannelOptions)
|
dc, err := c.pc.CreateDataChannel(c.id, dataChannelOptions)
|
||||||
// Triggers "OnNegotiationNeeded" on the PeerConnection, which will prepare
|
|
||||||
// an SDP offer while other goroutines operating on this struct handle the
|
|
||||||
// signaling. Eventually fires "OnOpen".
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("CreateDataChannel ERROR: %s", err)
|
log.Printf("CreateDataChannel ERROR: %s", err)
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue