1
0

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>
This commit is contained in:
江湖风轻 2023-05-11 18:42:24 +08:00 committed by GitHub
parent 4c3c64a34a
commit 10dcb7a3ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,7 +39,7 @@ func handleUDPToLocal(packet C.UDPPacket, pc net.PacketConn, key string, oAddr,
return return
} }
fromUDPAddr := from.(*net.UDPAddr) fromUDPAddr := *from.(*net.UDPAddr)
if fAddr.IsValid() { if fAddr.IsValid() {
fromAddr, _ := netip.AddrFromSlice(fromUDPAddr.IP) fromAddr, _ := netip.AddrFromSlice(fromUDPAddr.IP)
fromAddr = fromAddr.Unmap() 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 { if err != nil {
return return
} }