diff options
-rw-r--r-- | client/main.go | 6 | ||||
-rw-r--r-- | server/main.go | 33 |
2 files changed, 22 insertions, 17 deletions
diff --git a/client/main.go b/client/main.go index 5cdfa4f..e9af09b 100644 --- a/client/main.go +++ b/client/main.go @@ -60,15 +60,15 @@ func main() { } } - addr := net.JoinHostPort(socksHost, socksPort) + socksAddr := net.JoinHostPort(socksHost, socksPort) server := &socks5.Server{ - Addr: addr, + Addr: socksAddr, BindIP: "127.0.0.1", Dial: dialer.Dial, } - fmt.Printf("[+] Starting socks5 proxy at %s\n", addr) + fmt.Printf("[+] Starting socks5 proxy at %s\n", socksAddr) if err := server.ListenAndServe(); err != nil { panic(err) } diff --git a/server/main.go b/server/main.go index f8b7d85..632b8de 100644 --- a/server/main.go +++ b/server/main.go @@ -131,7 +131,7 @@ func main() { conn, err := ln.Accept() if err != nil { debug.Printf("error accepting connection: %v", err) - return + continue } debug.Printf("accepted connection %v…", conn) go proxyConn(ctx, info, conn, logger, debug) @@ -152,24 +152,29 @@ func proxyConn(ctx context.Context, info *pt.ServerInfo, obfsConn net.Conn, logg log.Println("Obfs4 client:", obfsConn.RemoteAddr().String()) /* - in the case of Tor, pt.DialOr returns a *net.TCPConn after dialing info.OrAddr. - in the vpn case (or any transparent proxy really), we do use - the pt.DialOr method to simply get a dialer to our upstream VPN remote. + TODO(atanarjuat): - keeping this terminology is a bit stupid and slightly confusing, instead - we could get the clearConn just by doing: + in the case of Tor, pt.DialOr returns a *net.TCPConn after dialing info.OrAddr. + in the vpn case (or any transparent proxy really), we do use + the pt.DialOr method to simply get a dialer to our upstream VPN remote. - s, err := net.DialTCP("tcp", nil, info.ExtendedOrAddr) - if err != nil { - return nil, err - } + keeping this terminology is a bit stupid and slightly confusing, instead + we could get the clearConn just by doing: + + s, err := net.DialTCP("tcp", nil, info.ExtendedOrAddr) + if err != nil { + return nil, err + } - that is precisely what the code in ptlib is doing. + that is precisely what the code in ptlib is doing. - We also aspire at being a generic PT at some point, so perhaps it's better to keep the usage - of DialOr? + We also aspire at being a generic PT at some point, so perhaps it's better to keep the usage + of DialOr. Maybe not, and so we don't need to keep the confusing info struct. - Maybe not, and so we don't need to keep the confusing info struct. + Another argument in favor of doing our own dialing in here is that + we could have an UDP dialer. We need to think of a good way + to configure the server to distinguish between udp and tcp + upstream flows. */ // we'll refer to the connection to the usptream node as "clearConn", as opposed to the obfuscated conn. |