Skip to content

Commit

Permalink
Fix: PacketConn's internal remote address is overwritten (#2727)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Hackerl authored May 11, 2023
1 parent 4c3c64a commit 10dcb7a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tunnel/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
}
Expand Down

0 comments on commit 10dcb7a

Please sign in to comment.