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.
Click to show internal directories.
Click to hide internal directories.