Documentation ¶
Index ¶
- type IPAllocator
- type MultiIPAllocator
- func (ma MultiIPAllocator) AllocateIP(ip net.IP) error
- func (ma MultiIPAllocator) AllocateNext() (net.IP, error)
- func (ma MultiIPAllocator) AllocateRange(size int) ([]net.IP, error)
- func (ma MultiIPAllocator) Free() int
- func (ma MultiIPAllocator) Has(ip net.IP) bool
- func (ma MultiIPAllocator) Names() []string
- func (ma MultiIPAllocator) Release(ip net.IP) error
- func (ma MultiIPAllocator) Total() int
- func (ma MultiIPAllocator) Used() int
- type SingleIPAllocator
- func (a *SingleIPAllocator) AllocateIP(ip net.IP) error
- func (a *SingleIPAllocator) AllocateNext() (net.IP, error)
- func (a *SingleIPAllocator) AllocateRange(size int) ([]net.IP, error)
- func (a *SingleIPAllocator) Free() int
- func (a *SingleIPAllocator) Has(ip net.IP) bool
- func (a *SingleIPAllocator) Name() string
- func (a *SingleIPAllocator) Release(ip net.IP) error
- func (a *SingleIPAllocator) Total() int
- func (a *SingleIPAllocator) Used() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IPAllocator ¶
type MultiIPAllocator ¶
type MultiIPAllocator []*SingleIPAllocator
MultiIPAllocator is responsible for allocating IPs from multiple contiguous IP ranges.
func (MultiIPAllocator) AllocateIP ¶
func (ma MultiIPAllocator) AllocateIP(ip net.IP) error
func (MultiIPAllocator) AllocateNext ¶
func (ma MultiIPAllocator) AllocateNext() (net.IP, error)
func (MultiIPAllocator) AllocateRange ¶ added in v1.5.0
func (ma MultiIPAllocator) AllocateRange(size int) ([]net.IP, error)
AllocateRange allocates continuous range of specified size. If not available in any allocator, error is returned.
func (MultiIPAllocator) Free ¶ added in v1.5.0
func (ma MultiIPAllocator) Free() int
func (MultiIPAllocator) Names ¶
func (ma MultiIPAllocator) Names() []string
func (MultiIPAllocator) Total ¶
func (ma MultiIPAllocator) Total() int
func (MultiIPAllocator) Used ¶
func (ma MultiIPAllocator) Used() int
type SingleIPAllocator ¶
type SingleIPAllocator struct {
// contains filtered or unexported fields
}
SingleIPAllocator is responsible for allocating IPs from a contiguous IP range.
func NewCIDRAllocator ¶
NewCIDRAllocator creates an IPAllocator based on the provided CIDR.
func NewIPRangeAllocator ¶
func NewIPRangeAllocator(startIP, endIP net.IP) (*SingleIPAllocator, error)
NewIPRangeAllocator creates an IPAllocator based on the provided start IP and end IP. The start IP and end IP are inclusive.
func (*SingleIPAllocator) AllocateIP ¶
func (a *SingleIPAllocator) AllocateIP(ip net.IP) error
AllocateIP allocates the specified IP. It returns error if the IP is not in the range or already allocated.
func (*SingleIPAllocator) AllocateNext ¶
func (a *SingleIPAllocator) AllocateNext() (net.IP, error)
AllocateNext allocates an IP from the IP range. It returns error if no IP is available.
func (*SingleIPAllocator) AllocateRange ¶ added in v1.5.0
func (a *SingleIPAllocator) AllocateRange(size int) ([]net.IP, error)
AllocateRange allocates continuous range of specified size. If not available, error is returned.
func (*SingleIPAllocator) Free ¶ added in v1.5.0
func (a *SingleIPAllocator) Free() int
Free returns the number of free IPs.
func (*SingleIPAllocator) Has ¶
func (a *SingleIPAllocator) Has(ip net.IP) bool
Has returns whether the provided IP is in the range or not.
func (*SingleIPAllocator) Name ¶
func (a *SingleIPAllocator) Name() string
func (*SingleIPAllocator) Release ¶
func (a *SingleIPAllocator) Release(ip net.IP) error
Release releases the provided IP. It returns error if the IP is not in the range or not allocated.
func (*SingleIPAllocator) Total ¶ added in v1.8.0
func (a *SingleIPAllocator) Total() int
Total returns the number total of IPs within the pool.
func (*SingleIPAllocator) Used ¶
func (a *SingleIPAllocator) Used() int
Used returns the number of the allocated IPs.