Improve the request for UDP Associate in Socks5

This commit is contained in:
RPRX 2021-01-26 23:53:01 +00:00 committed by GitHub
parent 59c7c4897c
commit ceff4185dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -465,8 +465,12 @@ func ClientHandshake(request *protocol.RequestHeader, reader io.Reader, writer i
command = byte(cmdUDPAssociate)
}
common.Must2(b.Write([]byte{socks5Version, command, 0x00 /* reserved */}))
if err := addrParser.WriteAddressPort(b, request.Address, request.Port); err != nil {
return nil, err
if request.Command == protocol.RequestCommandUDP {
common.Must2(b.Write([]byte{1, 0, 0, 0, 0, 0, 0 /* RFC 1928 */}))
} else {
if err := addrParser.WriteAddressPort(b, request.Address, request.Port); err != nil {
return nil, err
}
}
if err := buf.WriteAllBytes(writer, b.Bytes()); err != nil {