ipallocator

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPAllocator

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

	AllocateNext() (net.IP, error)

	// Allocate range of continuous IPs in one go. If continuus chunk is not
	// available, error will be returned.
	AllocateRange(size int) ([]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) 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) 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) 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

func NewCIDRAllocator(cidr *net.IPNet, reservedIPs []net.IP) (*SingleIPAllocator, error)

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.

Jump to

Keyboard shortcuts

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