Documentation ¶
Index ¶
- func EnsurePrefix(s string) string
- func LineParser(fields []int, delimiter string, valParser func(string) (netip.Prefix, error)) func(string) ([]netip.Prefix, error)
- func LoadPrefixSetBuilderFromFile(path string, errFn func(string, error) error) (*netipds.PrefixSetBuilder, error)
- func LoadPrefixSetFromFile(path string, errFn func(string, error) error) (*netipds.PrefixSet, error)
- func ParseHost(s string) (netip.Prefix, error)
- func ParsePrefixOrAddr(s string) (netip.Prefix, error)
- func ParseUrl(s string) (netip.Prefix, error)
- func PrefixCompare(p1, p2 netip.Prefix) int
- func StrSliceToPrefixSlice(cidrStrs []string) ([]netip.Prefix, error)
- func StringMaybeAddr(p netip.Prefix) string
- func ToSliceOfOneFn[A, B any](fn func(A) (B, error)) func(A) ([]B, error)
- func ValParser(acceptUrl bool, acceptHostPort bool) func(string) (netip.Prefix, error)
- type CidrProcessor
- type ParsedLine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsurePrefix ¶
If the string does end with an explicit subnet mask, then append '/32'
func LineParser ¶ added in v0.2.0
func LineParser( fields []int, delimiter string, valParser func(string) (netip.Prefix, error), ) func(string) ([]netip.Prefix, error)
LineParser returns a function that parses a line into a slice of prefixes.
func LoadPrefixSetFromFile ¶
func ParseHost ¶ added in v0.2.0
ParseHost parses a string as an IP with an optional :port suffix and returns the IP as a netip.Prefix.
func ParsePrefixOrAddr ¶
ParsePrefixOrAddr parses a string as a CIDR prefix or an IP address.
func ParseUrl ¶ added in v0.2.0
ParseUrl parses a string as a URL and returns the host as a netip.Prefix. If the URL is invalid, an error is returned. If the host is not an IP address, an error is returned.
func PrefixCompare ¶
func StrSliceToPrefixSlice ¶
StrSliceToPrefixSlice converts a slice of CIDR strings to a slice of Prefixes.
func StringMaybeAddr ¶ added in v0.2.0
StringMaybeAddr returns the Prefix as a string, stripping the prefix length if the Prefix is a single IP.
func ToSliceOfOneFn ¶ added in v0.2.0
ToSliceOfOneFn converts a function that returns a single value and an error into a function that returns a slice of one value and an error.
Types ¶
type CidrProcessor ¶
type CidrProcessor struct { Fields []int Delimiter string ValParser func(string) (netip.Prefix, error) HandlerFn func(*ParsedLine) error ErrFn func(string, error) error }
CidrProcessor consolidates all of the configuration provided by a user for processing lists of CIDRs.
type ParsedLine ¶ added in v0.2.0
type ParsedLine struct { Raw string Prefixes []netip.Prefix // contains filtered or unexported fields }
func (*ParsedLine) Clean ¶ added in v0.2.0
func (p *ParsedLine) Clean() string
Clean returns the raw line with any parsed fields replaced by their extracted Prefixes.