Skip to content

Commit b11fcf0

Browse files
authored
SOCKS4a: Check if the client sends an IP address as domain
Fix #3622
1 parent 7e24239 commit b11fcf0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

proxy/socks/protocol.go

+8
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,20 @@ func (s *ServerSession) handshake4(cmd byte, reader io.Reader, writer io.Writer)
6969
if _, err := ReadUntilNull(reader); /* user id */ err != nil {
7070
return nil, err
7171
}
72+
// Sock4a domain
7273
if address.IP()[0] == 0x00 {
7374
domain, err := ReadUntilNull(reader)
7475
if err != nil {
7576
return nil, errors.New("failed to read domain for socks 4a").Base(err)
7677
}
7778
address = net.DomainAddress(domain)
79+
// Check if the client sends an IP address as domain
80+
if len(domain) > 0 && (domain[0] >= '0' && domain[0] <= '9') {
81+
addr := net.ParseAddress(domain)
82+
if addr.Family().IsIP() {
83+
address = addr
84+
}
85+
}
7886
}
7987

8088
switch cmd {

0 commit comments

Comments
 (0)