From b1d7346175a17211708921cfae653ed5c3ec69fb Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Fri, 12 Mar 2021 17:41:37 +0800 Subject: [PATCH] Fix: set metadata.AddrType if host is ip string after remove host (#1291) --- tunnel/tunnel.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tunnel/tunnel.go b/tunnel/tunnel.go index 41fb0b16..316e3f4c 100644 --- a/tunnel/tunnel.go +++ b/tunnel/tunnel.go @@ -122,6 +122,11 @@ func preHandleMetadata(metadata *C.Metadata) error { if ip := net.ParseIP(metadata.Host); ip != nil { metadata.DstIP = ip metadata.Host = "" + if ip.To4() != nil { + metadata.AddrType = C.AtypIPv4 + } else { + metadata.AddrType = C.AtypIPv6 + } } // preprocess enhanced-mode metadata