Documentation
¶
Index ¶
- Constants
- func NextIP(ip net.IP, subnet net.IPNet) (net.IP, error)
- func NextIPv6(ip net.IP, subnet net.IPNet) (net.IP, error)
- type Config
- type IPAllocator
- type IPManager
- func (manager *IPManager) Assign(ip string, id string) error
- func (manager *IPManager) Close()
- func (manager *IPManager) Exists(ip string) (bool, error)
- func (manager *IPManager) Get(ip string) (string, error)
- func (manager *IPManager) GetAvailableIP(id string) (string, error)
- func (manager *IPManager) GetAvailableIPv6(id string) (string, error)
- func (manager *IPManager) Release(ip string) error
- func (manager *IPManager) ReleaseByID(id string) (ipv4Released, ipv6Released string, err error)
- func (manager *IPManager) SetLastKnownIP(ip net.IP)
- func (manager *IPManager) SetLastKnownIPv6(ip net.IP)
- func (manager *IPManager) UniqueID(id string) (bool, error)
- func (manager *IPManager) UniqueIDDualStack(id string) (bool, error)
- func (manager *IPManager) UniqueIDv6(id string) (bool, error)
- func (manager *IPManager) Update(key string, value string) error
Constants ¶
const ( // Mask size beyond 30 won't be accepted since the .0 and .255 are reserved MaxMask = 30 // MaxMaskIPv6 is the maximum prefix length for IPv6 subnets (/126 minimum for 4 addresses) MaxMaskIPv6 = 126 // This assumes all the ip start with 1 for now before we address // the issue: https://github.com/aws/amazon-ecs-cni-plugins/issues/37 IPPrefix = "1" // IPPrefixV6 is the prefix for IPv6 addresses in the database IPPrefixV6 = "6" // LastKnownIPv6Key is the key used to store the last allocated IPv6 address in the database LastKnownIPv6Key = "lastKnownIPv6" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
DB string
PersistConnection bool
Bucket string
ConnectionTimeout time.Duration
}
Config represents the configuration for boltdb opermation where the ip address are stored
type IPAllocator ¶
type IPAllocator interface {
GetAvailableIP(string) (string, error)
GetAvailableIPv6(string) (string, error)
Get(string) (string, error)
Assign(string, string) error
Update(string, string) error
Release(string) error
ReleaseByID(string) (ipv4Released, ipv6Released string, err error)
Exists(string) (bool, error)
SetLastKnownIP(net.IP)
SetLastKnownIPv6(net.IP)
Close()
}
IPAllocator defines the operation for an ip allocator
func NewIPAllocator ¶
func NewIPAllocator(options *Config, subnet net.IPNet) (IPAllocator, error)
NewIPAllocator creates an ip manager from the IPAM and db configuration
func NewIPAllocatorDualStack ¶
func NewIPAllocatorDualStack(options *Config, subnetV4, subnetV6 *net.IPNet) (IPAllocator, error)
NewIPAllocatorDualStack creates an IP manager supporting both IPv4 and IPv6 subnetV4 and subnetV6 can be nil if that stack is not configured
type IPManager ¶
type IPManager struct {
// contains filtered or unexported fields
}
IPManager is responsible for managing the ip addresses using boltdb
func (*IPManager) Assign ¶
Assign marks the ip as used or return an error if the ip has already been used
func (*IPManager) Close ¶
func (manager *IPManager) Close()
Close will close the connection to the db
func (*IPManager) Get ¶
Get returns the id by which the ip was used and return empty if the key not exists
func (*IPManager) GetAvailableIP ¶
GetAvailableIP returns the next available ip address
func (*IPManager) GetAvailableIPv6 ¶
GetAvailableIPv6 returns the next available IPv6 address from the configured subnet
func (*IPManager) Release ¶
Release marks the ip as available or return an error if the ip is avaialble already
func (*IPManager) ReleaseByID ¶
ReleaseByID releases all IPs (v4 and v6) associated with an ID It searches both IPv4 and IPv6 prefixes in the database and returns both released IPs
func (*IPManager) SetLastKnownIP ¶
SetLastKnownIP updates the record of last visited ip address
func (*IPManager) SetLastKnownIPv6 ¶
SetLastKnownIPv6 updates the record of last visited IPv6 address
func (*IPManager) UniqueIDDualStack ¶
UniqueIDDualStack checks whether the id has already existed in the ipam for both IPv4 and IPv6
func (*IPManager) UniqueIDv6 ¶
UniqueIDv6 checks whether the id has already existed in the IPv6 addresses only