[tor-commits] [snowflake/master] Remove for loop around broker.Negotiate
cohosh at torproject.org
cohosh at torproject.org
Mon Nov 23 17:11:23 UTC 2020
commit 665d76c5b04c4e470d85a826ea617a2404ed4a1d
Author: Cecylia Bocovich <cohosh at torproject.org>
Date: Fri Nov 13 15:08:00 2020 -0500
Remove for loop around broker.Negotiate
Instead of continuously polling the broker until the client receives a
snowflake, fail back to the Connect() loop and try again to collect more
peers after ReconnectTimeout.
---
client/lib/webrtc.go | 21 ++++-----------------
1 file changed, 4 insertions(+), 17 deletions(-)
diff --git a/client/lib/webrtc.go b/client/lib/webrtc.go
index af5a45a..3a23ffc 100644
--- a/client/lib/webrtc.go
+++ b/client/lib/webrtc.go
@@ -112,7 +112,10 @@ func (c *WebRTCPeer) connect(config *webrtc.Configuration, broker *BrokerChannel
if err != nil {
return err
}
- answer := exchangeSDP(broker, c.pc.LocalDescription())
+ answer, err := broker.Negotiate(c.pc.LocalDescription())
+ if err != nil {
+ return err
+ }
log.Printf("Received Answer.\n")
err = c.pc.SetRemoteDescription(*answer)
if nil != err {
@@ -217,22 +220,6 @@ func (c *WebRTCPeer) establishDataChannel() (*webrtc.DataChannel, error) {
}
}
-// exchangeSDP sends the local SDP offer to the Broker, awaits the SDP answer,
-// and returns the answer.
-func exchangeSDP(broker *BrokerChannel, offer *webrtc.SessionDescription) *webrtc.SessionDescription {
- // Keep trying the same offer until a valid answer arrives.
- for {
- // Send offer to broker (blocks).
- answer, err := broker.Negotiate(offer)
- if err == nil {
- return answer
- }
- log.Printf("BrokerChannel Error: %s", err)
- log.Printf("Failed to retrieve answer. Retrying in %v", ReconnectTimeout)
- <-time.After(ReconnectTimeout)
- }
-}
-
// Close all channels and transports
func (c *WebRTCPeer) cleanup() {
// Close this side of the SOCKS pipe.
More information about the tor-commits
mailing list