v1.2.3 Latest Latest

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

Go to latest
Published: Sep 24, 2021 License: Apache-2.0 Imports: 5 Imported by: 0




This section is empty.


This section is empty.


This section is empty.


type IPAllocator

type IPAllocator interface {
	AllocateIP(ip net.IP) error

	AllocateNext() (net.IP, error)

	Release(ip net.IP) error

	Used() int

	Has(ip net.IP) bool

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) Has

func (ma MultiIPAllocator) Has(ip net.IP) bool

func (MultiIPAllocator) Names

func (ma MultiIPAllocator) Names() []string

func (MultiIPAllocator) Release

func (ma MultiIPAllocator) Release(ip net.IP) error

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.

Jump to

Keyboard shortcuts

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