filter

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: BSD-3-Clause, GPL-3.0, MIT, + 1 more Imports: 16 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 capable of parsing Adblock-style filter lists and hosts rules and matching URLs against them.

Safe for concurrent use.

func NewFilter

func NewFilter(networkRules networkRules, scriptletsInjector scriptletsInjector, cosmeticRulesInjector cosmeticRulesInjector, cssRulesInjector cssRulesInjector, jsRuleInjector jsRuleInjector, extendedCSSInjector extendedCSSInjector, eventsEmitter filterEventsEmitter, whitelistSrv whitelistSrv) (*Filter, error)

NewFilter creates and initializes a new filter.

func (*Filter) AddList added in v1.2.0

func (f *Filter) AddList(name string, trusted bool, rules io.Reader) error

AddList 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, error)

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.

func (*Filter) HandleResponse

func (f *Filter) HandleResponse(req *http.Request, res *http.Response) error

HandleResponse handles the given response by matching it against the filter rules. If the response should be modified, it modifies it in-place.

As of April 2024, there are no response-only rules that can block or redirect responses. For that reason, this method does not return a blocking or redirecting response itself.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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