commit c0b6e082f2f30cbeca962937ea5a777b98cf3ebb Author: Cecylia Bocovich cohosh@torproject.org Date: Mon Mar 8 22:16:33 2021 -0500
Don't log errors from callng close on OR conns
Snowflake copies data between the OR connection and the KCP stream, meaning that in most cases the copy loops will only terminate once the OR connection times out. In this case the OR connection is already closed and so calls to CloseRead and CloseWrite will generate errors. --- server/server.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/server/server.go b/server/server.go index b3fa04a..620cd50 100644 --- a/server/server.go +++ b/server/server.go @@ -76,9 +76,7 @@ func proxy(local *net.TCPConn, conn net.Conn) { if _, err := io.Copy(conn, local); err != nil && err != io.ErrClosedPipe { log.Printf("error copying ORPort to WebSocket %v", err) } - if err := local.CloseRead(); err != nil { - log.Printf("error closing read after copying ORPort to WebSocket %v", err) - } + local.CloseRead() conn.Close() wg.Done() }() @@ -86,9 +84,7 @@ func proxy(local *net.TCPConn, conn net.Conn) { if _, err := io.Copy(local, conn); err != nil && err != io.ErrClosedPipe { log.Printf("error copying WebSocket to ORPort %v", err) } - if err := local.CloseWrite(); err != nil { - log.Printf("error closing write after copying WebSocket to ORPort %v", err) - } + local.CloseWrite() conn.Close() wg.Done() }()