iputil

package
v0.0.0-...-5888cca Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddToIP

func AddToIP(ip net.IP, offset *big.Int) net.IP

AddToIP adds an arbitrary integer to an IP and returns the empty IP if the result would be negative.

func IPDiff

func IPDiff(x net.IP, y net.IP) *big.Int

IPDiff takes the difference between two IPs, construed as integers.

func IPIter

func IPIter(start net.IP, end net.IP, callback func(net.IP) error) error

IPIter iterates over a range of ip addresses. Both the start and end are inclusive.

func IsCanonicalIP

func IsCanonicalIP(ip net.IP) bool

IsCanonicalIP returns true if the underlying IP object is 16 bytes long.

Internally, net.IP can be 4 bytes or it can be 16 bytes long. IPv4 addresses also have a 16 byte representation with a specific prefix.

func IsNegative

func IsNegative(item *big.Int) bool

func MustParseIP

func MustParseIP(x string) net.IP

MustParseIP parses an IP address and panics if it's invalid.

func RawIncr

func RawIncr(ip net.IP) (res net.IP, overflow bool)

RawIncr takes an IP address and increments it in an abstraction-breaking way. It doesn't respect submasks, for example.

func ValidateSameFamily

func ValidateSameFamily(ips ...net.IP) error

ValidateSameFamily verifies that a series of IP addresses.

Types

This section is empty.

Jump to

Keyboard shortcuts

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