diff options
Diffstat (limited to 'libpod/network/util/ip.go')
-rw-r--r-- | libpod/network/util/ip.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/libpod/network/util/ip.go b/libpod/network/util/ip.go index e75107a1c..e82b4a781 100644 --- a/libpod/network/util/ip.go +++ b/libpod/network/util/ip.go @@ -1,6 +1,8 @@ package util -import "net" +import ( + "net" +) // IsIPv6 returns true if netIP is IPv6. func IsIPv6(netIP net.IP) bool { @@ -44,3 +46,11 @@ func FirstIPInSubnet(addr *net.IPNet) (net.IP, error) { //nolint:interfacer cidr.IP[len(cidr.IP)-1]++ return cidr.IP, nil } + +// NormalizeIP will transform the given ip to the 4 byte len ipv4 if possible +func NormalizeIP(ip *net.IP) { + ipv4 := ip.To4() + if ipv4 != nil { + *ip = ipv4 + } +} |