From 6393fadf11c8ade268376bb0ce107a9d8c709e0a Mon Sep 17 00:00:00 2001 From: dyhkwong <50692134+dyhkwong@users.noreply.github.com> Date: Tue, 9 Apr 2024 23:09:02 +0800 Subject: [PATCH] Fix socks5 udp associate address --- protocol/socks/handshake.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/protocol/socks/handshake.go b/protocol/socks/handshake.go index a8736ff4..27c9b389 100644 --- a/protocol/socks/handshake.go +++ b/protocol/socks/handshake.go @@ -76,6 +76,9 @@ func ClientHandshake5(conn io.ReadWriter, command byte, destination M.Socksaddr, } else if authResponse.Method != socks5.AuthTypeNotRequired { return socks5.Response{}, E.New("socks5: unsupported auth method: ", authResponse.Method) } + if command == socks5.CommandUDPAssociate { + destination = M.SocksaddrFrom(netip.IPv4Unspecified(), 0) + } err = socks5.WriteRequest(conn, socks5.Request{ Command: command, Destination: destination, @@ -215,6 +218,7 @@ func HandleConnection0(ctx context.Context, conn net.Conn, version byte, authent if err != nil { return err } + request.Destination = M.SocksaddrFrom(netip.IPv4Unspecified(), 0) metadata.Protocol = "socks5" metadata.Destination = request.Destination var innerError error