mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Allow handling multiple SOCKS connections simultaneously.
Close the SOCKS connection in the same function that opens it.
This commit is contained in:
parent
20ac2029fd
commit
dfb83c6606
2 changed files with 7 additions and 5 deletions
|
@ -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})
|
||||
|
|
|
@ -57,10 +57,13 @@ func socksAcceptLoop(ln *pt.SocksListener, snowflakes sf.SnowflakeCollector) {
|
|||
break
|
||||
}
|
||||
log.Printf("SOCKS accepted: %v", conn.Req)
|
||||
go func() {
|
||||
defer conn.Close()
|
||||
err = sf.Handler(conn, snowflakes)
|
||||
if err != nil {
|
||||
log.Printf("handler error: %s", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue