Documentation ¶
Overview ¶
The ip package contains yet another IP address (and CIDR) type :-). The types differ from the ones in the net package in that they are backed by fixed-sized arrays of the appropriate size. The key advantage of using a fixed-size array is that it makes the types hashable so they can be used as map keys. In addition, they can be converted to net.IP by slicing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidIP = errors.New("Failed to parse IP address")
Functions ¶
This section is empty.
Types ¶
type Addr ¶
type Addr interface { // Version returns the IP version; 4 or 6. Version() uint8 // AsNetIP returns a net.IP, which is backed by/shares storage with // this object. AsNetIP() net.IP AsCalicoNetIP() calinet.IP AsCIDR() CIDR String() string }
Addr represents either an IPv4 or IPv6 IP address.
func FromString ¶
type CIDR ¶
type CIDR interface { Version() uint8 Addr() Addr Prefix() uint8 String() string ToIPNet() net.IPNet }
func CIDRFromCalicoNet ¶
func CIDRFromIPNet ¶
func CIDRFromNetIP ¶
CIDRFromNetIP converts the given IP into our CIDR representation as a /32 or /128.
func MustParseCIDROrIP ¶
MustParseCIDROrIP parses the given IP address or CIDR, treating IP addresses as "full length" CIDRs. For example, "10.0.0.1" is treated as "10.0.0.1/32". It panics on failure.
func ParseCIDROrIP ¶
ParseCIDROrIP parses the given IP address or CIDR, treating IP addresses as "full length" CIDRs. For example, "10.0.0.1" is treated as "10.0.0.1/32".