ipnet

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const MaxIPv4Uint32 = 4294967295

MaxIPv4Uint32 largest possible uint32 value for an IPv4 address

Variables

View Source
var (
	FirstIPv4 = net.IPv4(0, 0, 0, 0)
	LastIPv4  = net.IPv4(255, 255, 255, 255)
	FirstIPv6 = make(net.IP, net.IPv6len)
	LastIPv6  = net.IP{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
)
View Source
var BaseIPv4 = []net.IP{
	{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0},
	{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0x4, 0x31, 0x32, 0xb0},
	{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xc, 0x7, 0xc9, 0xa0},
	{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xc, 0x7c, 0x72, 0x4f},
	{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xc, 0xd3, 0x58, 0x40},
	{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0x17, 0x19, 0x96, 0x98},
	{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0x18, 0x6a, 0x15, 0xac},
	{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0x1b, 0x52, 0x53, 0x70},
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0xff, 0xff, 0xd4, 0x91, 0xf3, 0xd0},
	{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xd5, 0x2a, 0xb7, 0x20},
	{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xd5, 0xbb, 0x5c, 0x29},
	{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xd8, 0x77, 0xf1, 0xf8},
	{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xd9, 0x2c, 0x61, 0x80},
	{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xd9, 0xcc, 0x74, 0x60},
	{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
}

BaseIPv4 represents a predefined list of IPv4 addresses. These addresses can be used as reference points or base IPs for various network operations.

View Source
var BaseIPv6 = []net.IP{
	{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0, 0x0},
	{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x18, 0x3d, 0xc0, 0x0},
	{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x18, 0xf2, 0xa2, 0xc8},
	{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2d, 0x3, 0xe8, 0x84},
	{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x32, 0x6c, 0x8, 0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x0, 0x0, 0x0, 0x0, 0x0},
	{0x20, 0x2, 0xd1, 0xde, 0x15, 0x76, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
	{0x20, 0x2, 0xdf, 0xb3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
	{0x26, 0x0, 0x1f, 0x13, 0x1, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
	{0x26, 0x2, 0xfe, 0xf5, 0x80, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
	{0x26, 0x20, 0x0, 0x1d, 0x22, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
	{0x2a, 0x1, 0x63, 0x82, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
	{0x2a, 0x2, 0x26, 0xf7, 0xd6, 0xd0, 0x68, 0xd0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
	{0x2a, 0x5, 0x41, 0x44, 0x5, 0x97, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
	{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
}

BaseIPv6 represents a predefined list of IPv6 addresses. Similar to BaseIPv4, these addresses serve as reference or base IPs for IPv6 network operations.

Functions

func BigIntToIP added in v0.3.1

func BigIntToIP(intValue *big.Int) net.IP

BigIntToIP converts a big.Int back to an IP address. It ensures that the resulting IP address has the correct length for IPv6 addresses, padding with leading zeros if necessary.

func Contains

func Contains(start, end, ip net.IP) bool

Contains checks if the given IP is within the range of start to end (inclusive of start and exclusive of end).

func GetIndex added in v0.3.1

func GetIndex(base []net.IP, ip net.IP) int

GetIndex finds the index of the given IP in the base list. It returns the highest index of an IP in the base list which is less than or equal to the given IP.

func IPLess

func IPLess(a, b net.IP) bool

IPLess compares two IPs and returns true if the first IP is less than the second. IPv4 < IPv6

func IPToBigInt added in v0.3.1

func IPToBigInt(ip net.IP) *big.Int

IPToBigInt converts an IP address to a big.Int. This is useful for performing mathematical operations on IP addresses, especially for IPv6 addresses due to their large size.

func IPToUint32

func IPToUint32(ip net.IP) uint32

IPToUint32 IP 转换为 uint32, IPv6 返回前 32 位

func IPv4StrToUint32

func IPv4StrToUint32(ipStr string) uint32

IPv4StrToUint32 IPv4字符串 转换为 uint32 (syntactic sugar)

func IPv4ToUint32

func IPv4ToUint32(ip net.IP) uint32

IPv4ToUint32 IPv4 转换为 uint32

func IsFirstIP

func IsFirstIP(ip net.IP, ipv6 bool) bool

IsFirstIP checks if the given IP is the first IP of its kind (IPv4 or IPv6).

func IsLastIP

func IsLastIP(ip net.IP, ipv6 bool) bool

IsLastIP checks if the given IP is the last IP of its kind (IPv4 or IPv6).

func LastIP

func LastIP(ipNet *net.IPNet) net.IP

LastIP returns the last IP address within the provided IPNet.

func MaskLess

func MaskLess(a, b *net.IPNet) bool

MaskLess compares two CIDRs. Returns true if the first CIDR has a larger prefix length (smaller network) than the second. IPv4 networks are considered smaller than IPv6.

func NextIP

func NextIP(ip net.IP) net.IP

NextIP returns the IP immediately after the given IP.

func PrefixSameLength

func PrefixSameLength(start, end net.IP) int

PrefixSameLength determines the length of the common prefix between two IPs.

func PrevIP

func PrevIP(ip net.IP) net.IP

PrevIP returns the IP immediately before the given IP.

func SplitIPNet added in v0.3.1

func SplitIPNet(start net.IP, end net.IP, num int) []net.IP

SplitIPNet splits an IP range into several parts based on the specified number and a reference list of base IPs which represent the density distribution of the entire IP range. It supports both IPv4 and IPv6 addresses.

func SuffixZeroLength

func SuffixZeroLength(ip net.IP) int

SuffixZeroLength calculates the length of trailing zeros in the IP.

func Uint32ToIPv4

func Uint32ToIPv4(uip uint32) net.IP

Uint32ToIPv4 uint32

func Uint64ToIP

func Uint64ToIP(uip uint64) net.IP

Uint64ToIP uint64 转换为 IP

func Uint64ToIP2

func Uint64ToIP2(high, low uint64) net.IP

Uint64ToIP2 uint64 转换为 IP

Types

type Range

type Range struct {
	Start net.IP
	End   net.IP
}

Range represents an IP range with a start and end IP.

func NewRange

func NewRange(ipNet *net.IPNet) *Range

NewRange initializes an IP range based on the provided IPNet. It normalizes the IP addresses to IPv6 length for consistency.

func (*Range) CommonRange

func (r *Range) CommonRange(ip net.IP, r2 *Range) bool

CommonRange finds the common IP range between the current range and another range (r2), ensuring that the resulting range contains the specified IP.

func (*Range) Contains

func (r *Range) Contains(ip net.IP) bool

Contains checks if the IP range contains a specific IP.

func (*Range) IPNets

func (r *Range) IPNets() []*net.IPNet

IPNets returns the CIDR groups corresponding to the IP range.

func (*Range) Join

func (r *Range) Join(r2 *Range) bool

Join attempts to merge the current IP range with another range (r2). It forbids merging if the start IP of r2 is before the current range or if the ranges aren't adjacent.

func (*Range) JoinIPNet

func (r *Range) JoinIPNet(ipNet *net.IPNet) bool

JoinIPNet tries to merge the current IP range with a provided IPNet. It forbids merging if the start IP of IPNet is before the current range or if they aren't adjacent.

type Ranges

type Ranges []Range

Ranges represents a slice of IP ranges.

func (Ranges) Len

func (r Ranges) Len() int

Len returns the number of IP ranges.

func (Ranges) Less

func (r Ranges) Less(i, j int) bool

Less checks if the start IP of the range at index i is less than that at index j.

func (Ranges) Swap

func (r Ranges) Swap(i, j int)

Swap swaps the positions of two IP ranges in the slice.

Jump to

Keyboard shortcuts

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