Documentation ¶
Index ¶
- type IPAllocator
- type MultiIPAllocator
- func (ma MultiIPAllocator) AllocateIP(ip net.IP) error
- func (ma MultiIPAllocator) AllocateNext() (net.IP, error)
- 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
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) Names ¶
func (ma MultiIPAllocator) Names() []string
func (MultiIPAllocator) Total ¶ added in v1.3.0
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 ¶
func NewCIDRAllocator(cidr string) (*SingleIPAllocator, error)
NewCIDRAllocator creates an IPAllocator based on the provided CIDR.
func NewIPRangeAllocator ¶
func NewIPRangeAllocator(startIP, endIP string) (*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) 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) Used ¶
func (a *SingleIPAllocator) Used() int
Used returns the number of the allocated IPs.