Documentation
¶
Overview ¶
Package address contains network address manipulation utilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyAddress is returned when the provided string representation of an // address is empty. ErrEmptyAddress = errors.New("empty address") )
Functions ¶
This section is empty.
Types ¶
type ExtraAddresses ¶
type ExtraAddresses struct { // ForwardedIPs contains the forwarded IPs. ForwardedIPs IPAddressMap // TargetInstanceIPs contains the target instance IPs. TargetInstanceIPs IPAddressMap // IPAliases contains the IP aliases. IPAliases IPAddressMap }
ExtraAddresses contains the extra addresses of a NIC.
func NewExtraAddresses ¶
func NewExtraAddresses(nic *metadata.NetworkInterface, config *cfg.Sections, ignore IPAddressMap) *ExtraAddresses
NewExtraAddresses returns a new ExtraAddresses object having addresses ignored from the provided ignore map.
func (*ExtraAddresses) MergedMap ¶
func (c *ExtraAddresses) MergedMap() IPAddressMap
MergedMap returns a map of IP addresses that are merged from the ForwardedIPs, TargetInstanceIPs and IPAliases.
func (*ExtraAddresses) MergedSlice ¶
func (c *ExtraAddresses) MergedSlice() []*IPAddr
MergedSlice returns a slice of IP addresses that are merged from the ForwardedIPs, TargetInstanceIPs and IPAliases. It will sort the slice by the IP address string representation.
type IPAddr ¶
IPAddr is a struct containing an IP address and its CIDR.
func ParseIP ¶
ParseIP parses an IP address string into a net.IP. Input data may be CIDR notation address or regular IP address, this function takes that into account and attempt to parse it as CIDR if it fails then it tries to parse as a regular IP.
type IPAddressMap ¶
IPAddressMap is a map of IP addresses, it's indexed by the string representation of the IP address and the value is the IP address wrapped into a net.IP object.
func MergeIPAddressMap ¶
func MergeIPAddressMap(args ...IPAddressMap) IPAddressMap
MergeIPAddressMap merges the given IP address maps into a single map.
func NewIPAddressMap ¶
func NewIPAddressMap(addresses []string, ignore IPAddressMap) IPAddressMap
NewIPAddressMap returns a new IP address map from the given addresses slice.
func (IPAddressMap) Add ¶
func (m IPAddressMap) Add(addr *IPAddr)
Add adds the given IP address to the map.
func (IPAddressMap) FormatIPs ¶
func (m IPAddressMap) FormatIPs() string
FormatIPs returns a string representation of the IP address map.
func (IPAddressMap) IPs ¶
func (m IPAddressMap) IPs() []string
IPs returns the list of IP addresses in the map.
func (IPAddressMap) RemoveAddresses ¶
func (m IPAddressMap) RemoveAddresses(addresses []string)
RemoveAddresses removes the given addresses from the map.
func (IPAddressMap) RemoveIPAddrs ¶
func (m IPAddressMap) RemoveIPAddrs(addr []*IPAddr)
RemoveIPAddrs removes the given IP addresses from the map.