commit dfb83c6606fe129d57f101d837ebe32133d79c61 Author: David Fifield david@bamsoftware.com Date: Tue Jan 28 03:10:54 2020 -0700
Allow handling multiple SOCKS connections simultaneously.
Close the SOCKS connection in the same function that opens it. --- client/lib/snowflake.go | 1 - client/snowflake.go | 11 +++++++---- 2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/client/lib/snowflake.go b/client/lib/snowflake.go index a27c6a5..9ab6fc6 100644 --- a/client/lib/snowflake.go +++ b/client/lib/snowflake.go @@ -25,7 +25,6 @@ func Handler(socks SocksConnector, snowflakes SnowflakeCollector) error {
return errors.New("handler: Received invalid Snowflake") } - defer socks.Close() defer snowflake.Close() log.Println("---- Handler: snowflake assigned ----") err := socks.Grant(&net.TCPAddr{IP: net.IPv4zero, Port: 0}) diff --git a/client/snowflake.go b/client/snowflake.go index 7cb9451..af416be 100644 --- a/client/snowflake.go +++ b/client/snowflake.go @@ -57,10 +57,13 @@ func socksAcceptLoop(ln *pt.SocksListener, snowflakes sf.SnowflakeCollector) { break } log.Printf("SOCKS accepted: %v", conn.Req) - err = sf.Handler(conn, snowflakes) - if err != nil { - log.Printf("handler error: %s", err) - } + go func() { + defer conn.Close() + err = sf.Handler(conn, snowflakes) + if err != nil { + log.Printf("handler error: %s", err) + } + }() } }
tor-commits@lists.torproject.org