commit 36ca610d6bf399a1cf6e6d35cec8e57e6eddf6b4 Author: Shelikhoo xiaokangwang@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()
tor-commits@lists.torproject.org