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

This commit is contained in:
wwqgtxx 2021-03-12 17:41:37 +08:00 committed by GitHub
parent 0976d27cb1
commit 5da1b2a8aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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