commit c3f09994daa5a512a6d6cea026aeb15162d5d866 Author: Shelikhoo xiaokangwang@outlook.com Date: Mon Dec 13 14:10:06 2021 +0000
Add Snowflake Event Reporter for Broker Communication --- client/lib/webrtc.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/client/lib/webrtc.go b/client/lib/webrtc.go index f4b775c..3b496d0 100644 --- a/client/lib/webrtc.go +++ b/client/lib/webrtc.go @@ -9,6 +9,7 @@ import ( "sync" "time"
+ "git.torproject.org/pluggable-transports/snowflake.git/v2/common/event" "github.com/pion/webrtc/v3" )
@@ -31,7 +32,8 @@ type WebRTCPeer struct {
once sync.Once // Synchronization for PeerConnection destruction
- bytesLogger bytesLogger + bytesLogger bytesLogger + eventsLogger event.SnowflakeEventReceiver }
// NewWebRTCPeer constructs a WebRTC PeerConnection to a snowflake proxy. @@ -131,10 +133,21 @@ func (c *WebRTCPeer) connect(config *webrtc.Configuration, broker *BrokerChannel log.Println(c.id, " connecting...") // TODO: When go-webrtc is more stable, it's possible that a new // PeerConnection won't need to be re-prepared each time. - if err := c.preparePeerConnection(config); err != nil { + err := c.preparePeerConnection(config) + localDescription := c.pc.LocalDescription() + c.eventsLogger.OnNewSnowflakeEvent(event.EventOnOfferCreated{ + WebRTCLocalDescription: localDescription, + Error: err, + }) + if err != nil { return err } - answer, err := broker.Negotiate(c.pc.LocalDescription()) + + answer, err := broker.Negotiate(localDescription) + c.eventsLogger.OnNewSnowflakeEvent(event.EventOnBrokerRendezvous{ + WebRTCRemoteDescription: answer, + Error: err, + }) if err != nil { return err }
tor-commits@lists.torproject.org