1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-17 18:06:15 -05:00

fix: set TTL for incoming UDP IP packets from TUN with PacketAddr dispatcher

Fixes UDP packets being dropped in non-local routing path(e.g. forwarding to LAN or container veth) due to 0-TTL.
This commit is contained in:
Huang-Huang Bao 2023-10-29 07:34:48 +08:00 committed by Xiaokang Wang (Shelikhoo)
parent c0a0ce29e3
commit 42c50d25e1

View File

@ -78,6 +78,7 @@ func constructIPv4UDPPacket(src, dst net.Destination, data []byte) ([]byte, erro
Protocol: layers.IPProtocolUDP, Protocol: layers.IPProtocolUDP,
SrcIP: src.Address.IP(), SrcIP: src.Address.IP(),
DstIP: dst.Address.IP(), DstIP: dst.Address.IP(),
TTL: 64, // set TTL to a reasonable non-zero value to allow non-local routing
} }
udp := &layers.UDP{ udp := &layers.UDP{
SrcPort: layers.UDPPort(src.Port), SrcPort: layers.UDPPort(src.Port),
@ -103,6 +104,7 @@ func constructIPv6UDPPacket(src, dst net.Destination, data []byte) ([]byte, erro
NextHeader: layers.IPProtocolUDP, NextHeader: layers.IPProtocolUDP,
SrcIP: src.Address.IP(), SrcIP: src.Address.IP(),
DstIP: dst.Address.IP(), DstIP: dst.Address.IP(),
HopLimit: 64,
} }
udp := &layers.UDP{ udp := &layers.UDP{
SrcPort: layers.UDPPort(src.Port), SrcPort: layers.UDPPort(src.Port),