From 0a91893a2687b5cf07df31ec085d8c3d19eb1563 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Fri, 13 Jan 2017 17:10:07 +0100 Subject: [PATCH] handle IPv6 address in tproxy --- transport/internet/udp/hub_linux.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/transport/internet/udp/hub_linux.go b/transport/internet/udp/hub_linux.go index b385db72..540ef845 100644 --- a/transport/internet/udp/hub_linux.go +++ b/transport/internet/udp/hub_linux.go @@ -25,10 +25,14 @@ func RetrieveOriginalDest(oob []byte) v2net.Destination { return v2net.Destination{} } for _, msg := range msgs { - if msg.Header.Level == syscall.SOL_IP && msg.Header.Type == syscall.IP_ORIGDSTADDR { + if msg.Header.Level == syscall.SOL_IP && msg.Header.Type == syscall.IP_RECVORIGDSTADDR { ip := v2net.IPAddress(msg.Data[4:8]) port := v2net.PortFromBytes(msg.Data[2:4]) return v2net.UDPDestination(ip, port) + } else if msg.Header.Level == syscall.SOL_IPV6 && msg.Header.Type == syscall.IP_RECVORIGDSTADDR { + ip := v2net.IPAddress(msg.Data[8:24]) + port := v2net.PortFromBytes(msg.Data[2:4]) + return v2net.UDPDestination(ip, port) } } return v2net.Destination{}