diff options
author | David Fifield <david@bamsoftware.com> | 2021-05-24 14:36:24 -0600 |
---|---|---|
committer | David Fifield <david@bamsoftware.com> | 2021-05-24 14:40:50 -0600 |
commit | 01a96c7d95bfcc6ec5b6a770c8a56ef7da6605f4 (patch) | |
tree | 3d6c6a1bdba429d115106ff500ceef021ed01afb | |
parent | ef4d0a1da56e15327173923fa14a28d9ca40789c (diff) | |
download | snowflake-01a96c7d95bfcc6ec5b6a770c8a56ef7da6605f4.tar.gz snowflake-01a96c7d95bfcc6ec5b6a770c8a56ef7da6605f4.zip |
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
-rw-r--r-- | client/snowflake.go | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/client/snowflake.go b/client/snowflake.go index f19afcf..bacc389 100644 --- a/client/snowflake.go +++ b/client/snowflake.go @@ -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: |