diff options
Diffstat (limited to 'libpod/network/internal/util/ip.go')
-rw-r--r-- | libpod/network/internal/util/ip.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libpod/network/internal/util/ip.go b/libpod/network/internal/util/ip.go index 7fe35d3d4..ee759fd65 100644 --- a/libpod/network/internal/util/ip.go +++ b/libpod/network/internal/util/ip.go @@ -68,3 +68,11 @@ func getRandomIPv6Subnet() (net.IPNet, error) { ip = append(ip, make([]byte, 8)...) return net.IPNet{IP: ip, Mask: net.CIDRMask(64, 128)}, 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 + } +} |