[tor-commits] [snowflake/main] Add NewWebRTCPeer3E Initializer

shelikhoo at torproject.org shelikhoo at torproject.org
Tue Jan 25 12:50:37 UTC 2022


commit 36ca610d6bf399a1cf6e6d35cec8e57e6eddf6b4
Author: Shelikhoo <xiaokangwang at outlook.com>
Date:   Mon Dec 13 15:05:38 2021 +0000

    Add NewWebRTCPeer3E Initializer
    
    This name includes [E]vent to reduce merge conflict with forward proxy change set.
---
 client/lib/webrtc.go | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/client/lib/webrtc.go b/client/lib/webrtc.go
index 4068eb8..01b85f5 100644
--- a/client/lib/webrtc.go
+++ b/client/lib/webrtc.go
@@ -36,13 +36,22 @@ type WebRTCPeer struct {
 	eventsLogger event.SnowflakeEventReceiver
 }
 
-// NewWebRTCPeer constructs a WebRTC PeerConnection to a snowflake proxy.
+func NewWebRTCPeer(config *webrtc.Configuration,
+	broker *BrokerChannel) (*WebRTCPeer, error) {
+	return NewWebRTCPeer3E(config, broker, nil)
+}
+
+// NewWebRTCPeer3E constructs a WebRTC PeerConnection to a snowflake proxy.
 //
 // The creation of the peer handles the signaling to the Snowflake broker, including
 // the exchange of SDP information, the creation of a PeerConnection, and the establishment
 // of a DataChannel to the Snowflake proxy.
-func NewWebRTCPeer(config *webrtc.Configuration,
-	broker *BrokerChannel) (*WebRTCPeer, error) {
+func NewWebRTCPeer3E(config *webrtc.Configuration,
+	broker *BrokerChannel, eventsLogger event.SnowflakeEventReceiver) (*WebRTCPeer, error) {
+	if eventsLogger == nil {
+		eventsLogger = event.NewSnowflakeEventDispatcher()
+	}
+
 	connection := new(WebRTCPeer)
 	{
 		var buf [8]byte
@@ -59,6 +68,8 @@ func NewWebRTCPeer(config *webrtc.Configuration,
 	// Pipes remain the same even when DataChannel gets switched.
 	connection.recvPipe, connection.writePipe = io.Pipe()
 
+	connection.eventsLogger = eventsLogger
+
 	err := connection.connect(config, broker)
 	if err != nil {
 		connection.Close()





More information about the tor-commits mailing list