Commit dfb83c66 authored by David Fifield's avatar David Fifield
Browse files

Allow handling multiple SOCKS connections simultaneously.

Close the SOCKS connection in the same function that opens it.
parent 20ac2029
...@@ -25,7 +25,6 @@ func Handler(socks SocksConnector, snowflakes SnowflakeCollector) error { ...@@ -25,7 +25,6 @@ func Handler(socks SocksConnector, snowflakes SnowflakeCollector) error {
return errors.New("handler: Received invalid Snowflake") return errors.New("handler: Received invalid Snowflake")
} }
defer socks.Close()
defer snowflake.Close() defer snowflake.Close()
log.Println("---- Handler: snowflake assigned ----") log.Println("---- Handler: snowflake assigned ----")
err := socks.Grant(&net.TCPAddr{IP: net.IPv4zero, Port: 0}) err := socks.Grant(&net.TCPAddr{IP: net.IPv4zero, Port: 0})
......
...@@ -57,10 +57,13 @@ func socksAcceptLoop(ln *pt.SocksListener, snowflakes sf.SnowflakeCollector) { ...@@ -57,10 +57,13 @@ func socksAcceptLoop(ln *pt.SocksListener, snowflakes sf.SnowflakeCollector) {
break break
} }
log.Printf("SOCKS accepted: %v", conn.Req) log.Printf("SOCKS accepted: %v", conn.Req)
err = sf.Handler(conn, snowflakes) go func() {
if err != nil { defer conn.Close()
log.Printf("handler error: %s", err) err = sf.Handler(conn, snowflakes)
} if err != nil {
log.Printf("handler error: %s", err)
}
}()
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment