summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Fifield <david@bamsoftware.com>2017-08-02 20:29:55 -0700
committerDavid Fifield <david@bamsoftware.com>2017-08-02 20:29:55 -0700
commitbe4c2fdd5e0780d11386e7157cf92a9ea035b4c3 (patch)
tree2c74d8daea082e51261959411ff668e49b93edde
parent485538bcf00bd4ddaeb5f81dd05e3caaa89ffd6d (diff)
Call conn.RemoteAddr() before entering the datachannelHandler goroutine.
This is a workaround for the hang described at https://bugs.torproject.org/18628#comment:8
-rw-r--r--proxy-go/snowflake.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/proxy-go/snowflake.go b/proxy-go/snowflake.go
index 4e46ee4..133bc0e 100644
--- a/proxy-go/snowflake.go
+++ b/proxy-go/snowflake.go
@@ -202,15 +202,19 @@ func CopyLoopTimeout(c1 net.Conn, c2 net.Conn, timeout time.Duration) {
wg.Wait()
}
-func datachannelHandler(conn *webRTCConn) {
+// We pass conn.RemoteAddr() as an additional parameter, rather than calling
+// conn.RemoteAddr() inside this function, as a workaround for a hang that
+// otherwise occurs inside of conn.pc.RemoteDescription() (called by
+// RemoteAddr). https://bugs.torproject.org/18628#comment:8
+func datachannelHandler(conn *webRTCConn, remoteAddr net.Addr) {
defer conn.Close()
defer retToken()
// Retrieve client IP address
- if conn.RemoteAddr() != nil && conn.RemoteAddr().String() != "" {
+ if remoteAddr != nil && remoteAddr.String() != "" {
// Encode client IP address in relay URL
q := opt.relayURL.Query()
- clientIP := conn.RemoteAddr().String()
+ clientIP := remoteAddr.String()
q.Set("client_ip", clientIP)
opt.relayURL.RawQuery = q.Encode()
} else {
@@ -271,7 +275,7 @@ func makePeerConnectionFromOffer(sdp *webrtc.SessionDescription, config *webrtc.
}
conn := &webRTCConn{pc: pc, dc: dc, pr: pr}
- go datachannelHandler(conn)
+ go datachannelHandler(conn, conn.RemoteAddr())
}
err = pc.SetRemoteDescription(sdp)