Fix: set metadata.AddrType if host is ip string after remove host (#1291)

This commit is contained in:
gVisor bot 2021-03-12 17:41:37 +08:00
parent 0c2e1dc55d
commit b1d7346175

View file

@ -122,6 +122,11 @@ func preHandleMetadata(metadata *C.Metadata) error {
if ip := net.ParseIP(metadata.Host); ip != nil { if ip := net.ParseIP(metadata.Host); ip != nil {
metadata.DstIP = ip metadata.DstIP = ip
metadata.Host = "" metadata.Host = ""
if ip.To4() != nil {
metadata.AddrType = C.AtypIPv4
} else {
metadata.AddrType = C.AtypIPv6
}
} }
// preprocess enhanced-mode metadata // preprocess enhanced-mode metadata