From 10dcb7a3ada4a3f197d2348f1cb893aebe88a5b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=9F=E6=B9=96=E9=A3=8E=E8=BD=BB?= <490021209@qq.com> Date: Thu, 11 May 2023 18:42:24 +0800 Subject: [PATCH] Fix: PacketConn's internal remote address is overwritten (#2727) When using vmess + fake-ip, after receiving the first UDP response, PacketConn's internal address will be rewritten to fake-ip, causing all subsequent sending operations to return "ErrUDPRemoteAddrMismatch". Signed-off-by: Hackerl <490021209@qq.com> --- tunnel/connection.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tunnel/connection.go b/tunnel/connection.go index 0614603..c220908 100644 --- a/tunnel/connection.go +++ b/tunnel/connection.go @@ -39,7 +39,7 @@ func handleUDPToLocal(packet C.UDPPacket, pc net.PacketConn, key string, oAddr, return } - fromUDPAddr := from.(*net.UDPAddr) + fromUDPAddr := *from.(*net.UDPAddr) if fAddr.IsValid() { fromAddr, _ := netip.AddrFromSlice(fromUDPAddr.IP) fromAddr = fromAddr.Unmap() @@ -48,7 +48,7 @@ func handleUDPToLocal(packet C.UDPPacket, pc net.PacketConn, key string, oAddr, } } - _, err = packet.WriteBack(buf[:n], fromUDPAddr) + _, err = packet.WriteBack(buf[:n], &fromUDPAddr) if err != nil { return }