cidr_merger

package
v0.0.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IpNetToString added in v0.0.4

func IpNetToString(ipNets []*net.IPNet) []string

IpNetToString 将网段对象格式的IP转换为String

func IpRangeToIpNet added in v0.0.4

func IpRangeToIpNet(irs []*Range) []*net.IPNet

func ParseIp added in v0.0.4

func ParseIp(str string) net.IP

func StrToIpNet added in v0.0.4

func StrToIpNet(hosts []string) []*net.IPNet

StrToIpNet 将String格式的IP转换为网段对象

Types

type IRange

type IRange interface {
	ToIpNets() []*net.IPNet
	ToRange() *Range
	String() string
}

func IpNetToIRange added in v0.0.4

func IpNetToIRange(in []*net.IPNet) []IRange

func Parse added in v0.0.4

func Parse(text string) (IRange, error)

maybe IpWrapper, Range or IpNetWrapper is returned 128.0.0.0-255.255.255.255 -> Range 192.168.9.0/22 -> IpNetWrapper 127.0.0.1 -> IpWrapper

type IpNetWrapper

type IpNetWrapper struct {
	*net.IPNet
}

func (IpNetWrapper) String

func (r IpNetWrapper) String() string

func (IpNetWrapper) ToIpNets

func (r IpNetWrapper) ToIpNets() []*net.IPNet

func (IpNetWrapper) ToRange

func (r IpNetWrapper) ToRange() *Range

type IpWrapper

type IpWrapper struct {
	net.IP
}

func (IpWrapper) String

func (r IpWrapper) String() string

func (IpWrapper) ToIpNets

func (r IpWrapper) ToIpNets() []*net.IPNet

func (IpWrapper) ToRange

func (r IpWrapper) ToRange() *Range

type Range

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

func IpNetToRange added in v0.0.4

func IpNetToRange(in []*net.IPNet) []*Range

func SortAndMerge added in v0.0.4

func SortAndMerge(ranges []*Range) []*Range

SortAndMerge 排序并合并

func (*Range) String

func (r *Range) String() string

func (*Range) ToIpNets

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

func (*Range) ToRange

func (r *Range) ToRange() *Range

type Ranges

type Ranges []*Range

func (Ranges) Len

func (s Ranges) Len() int

func (Ranges) Less

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

func (Ranges) Swap

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

Jump to

Keyboard shortcuts

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