ip

package
v0.0.0-...-eee9142 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IPGenerator

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

IPGenerator is used to generate an IP from the provided CIDR and the index. It is not an allocator and doesn't maintain any cache.

func NewIPGenerator

func NewIPGenerator(subnet string) (*IPGenerator, error)

NewIPGenerator returns an ipGenerator instance

func (*IPGenerator) GenerateIP

func (ipGenerator *IPGenerator) GenerateIP(idx int) (*net.IPNet, error)

GenerateIP generates an IP from the base ip and the provided 'idx' and returns the IPNet with the generated IP and the netmask of cidr. If suppose the subnet was - 100.88.0.0/16 and the specified index is 10, it will return IPNet { IP : 100.88.0.10, Mask : 16} Returns error if the generated IP is out of network range.

Jump to

Keyboard shortcuts

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