filter

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2024 License: Apache-2.0, BSD-2-Clause-Views, BSD-3-Clause, + 4 more Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

Filter is a filter for URLs that is capable of Adblock-style filter lists and hosts rules and matching URLs against them.

The filter is safe for concurrent use.

func NewFilter

func NewFilter(config config, ruleMatcher ruleMatcher, exceptionRuleMatcher ruleMatcher, eventsEmitter filterEventsEmitter) (*Filter, error)

NewFilter creates and initializes a new filter.

func (*Filter) AddRules

func (f *Filter) AddRules(reader io.Reader, filterName *string) (ruleCount, exceptionCount int)

AddRules parses the rules from the given reader and adds them to the filter.

func (*Filter) HandleRequest

func (f *Filter) HandleRequest(req *http.Request) *http.Response

HandleRequest handles the given request by matching it against the filter rules. If the request should be blocked, it returns a response that blocks the request. If the request should be modified, it modifies it in-place.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL