summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYawning Angel <yawning@torproject.org>2014-08-20 22:44:07 +0000
committerYawning Angel <yawning@torproject.org>2014-08-20 22:44:07 +0000
commit596cc8507340a1233defe5bf88e6e2a400cc7f9f (patch)
tree47a00483b8e4e1294bf4664bd492bfb597e37e48
parentdd9fdee55d75e23fff97177999b7fd16613fa27a (diff)
Elide the error out from most logs unless unsafeLogging is set.
The Golang runtime will happily splatter the remote IP address and port in the error's string representation for network related errors. While useful for debugging, this is unacceptable from a privacy standpoint.
-rw-r--r--obfs4proxy/obfs4proxy.go34
1 files changed, 27 insertions, 7 deletions
diff --git a/obfs4proxy/obfs4proxy.go b/obfs4proxy/obfs4proxy.go
index 8820127..7ba0e93 100644
--- a/obfs4proxy/obfs4proxy.go
+++ b/obfs4proxy/obfs4proxy.go
@@ -167,7 +167,11 @@ func clientHandler(f base.ClientFactory, conn *pt.SocksConn, proxyURI *url.URL)
// the configuration phase.
dialer, err := proxy.FromURL(proxyURI, proxy.Direct)
if err != nil {
- log.Printf("[ERROR]: %s(%s) - failed to obtain proxy dialer: %s", name, addrStr, err)
+ if unsafeLogging {
+ log.Printf("[ERROR]: %s(%s) - failed to obtain proxy dialer: %s", name, addrStr, err)
+ } else {
+ log.Printf("[ERROR]: %s(%s) - failed to obtain proxy dialer", name, addrStr)
+ }
conn.Reject()
return
}
@@ -191,18 +195,26 @@ func clientHandler(f base.ClientFactory, conn *pt.SocksConn, proxyURI *url.URL)
// bytes back and forth.
remote, err := f.WrapConn(remoteConn, args)
if err != nil {
- log.Printf("[ERROR]: %s(%s) - handshake failed: %s", name, addrStr, err)
+ if unsafeLogging {
+ log.Printf("[ERROR]: %s(%s) - handshake failed: %s", name, addrStr, err)
+ } else {
+ log.Printf("[ERROR]: %s(%s) - handshake failed", name, addrStr)
+ }
conn.Reject()
return
}
err = conn.Grant(remoteConn.RemoteAddr().(*net.TCPAddr))
if err != nil {
- log.Printf("[ERROR]: %s(%s) - SOCKS grant failed: %s", name, addrStr, err)
+ if unsafeLogging {
+ log.Printf("[ERROR]: %s(%s) - SOCKS grant failed: %s", name, addrStr, err)
+ } else {
+ log.Printf("[ERROR]: %s(%s) - SOCKS grant failed", name, addrStr)
+ }
return
}
err = copyLoop(conn, remote)
- if err != nil {
+ if err != nil && unsafeLogging {
log.Printf("[INFO]: %s(%s) - closed connection: %s", name, addrStr, err)
} else {
log.Printf("[INFO]: %s(%s) - closed connection", name, addrStr)
@@ -282,20 +294,28 @@ func serverHandler(f base.ServerFactory, conn net.Conn, info *pt.ServerInfo) {
// Instantiate the server transport method and handshake.
remote, err := f.WrapConn(conn)
if err != nil {
- log.Printf("[ERROR]: %s(%s) - handshake failed: %s", name, addrStr, err)
+ if unsafeLogging {
+ log.Printf("[ERROR]: %s(%s) - handshake failed: %s", name, addrStr, err)
+ } else {
+ log.Printf("[ERROR]: %s(%s) - handshake failed", name, addrStr)
+ }
return
}
// Connect to the orport.
orConn, err := pt.DialOr(info, conn.RemoteAddr().String(), name)
if err != nil {
- log.Printf("[ERROR]: %s(%s) - failed to connect to ORPort: %s", name, addrStr, err)
+ if unsafeLogging {
+ log.Printf("[ERROR]: %s(%s) - failed to connect to ORPort: %s", name, addrStr, err)
+ } else {
+ log.Printf("[ERROR]: %s(%s) - failed to connect to ORPort", name, addrStr)
+ }
return
}
defer orConn.Close()
err = copyLoop(orConn, remote)
- if err != nil {
+ if err != nil && unsafeLogging {
log.Printf("[INFO]: %s(%s) - closed connection: %s", name, addrStr, err)
} else {
log.Printf("[INFO]: %s(%s) - closed connection", name, addrStr)