helpers/subnetmap: fix bug when using IPv6-mapped IPv4 addresses

Go will display them as IPv4. We want everything to be IPv6.
This commit is contained in:
Vincent Bernat
2022-07-31 22:45:19 +02:00
parent c0d9d301b3
commit f1585f3e6c
2 changed files with 12 additions and 0 deletions

View File

@@ -70,6 +70,8 @@ func SubnetMapUnmarshallerHook[V any]() mapstructure.DecodeHookFunc {
}
if bits == 32 {
key = fmt.Sprintf("::ffff:%s/%d", ipNet.IP.String(), ones+96)
} else if ipNet.IP.To4() != nil {
key = fmt.Sprintf("::ffff:%s/%d", ipNet.IP.String(), ones)
} else {
key = ipNet.String()
}