Documentation
¶
Index ¶
- Constants
- Variables
- func Contains(start, end, ip net.IP) bool
- func IPLess(a, b net.IP) bool
- func IPToUint32(ip net.IP) uint32
- func IPv4StrToUint32(ipStr string) uint32
- func IPv4ToUint32(ip net.IP) uint32
- func IsFirstIP(ip net.IP, ipv6 bool) bool
- func IsLastIP(ip net.IP, ipv6 bool) bool
- func LastIP(ipNet *net.IPNet) net.IP
- func MaskLess(a, b *net.IPNet) bool
- func NextIP(ip net.IP) net.IP
- func PrefixSameLength(start, end net.IP) int
- func PrevIP(ip net.IP) net.IP
- func SuffixZeroLength(ip net.IP) int
- func Uint32ToIPv4(uip uint32) net.IP
- func Uint64ToIP(uip uint64) net.IP
- func Uint64ToIP2(high, low uint64) net.IP
- type Range
- type Ranges
Constants ¶
const MaxIPv4Uint32 = 4294967295
MaxIPv4Uint32 largest possible uint32 value for an IPv4 address
Variables ¶
Functions ¶
func Contains ¶
Contains checks if the given IP is within the range of start to end (inclusive of start and exclusive of end).
func IPLess ¶
IPLess compares two IPs and returns true if the first IP is less than the second. IPv4 < IPv6
func IPv4StrToUint32 ¶
IPv4StrToUint32 IPv4字符串 转换为 uint32 (syntactic sugar)
func MaskLess ¶
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 PrefixSameLength ¶
PrefixSameLength determines the length of the common prefix between two IPs.
func SuffixZeroLength ¶
SuffixZeroLength calculates the length of trailing zeros in the IP.
Types ¶
type Range ¶
Range represents an IP range with a start and end IP.
func NewRange ¶
NewRange initializes an IP range based on the provided IPNet. It normalizes the IP addresses to IPv6 length for consistency.
func (*Range) CommonRange ¶
CommonRange finds the common IP range between the current range and another range (r2), ensuring that the resulting range contains the specified IP.