[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [pluggable-transports/snowflake] 01/04: Refactor creation of webRTCConn in proxy



This is an automated email from the git hooks/post-receive script.

cohosh pushed a commit to branch main
in repository pluggable-transports/snowflake.

commit 6007d5e08e981b739e5dab23ce5597fc086ca1c2
Author: Cecylia Bocovich <cohosh@xxxxxxxxxxxxxx>
AuthorDate: Tue Oct 18 14:55:50 2022 -0400

    Refactor creation of webRTCConn in proxy
---
 proxy/lib/snowflake.go  | 3 +--
 proxy/lib/webrtcconn.go | 6 ++++++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/proxy/lib/snowflake.go b/proxy/lib/snowflake.go
index ac88f0c..352c6e7 100644
--- a/proxy/lib/snowflake.go
+++ b/proxy/lib/snowflake.go
@@ -384,8 +384,7 @@ func (sf *SnowflakeProxy) makePeerConnectionFromOffer(sdp *webrtc.SessionDescrip
 		close(dataChan)
 
 		pr, pw := io.Pipe()
-		conn := &webRTCConn{pc: pc, dc: dc, pr: pr, eventLogger: sf.EventDispatcher}
-		conn.bytesLogger = newBytesSyncLogger()
+		conn := newWebRTCConn(pc, dc, pr, sf.EventDispatcher)
 
 		dc.OnOpen(func() {
 			log.Println("OnOpen channel")
diff --git a/proxy/lib/webrtcconn.go b/proxy/lib/webrtcconn.go
index 49f98d8..0a851df 100644
--- a/proxy/lib/webrtcconn.go
+++ b/proxy/lib/webrtcconn.go
@@ -34,6 +34,12 @@ type webRTCConn struct {
 	eventLogger event.SnowflakeEventReceiver
 }
 
+func newWebRTCConn(pc *webrtc.PeerConnection, dc *webrtc.DataChannel, pr *io.PipeReader, eventLogger event.SnowflakeEventReceiver) (*webRTCConn) {
+	conn := &webRTCConn{pc: pc, dc: dc, pr: pr, eventLogger: eventLogger}
+	conn.bytesLogger = newBytesSyncLogger()
+	return conn
+}
+
 func (c *webRTCConn) Read(b []byte) (int, error) {
 	return c.pr.Read(b)
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits