mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Fix error handling around transport.Dial.
The code checked for and displayed an error, but would then go on to call copyLoop on the nil Conn returned from transport.Dial. Add a return in that case, and put the cleanup operations in defer. Also remove an obsolete comment about an empty address. Obsolete because: https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/merge_requests/31#note_2733279
This commit is contained in:
parent
ef4d0a1da5
commit
01a96c7d95
1 changed files with 3 additions and 5 deletions
|
@ -69,17 +69,15 @@ func socksAcceptLoop(ln *pt.SocksListener, transport *sf.Transport, shutdown cha
|
|||
|
||||
handler := make(chan struct{})
|
||||
go func() {
|
||||
// pass an empty address because the broker chooses the bridge
|
||||
defer close(handler)
|
||||
sconn, err := transport.Dial()
|
||||
if err != nil {
|
||||
log.Printf("dial error: %s", err)
|
||||
return
|
||||
}
|
||||
defer sconn.Close()
|
||||
// copy between the created Snowflake conn and the SOCKS conn
|
||||
copyLoop(conn, sconn)
|
||||
sconn.Close()
|
||||
close(handler)
|
||||
return
|
||||
|
||||
}()
|
||||
select {
|
||||
case <-shutdown:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue