Merge pull request #48 from serjs/dependabot/go_modules/golang.org/x/net-0.17.0

Bump golang.org/x/net from 0.1.0 to 0.17.0
This commit is contained in:
Sergey Bogatyrets 2024-02-26 07:09:16 +03:00 committed by GitHub
commit c30bfd3d72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 4 additions and 36 deletions

2
go.mod
View File

@ -7,4 +7,4 @@ require (
github.com/caarlos0/env/v6 v6.10.1 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

4
go.sum
View File

@ -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/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 h1:t1mPSxNpei6M5yAeu1qtRdPAK29Nbcf/n3G7x+b3/II=
github.com/caarlos0/env/v6 v6.10.1/go.mod h1:hvp/ryKXKipEkcuYjs9mI4bBCg+UI0Yhgm5Zu0ddvwc= 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.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=

View File

@ -55,7 +55,6 @@ type Config struct {
type Server struct { type Server struct {
config *Config config *Config
authMethods map[uint8]Authenticator authMethods map[uint8]Authenticator
isIPAllowed func(net.IP) bool
} }
// New creates a new Server and potentially returns an error // 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 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 return server, nil
} }
@ -123,37 +117,11 @@ func (s *Server) Serve(l net.Listener) error {
return nil 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. // ServeConn is used to serve a single connection.
func (s *Server) ServeConn(conn net.Conn) error { func (s *Server) ServeConn(conn net.Conn) error {
defer conn.Close() defer conn.Close()
bufConn := bufio.NewReader(conn) 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 // Read the version byte
version := []byte{0} version := []byte{0}
if _, err := bufConn.Read(version); err != nil { if _, err := bufConn.Read(version); err != nil {

2
vendor/modules.txt vendored
View File

@ -4,6 +4,6 @@ github.com/armon/go-socks5
# github.com/caarlos0/env/v6 v6.10.1 # github.com/caarlos0/env/v6 v6.10.1
## explicit; go 1.17 ## explicit; go 1.17
github.com/caarlos0/env/v6 github.com/caarlos0/env/v6
# golang.org/x/net v0.1.0 # golang.org/x/net v0.17.0
## explicit; go 1.17 ## explicit; go 1.17
golang.org/x/net/context golang.org/x/net/context