Bump golang.org/x/net from 0.1.0 to 0.17.0

Bumps [golang.org/x/net](https://github.com/golang/net) from 0.1.0 to 0.17.0.
- [Commits](https://github.com/golang/net/compare/v0.1.0...v0.17.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2023-10-11 22:23:38 +00:00
committed by GitHub
parent d0347549a4
commit 93554c03aa
4 changed files with 4 additions and 36 deletions
-32
View File
@@ -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 {