ippool

package module
v0.0.0-...-053ad4a Latest Latest
Warning

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

Go to latest
Published: May 2, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

README

Build Status Go Report Card License

ippool is a dead simple IP pool to simulate the behavior of a DHCP server's ip pool. It was designed to return sequentially generated IPs meant to have short lease periods, working with a fairly small number of used IPs. Working with a almost exhausted pool will lead to longer waiting times retrieving new IPs.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dhcpc

type Dhcpc struct {
	Network *net.IPNet
	// contains filtered or unexported fields
}

func New

func New(network string) (*Dhcpc, error)

func (*Dhcpc) IPv4

func (d *Dhcpc) IPv4() net.IP

IPv4 returns the next free IPv4 or nil if the pool is exhausted.

func (*Dhcpc) Release4

func (d *Dhcpc) Release4(ip net.IP)

type GenIP4

type GenIP4 struct {
	// contains filtered or unexported fields
}

GenIP4 is a sequential IPv4 generator.

func NewGenIP4

func NewGenIP4(network string) (*GenIP4, error)

NewGenIP4 creates a new IPv4 address's generator for the given CIDR network, returning an error if it's not in the right format or is invalid.

func (*GenIP4) NextIP

func (p *GenIP4) NextIP() (byte, byte, byte, byte)

Jump to

Keyboard shortcuts

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