[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [snowflake/master] Remove erroneous logging around pt.*Error calls.



commit 5ff75e1034c8d4ae4ba64f92d9aef364d09c27ac
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date:   Mon Jan 20 23:57:31 2020 -0700

    Remove erroneous logging around pt.*Error calls.
    
    These functions are called for their side effect of sending a PT error
    message on stdout; they also return a representation of the error
    message as an error object for the caller to use if it wishes. These
    functions *always* return a non-nil error object; it is not something to
    be logged, any more than the return value of errors.New is.
    
    The mistaken logging was added in
    https://bugs.torproject.org/31794
    b26c7a7a7330586c3be3ece02c68999bb279ff40
    3ec9dd19faa8584dd76ba3b85eb71a03b8ee25c0
    ed3d42e1ec3ff852f8c4751eb4cf5e9ed4dd4a68
---
 client/snowflake.go        | 12 +++---------
 server-webrtc/snowflake.go |  4 +---
 server/server.go           | 12 +++---------
 3 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/client/snowflake.go b/client/snowflake.go
index bb7de46..3c496e0 100644
--- a/client/snowflake.go
+++ b/client/snowflake.go
@@ -157,9 +157,7 @@ func main() {
 		log.Fatal(err)
 	}
 	if ptInfo.ProxyURL != nil {
-		if err := pt.ProxyError("proxy is not supported"); err != nil {
-			log.Printf("call to pt.ProxyError generated error: %v", err)
-		}
+		pt.ProxyError("proxy is not supported")
 		os.Exit(1)
 	}
 	listeners := make([]net.Listener, 0)
@@ -169,18 +167,14 @@ func main() {
 			// TODO: Be able to recover when SOCKS dies.
 			ln, err := pt.ListenSocks("tcp", "127.0.0.1:0")
 			if err != nil {
-				if inerr := pt.CmethodError(methodName, err.Error()); inerr != nil {
-					log.Printf("handling error generated by pt.ListenSocks with pt.CmethodError generated error: %v", inerr)
-				}
+				pt.CmethodError(methodName, err.Error())
 				break
 			}
 			go socksAcceptLoop(ln, snowflakes)
 			pt.Cmethod(methodName, ln.Version(), ln.Addr())
 			listeners = append(listeners, ln)
 		default:
-			if err := pt.CmethodError(methodName, "no such method"); err != nil {
-				log.Printf("calling pt.CmethodError generated error: %v", err)
-			}
+			pt.CmethodError(methodName, "no such method")
 		}
 	}
 	pt.CmethodsDone()
diff --git a/server-webrtc/snowflake.go b/server-webrtc/snowflake.go
index d5b1604..acdf5b1 100644
--- a/server-webrtc/snowflake.go
+++ b/server-webrtc/snowflake.go
@@ -230,9 +230,7 @@ func main() {
 			bindaddr.Addr.Port = 12345 // lies!!!
 			pt.Smethod(bindaddr.MethodName, bindaddr.Addr)
 		default:
-			if err := pt.SmethodError(bindaddr.MethodName, "no such method"); err != nil {
-				log.Printf("SmethodError returned error: %v", err)
-			}
+			pt.SmethodError(bindaddr.MethodName, "no such method")
 		}
 	}
 	pt.SmethodsDone()
diff --git a/server/server.go b/server/server.go
index e3f4c6f..785b545 100644
--- a/server/server.go
+++ b/server/server.go
@@ -282,9 +282,7 @@ func main() {
 	servers := make([]*http.Server, 0)
 	for _, bindaddr := range ptInfo.Bindaddrs {
 		if bindaddr.MethodName != ptMethodName {
-			if err = pt.SmethodError(bindaddr.MethodName, "no such method"); err != nil {
-				log.Printf("pt.SmethodError returned error: %v", err)
-			}
+			pt.SmethodError(bindaddr.MethodName, "no such method")
 			continue
 		}
 
@@ -296,9 +294,7 @@ func main() {
 			lnHTTP01, err = net.ListenTCP("tcp", &addr)
 			if err != nil {
 				log.Printf("error opening HTTP-01 ACME listener: %s", err)
-				if inerr := pt.SmethodError(bindaddr.MethodName, "HTTP-01 ACME listener: "+err.Error()); inerr != nil {
-					log.Printf("pt.SmethodError returned error: %v", inerr)
-				}
+				pt.SmethodError(bindaddr.MethodName, "HTTP-01 ACME listener: "+err.Error())
 				continue
 			}
 			server := &http.Server{
@@ -326,9 +322,7 @@ func main() {
 		}
 		if err != nil {
 			log.Printf("error opening listener: %s", err)
-			if inerr := pt.SmethodError(bindaddr.MethodName, err.Error()); inerr != nil {
-				log.Printf("pt.SmethodError returned error: %v", inerr)
-			}
+			pt.SmethodError(bindaddr.MethodName, err.Error())
 			continue
 		}
 		pt.SmethodArgs(bindaddr.MethodName, bindaddr.Addr, args)

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits