Documentation
¶
Index ¶
- Constants
- func BytesToIP(b []byte) (netip.Addr, error)
- func CIDRToRange(cidr string) (start, end netip.Addr, err error)
- func CacheKey(category, key string) []byte
- func CompareIPs(a, b netip.Addr) int
- func DecodeRangeKey(key []byte) (netip.Addr, error)
- func EncodeRangeKey(ip netip.Addr) []byte
- func IPNetToPrefix(ipnet *net.IPNet) (netip.Prefix, error)
- func IPToBytes(ip netip.Addr) []byte
- func IPv4ToInt32(ip netip.Addr) uint32
- func Int32ToIPv4(n uint32) netip.Addr
- func IsInRange(ip, start, end netip.Addr) bool
- func MetaKey(suffix string) []byte
- func NormalizePrefix(cidr string) (string, error)
- func ParseIP(s string) (netip.Addr, error)
- func PrefixToIPNet(prefix netip.Prefix) *net.IPNet
- func RepresentativeIP(cidr string) (netip.Addr, error)
Constants ¶
View Source
const ( // Key prefixes for LevelDB PrefixRangeV4 = "R4:" PrefixRangeV6 = "R6:" PrefixMeta = "meta:" PrefixCache = "cache:" )
Variables ¶
This section is empty.
Functions ¶
func CIDRToRange ¶
CIDRToRange converts a CIDR string to start and end IP addresses
func CompareIPs ¶
CompareIPs compares two IP addresses (-1 if a < b, 0 if a == b, 1 if a > b)
func DecodeRangeKey ¶
DecodeRangeKey extracts the IP address from a range key
func EncodeRangeKey ¶
EncodeRangeKey creates a LevelDB key for an IP range start Format: "R4:" + 4-byte big-endian IP (IPv4) or "R6:" + 16-byte big-endian IP (IPv6)
func IPNetToPrefix ¶
IPNetToPrefix converts net.IPNet to netip.Prefix
func IPv4ToInt32 ¶
IPv4ToInt32 converts an IPv4 address to uint32
func Int32ToIPv4 ¶
Int32ToIPv4 converts a uint32 to an IPv4 address
func NormalizePrefix ¶
NormalizePrefix normalizes a CIDR prefix string
func PrefixToIPNet ¶
PrefixToIPNet converts netip.Prefix to net.IPNet
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.