Documentation
¶
Overview ¶
Package ipfilter implements a high performance IP filter.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IPFilter ¶
type IPFilter struct {
// contains filtered or unexported fields
}
IPFilter is a high performance, AVL-based IP filter. The filter can be used for filtering any IPv4, IPv6 and IP4-mapped IPv6 addresses.
It's thread-safe for read ops. But if you need to read and write at the same time, a RWLock is necessary.
func NewNonGlobalUnicastIPFilter ¶
func NewNonGlobalUnicastIPFilter() *IPFilter
NewNonGlobalUnicastIPFilter returns a new IPFilter which can filter out all the non-global unicast IPv4 and IPv6 IPs.
func NewNonPublicIPFilter ¶
func NewNonPublicIPFilter() *IPFilter
NewNonPublicIPFilter returns a new IPFilter which can filter out all the non-public IPv4 and IPv6 IPs, such as private addresses.
func (*IPFilter) Add ¶
Add an IP or a CIDR address into the filter. The addr can be a IP, such as "192.168.0.1", or a CIDR notation, like "192.0.2.0/24" or "2001:db8::/32" .
To add mutliple IP / CIDR addresses into the filter, you can simply call it multi times.