Add netiputil.AddrPortFromNet()
Co-authored-by: Cory Snider <csnider@mirantis.com> Signed-off-by: Rob Murray <rob.murray@docker.com>
This commit is contained in:
parent
8d5d655db0
commit
f07644e17e
1 changed files with 8 additions and 0 deletions
|
@ -51,3 +51,11 @@ func SubnetRange(network, subnet netip.Prefix) (start, end uint64) {
|
|||
end = start + (1 << uint64(subnet.Addr().BitLen()-subnet.Bits())) - 1
|
||||
return start, end
|
||||
}
|
||||
|
||||
// AddrPortFromNet converts a net.Addr into a netip.AddrPort.
|
||||
func AddrPortFromNet(addr net.Addr) netip.AddrPort {
|
||||
if a, ok := addr.(interface{ AddrPort() netip.AddrPort }); ok {
|
||||
return a.AddrPort()
|
||||
}
|
||||
return netip.AddrPort{}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue