utils

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNextIP

func GetNextIP(cidr string, usedIPs map[string]bool) (net.IP, error)

GetNextIP returns the next available IP in the CIDR range

func GetRandomCIDR

func GetRandomCIDR(mask int, blacklist []string) (string, error)

GetRandomCIDR returns a random CIDR with the given mask and not in the blacklist. If the blacklist is empty, it will return a random CIDR with the given mask. This function supports mask 0, 8, 16, 24. If you need more elaborate masks to get more subnets (i.e: 0<mask<32) refactor this to use bitwise operations on the IP.

func GetRandomCIDRInRange

func GetRandomCIDRInRange(mask int, start, end net.IP, blacklist []string) (string, error)

func IsFreePort

func IsFreePort(port int) bool

IsFreePort checks if a given port is free to use by trying to listen on it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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