Documentation ¶
Index ¶
- type Action
- type Filters
- func (fs *Filters) ActionForFilter(ipnet net.IPNet) (action Action, ok bool)
- func (fs *Filters) AddDialFilter(f *net.IPNet)deprecated
- func (fs *Filters) AddFilter(ipnet net.IPNet, action Action)
- func (fs *Filters) AddrBlocked(a ma.Multiaddr) (deny bool)
- func (fs *Filters) Filters() (result []*net.IPNet)deprecated
- func (fs *Filters) FiltersForAction(action Action) (result []net.IPNet)
- func (fs *Filters) Remove(ipnet *net.IPNet) (removed bool)deprecated
- func (fs *Filters) RemoveLiteral(ipnet net.IPNet) (removed bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Filters ¶
type Filters struct { DefaultAction Action // contains filtered or unexported fields }
Filters is a structure representing a collection of accept/deny net.IPNet filters, together with the DefaultAction flag, which represents the default filter policy.
Note that the last policy added to the Filters is authoritative.
func NewFilters ¶
func NewFilters() *Filters
NewFilters constructs and returns a new set of net.IPNet filters. By default, the new filter accepts all addresses.
func (*Filters) ActionForFilter ¶
func (*Filters) AddDialFilter
deprecated
AddDialFilter adds a deny rule to this Filters set. Hosts matching the given net.IPNet filter will be denied, unless another rule is added which states that they should be accepted.
No effort is made to prevent duplication of filters, or to simplify the filters list.
Deprecated: Use AddFilter().
func (*Filters) AddFilter ¶
AddFilter adds a rule to the Filters set, enforcing the desired action for the provided IPNet mask.
func (*Filters) AddrBlocked ¶
AddrBlocked parses a ma.Multiaddr and, if a valid netip is found, it applies the Filter set rules, returning true if the given address should be denied, and false if the given address is accepted.
If a parsing error occurs, or no filter matches, the Filters' default is returned.
TODO: currently, the last filter to match wins always, but it shouldn't be that way.
Instead, the highest-specific last filter should win; that way more specific filters override more general ones.
func (*Filters) FiltersForAction ¶
FiltersForAction returns the filters associated with the indicated action.