[tor-commits] [snowflake/main] Suppress connection end log output

cohosh at torproject.org cohosh at torproject.org
Tue Jan 18 19:34:10 UTC 2022


commit 50646698e3e213fd9e714c327463eed87c4fb5f3
Author: Shelikhoo <xiaokangwang at outlook.com>
Date:   Thu Jan 6 20:31:15 2022 +0000

    Suppress connection end log output
    
    This is an amendment of https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/merge_requests/30
---
 server/lib/snowflake.go | 3 ++-
 server/server.go        | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/server/lib/snowflake.go b/server/lib/snowflake.go
index 8942286..31b6a20 100644
--- a/server/lib/snowflake.go
+++ b/server/lib/snowflake.go
@@ -38,6 +38,7 @@ package snowflake_server
 
 import (
 	"crypto/tls"
+	"errors"
 	"fmt"
 	"io"
 	"log"
@@ -262,7 +263,7 @@ func (l *SnowflakeListener) acceptSessions(ln *kcp.Listener) error {
 		go func() {
 			defer conn.Close()
 			err := l.acceptStreams(conn)
-			if err != nil && err != io.ErrClosedPipe {
+			if err != nil && !errors.Is(err, io.ErrClosedPipe) {
 				log.Printf("acceptStreams: %v", err)
 			}
 		}()
diff --git a/server/server.go b/server/server.go
index 820a0a5..4b53c86 100644
--- a/server/server.go
+++ b/server/server.go
@@ -3,6 +3,7 @@
 package main
 
 import (
+	"errors"
 	"flag"
 	"fmt"
 	"io"
@@ -47,7 +48,7 @@ func proxy(local *net.TCPConn, conn net.Conn) {
 	wg.Add(2)
 
 	go func() {
-		if _, err := io.Copy(conn, local); err != nil && err != io.ErrClosedPipe {
+		if _, err := io.Copy(conn, local); err != nil && !errors.Is(err, io.ErrClosedPipe) {
 			log.Printf("error copying ORPort to WebSocket %v", err)
 		}
 		local.CloseRead()
@@ -55,7 +56,7 @@ func proxy(local *net.TCPConn, conn net.Conn) {
 		wg.Done()
 	}()
 	go func() {
-		if _, err := io.Copy(local, conn); err != nil && err != io.ErrClosedPipe {
+		if _, err := io.Copy(local, conn); err != nil && !errors.Is(err, io.ErrClosedPipe) {
 			log.Printf("error copying WebSocket to ORPort %v", err)
 		}
 		local.CloseWrite()





More information about the tor-commits mailing list