From 0d647390a206a4ed4e513e419869055408df9822 Mon Sep 17 00:00:00 2001 From: atanarjuat Date: Sun, 29 May 2022 18:31:44 +0200 Subject: do not return if error on accept --- server/main.go | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'server/main.go') 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. -- cgit v1.2.3