commit 1d1882b59db87a5e4ff7fabdc1ffff29908a2d44 Author: Serene Han keroserene+git@gmail.com Date: Tue Mar 29 22:28:52 2016 -0700
webRTCConn close as part of its reset, instead of depending on external deferred close after receiving reset channel, allows valid disconnections even before use --- client/snowflake.go | 3 +-- client/webrtc.go | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/client/snowflake.go b/client/snowflake.go index 8f4a6bd..8a03148 100644 --- a/client/snowflake.go +++ b/client/snowflake.go @@ -21,7 +21,7 @@ import ( var ptInfo pt.ClientInfo
const ( - ReconnectTimeout = 5 + ReconnectTimeout = 10 SnowflakeCapacity = 3 )
@@ -109,7 +109,6 @@ func handler(conn *pt.SocksConn) error { conn.Reject() return errors.New("handler: Received invalid Snowflake") } - defer remote.Close() defer conn.Close() log.Println("handler: Snowflake assigned.")
diff --git a/client/webrtc.go b/client/webrtc.go index 2b907ad..5b30e95 100644 --- a/client/webrtc.go +++ b/client/webrtc.go @@ -291,13 +291,14 @@ func (c *webRTCConn) Reset() { c.reset <- struct{}{} log.Println("WebRTC resetting...") }() + c.Close() }
func (c *webRTCConn) cleanup() { if nil != c.snowflake { s := c.snowflake log.Printf("WebRTC: closing DataChannel") - // Setting snowflak to nil *before* Close indicates to OnClose that it + // Setting snowflake to nil *before* Close indicates to OnClose that it // was locally triggered. c.snowflake = nil s.Close()