commit 2c008d6589e37e77f01a364ab414d6a95218de36
Author: Cecylia Bocovich <coh...@torproject.org>
Date:   Mon Feb 14 14:00:01 2022 -0500

    Add connection failure events for proxy timeouts
    
    This change adds two new connection failure events for snowflake
    proxies. One fires when the datachannel times out and another fires when
    the connection to the proxy goes stale.
---
 client/lib/webrtc.go | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/client/lib/webrtc.go b/client/lib/webrtc.go
index 282b54d..d5264a9 100644
--- a/client/lib/webrtc.go
+++ b/client/lib/webrtc.go
@@ -129,6 +129,8 @@ func (c *WebRTCPeer) checkForStaleness(timeout 
time.Duration) {
                if time.Since(lastReceive) > timeout {
                        log.Printf("WebRTC: No messages received for %v -- 
closing stale connection.",
                                timeout)
+                       err := errors.New("no messages received, closing stale 
connection")
+                       
c.eventsLogger.OnNewSnowflakeEvent(event.EventOnSnowflakeConnectionFailed{Error:
 err})
                        c.Close()
                        return
                }
@@ -174,7 +176,9 @@ func (c *WebRTCPeer) connect(config *webrtc.Configuration, 
broker *BrokerChannel
        case <-c.open:
        case <-time.After(DataChannelTimeout):
                c.transport.Close()
-               return errors.New("timeout waiting for DataChannel.OnOpen")
+               err = errors.New("timeout waiting for DataChannel.OnOpen")
+               
c.eventsLogger.OnNewSnowflakeEvent(event.EventOnSnowflakeConnectionFailed{Error:
 err})
+               return err
        }
 
        go c.checkForStaleness(SnowflakeTimeout)



_______________________________________________
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits

Reply via email to