iprange

package
v0.0.1-draft Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const MaxIPv4Uint32 = 4294967295

Variables

This section is empty.

Functions

func IPLess

func IPLess(a, b net.IP) bool

IPLess IP大小比较 IPv4 < IPv6

func IPNetMaskLess

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

IPNetMaskLess CIDR大小比较 IPv4 < IPv6 ones越大,子网范围越小

func IPv4StrToUint32

func IPv4StrToUint32(ipStr string) uint32

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

func IPv4ToUint32

func IPv4ToUint32(ip net.IP) uint32

IPv4ToUint32 IPv4 转换为 uint32

func LastIP

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

LastIP IPNet最后一个IP

func NextIP

func NextIP(ip net.IP) net.IP

NextIP 下一个IP

func PrefixSameLength

func PrefixSameLength(start, end net.IP) int

PrefixSameLength 前缀相同长度

func SuffixZeroLength

func SuffixZeroLength(ip net.IP) int

SuffixZeroLength 后缀空值长度

func Uint32ToIPv4

func Uint32ToIPv4(uip uint32) net.IP

Uint32ToIPv4 uint32 转换为 IP

Types

type IPRange

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

IPRange IP区间

func NewIPRange

func NewIPRange(ipNet *net.IPNet) *IPRange

NewIPRange 初始化IP区间

func (*IPRange) IPNets

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

IPNets 输出IP区间对应的CIDR分组

func (*IPRange) Join

func (r *IPRange) Join(ipNet *net.IPNet) (ok bool)

Join 合并网段 FIXME 可能存在重复网段

type IPRanges

type IPRanges []IPRange

func (IPRanges) Len

func (r IPRanges) Len() int

func (IPRanges) Less

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

func (IPRanges) Swap

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

Jump to

Keyboard shortcuts

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