diff options
author | Cecylia Bocovich <cohosh@torproject.org> | 2022-02-14 14:00:01 -0500 |
---|---|---|
committer | Cecylia Bocovich <cohosh@torproject.org> | 2022-02-14 14:00:01 -0500 |
commit | 2c008d6589e37e77f01a364ab414d6a95218de36 (patch) | |
tree | 6535098d5a0e10b248e7895e22ae254772131538 | |
parent | bcc162898a9b085d8543e1aaeff7950b4431c5f3 (diff) | |
download | snowflake-2c008d6589e37e77f01a364ab414d6a95218de36.tar.gz snowflake-2c008d6589e37e77f01a364ab414d6a95218de36.zip |
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.
-rw-r--r-- | client/lib/webrtc.go | 6 |
1 files changed, 5 insertions, 1 deletions
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) |