Skip to content

Commit

Permalink
Socks4a server: Check if the client sends an IP address as domain (XT…
Browse files Browse the repository at this point in the history
  • Loading branch information
Fangliding authored and leninalive committed Oct 29, 2024
1 parent f2d60bb commit dd15584
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions common/net/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ func IPAddress(ip []byte) Address {
}

// DomainAddress creates an Address with given domain.
// This is an internal function that forcibly converts a string to domain.
// It's mainly used in test files and mux.
// Unless you have a specific reason, use net.ParseAddress instead,
// as this function does not check whether the input is an IP address.
// Otherwise, you will get strange results like domain: 1.1.1.1
func DomainAddress(domain string) Address {
return domainAddress(domain)
}
Expand Down
2 changes: 1 addition & 1 deletion proxy/socks/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (s *ServerSession) handshake4(cmd byte, reader io.Reader, writer io.Writer)
if err != nil {
return nil, errors.New("failed to read domain for socks 4a").Base(err)
}
address = net.DomainAddress(domain)
address = net.ParseAddress(domain)
}

switch cmd {
Expand Down

0 comments on commit dd15584

Please sign in to comment.