[tor-commits] [snowflake/master] Disable trickle ICE.

dcf at torproject.org dcf at torproject.org
Fri Apr 24 16:38:49 UTC 2020


commit 6c2e3adc41c2c6d1ed794adac019a5a6eb069536
Author: David Fifield <david at bamsoftware.com>
Date:   Thu Apr 23 22:22:34 2020 -0600

    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
---
 client/lib/webrtc.go | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/client/lib/webrtc.go b/client/lib/webrtc.go
index 589bbfa..e2a755f 100644
--- a/client/lib/webrtc.go
+++ b/client/lib/webrtc.go
@@ -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



More information about the tor-commits mailing list