diff options
-rw-r--r-- | modes/transparent_tcp/transparent_tcp.go | 26 | ||||
-rw-r--r-- | modes/transparent_udp/transparent_udp.go | 2 | ||||
-rw-r--r-- | shapeshifter-dispatcher/shapeshifter-dispatcher.go | 6 |
3 files changed, 16 insertions, 18 deletions
diff --git a/modes/transparent_tcp/transparent_tcp.go b/modes/transparent_tcp/transparent_tcp.go index 33534e7..51ec43b 100644 --- a/modes/transparent_tcp/transparent_tcp.go +++ b/modes/transparent_tcp/transparent_tcp.go @@ -30,8 +30,8 @@ package transparent_tcp import ( - "fmt" options2 "github.com/OperatorFoundation/shapeshifter-dispatcher/common" + "github.com/OperatorFoundation/shapeshifter-dispatcher/common/pt_extras" "github.com/OperatorFoundation/shapeshifter-dispatcher/transports" "github.com/OperatorFoundation/shapeshifter-transports/transports/Dust" @@ -74,14 +74,16 @@ func ClientSetup(termMon *termmon.TermMonitor, socksAddr string, target string, return } -func clientAcceptLoop(target string, termMon *termmon.TermMonitor, name string, options string, ln net.Listener, proxyURI *url.URL) error { +func clientAcceptLoop(target string, termMon *termmon.TermMonitor, name string, options string, ln net.Listener, proxyURI *url.URL) { defer ln.Close() for { conn, err := ln.Accept() if err != nil { if e, ok := err.(net.Error); ok && !e.Temporary() { - return err + log.Errorf("Fatal listener error: %s", err.Error()) + return } + log.Warnf("Failed to accept connection: %s", err.Error()) continue } go clientHandler(target, termMon, name, options, conn, proxyURI) @@ -131,7 +133,7 @@ func clientHandler(target string, termMon *termmon.TermMonitor, name string, opt // return // } if err != nil { - fmt.Errorf("outgoing connection failed %q %q", f, target) + log.Errorf("outgoing connection failed %q", target) return } @@ -142,12 +144,8 @@ func clientHandler(target string, termMon *termmon.TermMonitor, name string, opt } else { log.Infof("%s(%s) - closed connection", name, target) } - - return } - - func ServerSetup(termMon *termmon.TermMonitor, bindaddrString string, ptServerInfo pt.ServerInfo, statedir string, options string) (launched bool, listeners []net.Listener) { // Launch each of the server listeners. for _, bindaddr := range ptServerInfo.Bindaddrs { @@ -260,13 +258,13 @@ func getServerBindaddrs(serverBindaddr string) ([]pt.Bindaddr, error) { parts := strings.SplitN(spec, "-", 2) if len(parts) != 2 { - fmt.Errorf("TOR_PT_SERVER_BINDADDR: doesn't contain \"-\" %q", spec) + log.Errorf("TOR_PT_SERVER_BINDADDR: doesn't contain \"-\" %q", spec) return nil, nil } bindaddr.MethodName = parts[0] addr, err := pt.ResolveAddr(parts[1]) if err != nil { - fmt.Errorf("TOR_PT_SERVER_BINDADDR: %q %q", spec, err.Error()) + log.Errorf("TOR_PT_SERVER_BINDADDR: %q %q", spec, err.Error()) return nil, nil } bindaddr.Addr = addr @@ -277,14 +275,16 @@ func getServerBindaddrs(serverBindaddr string) ([]pt.Bindaddr, error) { return result, nil } -func serverAcceptLoop(termMon *termmon.TermMonitor, name string, ln net.Listener, info *pt.ServerInfo) error { +func serverAcceptLoop(termMon *termmon.TermMonitor, name string, ln net.Listener, info *pt.ServerInfo) { defer ln.Close() for { conn, err := ln.Accept() if err != nil { if e, ok := err.(net.Error); ok && !e.Temporary() { - return err + log.Errorf("Fatal listener error: %s", err.Error()) + return } + log.Warnf("Failed to accept connection: %s", err.Error()) continue } go serverHandler(termMon, name, conn, info) @@ -308,8 +308,6 @@ func serverHandler(termMon *termmon.TermMonitor, name string, remote net.Conn, i } else { log.Infof("%s - closed connection", name) } - - return } func copyLoop(a net.Conn, b net.Conn) error { diff --git a/modes/transparent_udp/transparent_udp.go b/modes/transparent_udp/transparent_udp.go index c324946..f40da14 100644 --- a/modes/transparent_udp/transparent_udp.go +++ b/modes/transparent_udp/transparent_udp.go @@ -83,7 +83,7 @@ func ClientSetup(termMon *termmon.TermMonitor, socksAddr string, target string, go clientHandler(target, termMon, name, options, ln, ptClientProxy) - log.Infof("%s - registered listener: %s", name, ln) + log.Infof("%s - registered listener", name) } return true diff --git a/shapeshifter-dispatcher/shapeshifter-dispatcher.go b/shapeshifter-dispatcher/shapeshifter-dispatcher.go index f68d18c..d7f49e4 100644 --- a/shapeshifter-dispatcher/shapeshifter-dispatcher.go +++ b/shapeshifter-dispatcher/shapeshifter-dispatcher.go @@ -311,7 +311,7 @@ func getClientNames(ptversion *string, transportsList *string, proxy *string) (c // FIXME - instead of this, goptlib should be modified to accept command line flag override of EITHER ptversion or transports (or both) if ptversion == nil || transportsList == nil { - log.Infof("Falling back to environment variables for ptversion/transports %q %q", ptversion, transportsList) + log.Infof("Falling back to environment variables for ptversion/transports %q %q", *ptversion, *transportsList) ptClientInfo, err = pt.ClientSetup(transports.Transports()) if err != nil { // FIXME - print a more useful error, specifying --ptversion and --transports flags @@ -349,7 +349,7 @@ func getServerInfo(ptversion *string, bindaddrList *string, options *string, tra ptServerInfo = pt.ServerInfo{Bindaddrs: bindaddrs} ptServerInfo.OrAddr, err = pt.ResolveAddr(*orport) if err != nil { - log.Errorf("Error resolving OR address %q %q", orport, err) + log.Errorf("Error resolving OR address %q %q", *orport, err) return ptServerInfo } @@ -368,7 +368,7 @@ func getServerInfo(ptversion *string, bindaddrList *string, options *string, tra } else { ptServerInfo.ExtendedOrAddr, err = pt.ResolveAddr(pt.Getenv("TOR_PT_EXTENDED_SERVER_PORT")) if err != nil { - log.Errorf("Error resolving Extended OR address %q %q", err) + log.Errorf("Error resolving Extended OR address %q", err) return ptServerInfo } } |