Documentation ¶
Overview ¶
Package composite implements a composite filter based on several types of filters and the logic of the filter application.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // SafeBrowsing is the safe-browsing filter to apply, if any. SafeBrowsing *hashprefix.Filter // AdultBlocking is the adult-content filter to apply, if any. AdultBlocking *hashprefix.Filter // NewRegisteredDomains is the newly registered domains filter to apply, if // any. NewRegisteredDomains *hashprefix.Filter // GeneralSafeSearch is the general safe-search filter to apply, if any. GeneralSafeSearch *safesearch.Filter // YouTubeSafeSearch is the youtube safe-search filter to apply, if any. YouTubeSafeSearch *safesearch.Filter // Custom is the custom rule-list filter of the profile, if any. Custom *rulelist.Immutable // RuleLists are the enabled rule-list filters of the profile or filtering // group, if any. All items must not be nil. RuleLists []*rulelist.Refreshable // ServiceLists are the rule-list filters of the profile's enabled blocked // services, if any. All items must not be nil. ServiceLists []*rulelist.Immutable }
Config is the configuration structure for the composite filter.
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter is a composite filter based on several types of safe-search and rule-list filters.
func (*Filter) FilterRequest ¶
func (f *Filter) FilterRequest( ctx context.Context, req *internal.Request, ) (r internal.Result, err error)
FilterRequest implements the internal.Interface interface for *Filter. The order in which the filters are applied is the following:
- Custom filter.
- Rule-list filters.
- Blocked-service filters.
- Dangerous-domains filter.
- Adult-content filter.
- General safe-search filter.
- YouTube safe-search filter.
- Newly-registered domains filter.
If f is empty, it returns nil with no error.
func (*Filter) FilterResponse ¶
func (f *Filter) FilterResponse( _ context.Context, resp *internal.Response, ) (r internal.Result, err error)
FilterResponse implements the internal.Interface interface for *Filter. It returns the action created from the filter list network rule with the highest priority. If f is empty, it returns nil with no error. Note that rewrite results are not applied to responses.
func (*Filter) Map ¶
Map implements the rulelist.IDMapper interface for *Filter. It returns the rule list data by its synthetic integer ID in the urlfilter engine. It panics if id is not found.