diff --git a/go.mod b/go.mod index 3a29ddb..8d190a2 100644 --- a/go.mod +++ b/go.mod @@ -7,4 +7,4 @@ require ( github.com/caarlos0/env/v6 v6.10.1 ) -require golang.org/x/net v0.1.0 // indirect +require golang.org/x/net v0.17.0 diff --git a/go.sum b/go.sum index 95fdbdc..49b7c69 100644 --- a/go.sum +++ b/go.sum @@ -2,5 +2,5 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/caarlos0/env/v6 v6.10.1 h1:t1mPSxNpei6M5yAeu1qtRdPAK29Nbcf/n3G7x+b3/II= github.com/caarlos0/env/v6 v6.10.1/go.mod h1:hvp/ryKXKipEkcuYjs9mI4bBCg+UI0Yhgm5Zu0ddvwc= -golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0= -golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= diff --git a/vendor/github.com/armon/go-socks5/socks5.go b/vendor/github.com/armon/go-socks5/socks5.go index 2d630fb..a17be68 100644 --- a/vendor/github.com/armon/go-socks5/socks5.go +++ b/vendor/github.com/armon/go-socks5/socks5.go @@ -55,7 +55,6 @@ type Config struct { type Server struct { config *Config authMethods map[uint8]Authenticator - isIPAllowed func(net.IP) bool } // New creates a new Server and potentially returns an error @@ -94,11 +93,6 @@ func New(conf *Config) (*Server, error) { server.authMethods[a.GetCode()] = a } - // Set default IP whitelist function - server.isIPAllowed = func(ip net.IP) bool { - return true // default allow all IPs - } - return server, nil } @@ -123,37 +117,11 @@ func (s *Server) Serve(l net.Listener) error { return nil } -// SetIPWhitelist sets the function to check if a given IP is allowed -func (s *Server) SetIPWhitelist(allowedIPs []net.IP) { - s.isIPAllowed = func(ip net.IP) bool { - for _, allowedIP := range allowedIPs { - if ip.Equal(allowedIP) { - return true - } - } - return false - } -} - // ServeConn is used to serve a single connection. func (s *Server) ServeConn(conn net.Conn) error { defer conn.Close() bufConn := bufio.NewReader(conn) - // Check client IP against whitelist - clientIP, _, err := net.SplitHostPort(conn.RemoteAddr().String()) - if err != nil { - s.config.Logger.Printf("[ERR] socks: Failed to get client IP address: %v", err) - return err - } - ip := net.ParseIP(clientIP) - if s.isIPAllowed(ip) { - s.config.Logger.Printf("[INFO] socks: Connection from allowed IP address: %s", clientIP) - } else { - s.config.Logger.Printf("[WARN] socks: Connection from not allowed IP address: %s", clientIP) - return fmt.Errorf("connection from not allowed IP address") - } - // Read the version byte version := []byte{0} if _, err := bufConn.Read(version); err != nil { diff --git a/vendor/modules.txt b/vendor/modules.txt index 6129cc3..3999332 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -4,6 +4,6 @@ github.com/armon/go-socks5 # github.com/caarlos0/env/v6 v6.10.1 ## explicit; go 1.17 github.com/caarlos0/env/v6 -# golang.org/x/net v0.1.0 +# golang.org/x/net v0.17.0 ## explicit; go 1.17 golang.org/x/net/context