ipmgr

package
v0.0.0-...-aab1398 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

README


Manage routes / addresses for external ip addresses

  • add the option to add ip addresses from the load balancer service definition
    • add if not present
    • maintain a map of addresses
    • remove when the last load balancer using the address is removed

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Bits string

Bits default link CIDR bits abbrev

View Source
var Debug bool

Debug set by initializer

IP default link IP

View Source
var LinkDevice string

LinkDevice default link device to use for external ip addresses

Functions

func CIDR2Addr

func CIDR2Addr(c *CIDR) (addr *netlink.Addr)

CIDR2Addr convert from CIDR to a netlink.Addr

func IPv4CIDRString2Mask

func IPv4CIDRString2Mask(ip string) (string, error)

IPv4CIDRString2Mask ip/bit string to subnet mask

func LinkAddrList

func LinkAddrList() (Addrs []netlink.Addr)

LinkAddrList of all devices for all families

func LinkAddrListByName

func LinkAddrListByName(linkName string) (Addrs []netlink.Addr)

LinkAddrListByName addresses for one device for all address families

func LinkDefaultAddr

func LinkDefaultAddr(link string) *netlink.Addr

LinkDefaultAddr assume that the first address is canonical for a device and shouldn't be modified, removed and describes the subnet bits/routes

func LinkIPv4AddrListByName

func LinkIPv4AddrListByName(linkName string) (Addrs []netlink.Addr)

LinkIPv4AddrListByName addresses for one device for ipv4

func LinkIPv6AddrListByName

func LinkIPv6AddrListByName(linkName string) (Addrs []netlink.Addr)

LinkIPv6AddrListByName addresses for one device for ipv6

func LinkList() ([]netlink.Link, error)

LinkList array of ether devices from netlink lib

func LinkNames

func LinkNames() (names []string)

LinkNames list all network device names

func SubNet

func SubNet(addr *netlink.Addr) (ip net.IP, subnet *net.IPNet, err error)

SubNet returns the ip, subnetwork and error (if any) of the CIDR

Types

type CIDR

type CIDR struct {
	IP         string
	Bits       string
	LinkDevice string
}

CIDR ip/bits CIDR struct

var DefaultCIDR *CIDR

DefaultCIDR default link device to use for external ip addresses

func Addr2CIDR

func Addr2CIDR(addr netlink.Addr) (c *CIDR)

Addr2CIDR convert from netlink.Addr

func LinkDefaultCIDR

func LinkDefaultCIDR(link string) *CIDR

LinkDefaultCIDR assume that the first address is canonical for a device and shouldn't be modified, removed and describes the subnet bits/routes

func StringToCIDR

func StringToCIDR(cidr string) (c *CIDR)

StringToCIDR cidr ip/bits string to type CIDR

func (*CIDR) CIDR2Addr

func (c *CIDR) CIDR2Addr() (addr *netlink.Addr)

CIDR2Addr convert from CIDR to a netlink.Addr

func (*CIDR) CIDRDevString

func (c *CIDR) CIDRDevString() string

CIDRDevString from CIDR with device

func (*CIDR) GetEtherIfaceFromIP

func (c *CIDR) GetEtherIfaceFromIP() string

GetEtherIfaceFromIP returns the link device name for which an address would be assigned

func (*CIDR) MatchAddr

func (c *CIDR) MatchAddr(addr *netlink.Addr) bool

MatchAddr return true when the CIDR blocks/subnets match

func (*CIDR) SetEtherIfaceFromIP

func (c *CIDR) SetEtherIfaceFromIP() string

SetEtherIfaceFromIP returns the link device name for which an address would be assigned

func (*CIDR) String

func (c *CIDR) String() string

String from CIDR

type LinkAddr

type LinkAddr struct {
	*netlink.Addr
	Count int
}

LinkAddr manage links track in use Count

type LoadBalancerIPs

type LoadBalancerIPs map[string]*LinkAddr

LoadBalancerIPs load balancer IPs

func (*LoadBalancerIPs) AddAddr

func (mips *LoadBalancerIPs) AddAddr(IPNet, LinkDevice string)

AddAddr adds an address to a network LinkDevice

func (*LoadBalancerIPs) Keys

func (mips *LoadBalancerIPs) Keys() (IPNets []string)

Keys of managed ip map | thread safe

func (*LoadBalancerIPs) RemoveAddr

func (mips *LoadBalancerIPs) RemoveAddr(IPNet, LinkDevice string)

RemoveAddr from networks

func (*LoadBalancerIPs) String

func (mips *LoadBalancerIPs) String() string

String from managed ip map | thread safe

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL