From ac3fd60d545df855c1872fec1fc1d553bbee6f8d Mon Sep 17 00:00:00 2001 From: Dreamacro <8615343+Dreamacro@users.noreply.github.com> Date: Thu, 10 Aug 2023 13:01:34 +0800 Subject: [PATCH] Fix: socks5 udp associate --- adapter/outbound/socks5.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adapter/outbound/socks5.go b/adapter/outbound/socks5.go index 4f81621..9b11bac 100644 --- a/adapter/outbound/socks5.go +++ b/adapter/outbound/socks5.go @@ -7,6 +7,7 @@ import ( "fmt" "io" "net" + "net/netip" "strconv" "github.com/Dreamacro/clash/component/dialer" @@ -110,7 +111,8 @@ func (ss *Socks5) ListenPacketContext(ctx context.Context, metadata *C.Metadata, } } - bindAddr, err := socks5.ClientHandshake(c, serializesSocksAddr(metadata), socks5.CmdUDPAssociate, user) + udpAssocateAddr := socks5.AddrFromStdAddrPort(netip.AddrPortFrom(netip.IPv4Unspecified(), 0)) + bindAddr, err := socks5.ClientHandshake(c, udpAssocateAddr, socks5.CmdUDPAssociate, user) if err != nil { err = fmt.Errorf("client hanshake error: %w", err) return