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:
David Fifield 2020-04-23 22:22:34 -06:00
parent 73173cb698
commit 6c2e3adc41

View file

@ -165,10 +165,7 @@ func (c *WebRTCPeer) preparePeerConnection() error {
c.pc = nil
}
s := webrtc.SettingEngine{}
s.SetTrickle(true)
api := webrtc.NewAPI(webrtc.WithSettingEngine(s))
pc, err := api.NewPeerConnection(*c.config)
pc, err := webrtc.NewPeerConnection(*c.config)
if err != nil {
log.Printf("NewPeerConnection ERROR: %s", err)
return err
@ -178,22 +175,11 @@ func (c *WebRTCPeer) preparePeerConnection() error {
pc.OnICECandidate(func(candidate *webrtc.ICECandidate) {
if candidate == nil {
log.Printf("WebRTC: Done gathering candidates")
c.offerChannel <- pc.LocalDescription()
} else {
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
go func() {
offer, err := pc.CreateOffer(nil)
@ -226,9 +212,6 @@ func (c *WebRTCPeer) establishDataChannel() error {
Ordered: &ordered,
}
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 {
log.Printf("CreateDataChannel ERROR: %s", err)
return err