Documentation
¶
Overview ¶
Package netaddr turns source addresses into ban units and checks the prefixes a list may publish.
Index ¶
- Variables
- func Coverage(p netip.Prefix) (ipv4Addresses, ipv6Networks uint64)
- func Host(addr string) (netip.Prefix, error)
- func Kind(p netip.Prefix, ipv6Prefix int) string
- func ParseAllow(s string) (netip.Prefix, error)
- func ParseEntry(s string, lim Limits) (netip.Prefix, error)
- func Unit(addr string, ipv6Prefix int) (netip.Prefix, error)
- type Limits
- type Set
Constants ¶
This section is empty.
Variables ¶
var DefaultLimits = Limits{IPv4MinPrefix: 24, IPv6MinPrefix: 48}
DefaultLimits allow nothing wider than an IPv4 /24 or an IPv6 /48.
Functions ¶
func Coverage ¶
Coverage counts what a prefix covers: IPv4 addresses, or IPv6 /64 networks, where anything narrower than a /64 counts as one. An IPv6 /0, whose count does not fit, counts as math.MaxUint64.
func Host ¶ added in v0.2.0
Host parses one address as the prefix that holds only it, an IPv4-mapped address as IPv4.
func Kind ¶
Kind names a prefix for metrics: ipv4 or ipv6 for a single source, range for anything wider than a unit.
func ParseAllow ¶
ParseAllow parses an allowlist line: an address, or a prefix of any width short of /0, which would allow everything.
func ParseEntry ¶
ParseEntry parses a prefix for a published list. It must be canonical (host bits zero), written as IPv4 when it is IPv4, and no wider than lim.
Types ¶
type Limits ¶
type Limits struct {
IPv4MinPrefix int `json:"ipv4MinPrefix"`
IPv6MinPrefix int `json:"ipv6MinPrefix"`
}
Limits are the widest prefixes a published list may carry.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set is a set of prefixes, such as an allowlist. Lookups take time logarithmic in its size; the index behind them is built by the first lookup after a change, so a Set is not safe for concurrent use.
func SpecialPurpose ¶
func SpecialPurpose() *Set
SpecialPurpose returns a set of the special-purpose blocks.