netlist

package
v5.0.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFromReader

func LoadFromReader(l *List, reader io.Reader) error

LoadFromReader loads IP list from a reader. It might modify the List and causes List unsorted.

func LoadFromText

func LoadFromText(l *List, s string) error

LoadFromText loads an IP from s. It might modify the List and causes List unsorted.

Types

type List

type List struct {
	// contains filtered or unexported fields
}

List is a list of netip.Prefix. It stores all netip.Prefix in one single slice and use binary search. It is suitable for large static cidr search.

func NewList

func NewList() *List

NewList returns a *List.

func (*List) Append

func (list *List) Append(newNet ...netip.Prefix)

Append appends new netip.Prefix(s) to the list. This modified the list. Caller must call List.Sort() before calling List.Contains()

func (*List) Contains

func (list *List) Contains(addr netip.Addr) bool

Contains reports whether the list includes the given netip.Addr.

func (*List) Len

func (list *List) Len() int

Len implements sort Interface.

func (*List) Less

func (list *List) Less(i, j int) bool

Less implements sort Interface.

func (*List) Match

func (list *List) Match(addr netip.Addr) bool

func (*List) Sort

func (list *List) Sort()

Sort sorts the list, this must be called after list being modified and before calling List.Contains().

func (*List) Swap

func (list *List) Swap(i, j int)

Swap implements sort Interface.

type Matcher

type Matcher interface {
	Match(addr netip.Addr) bool
}

Jump to

Keyboard shortcuts

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