ruletree

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2025 License: Apache-2.0, BSD-2-Clause-Views, BSD-3-Clause, + 4 more Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data interface {
	ShouldMatchRes(res *http.Response) bool
	ShouldMatchReq(req *http.Request) bool
	ParseModifiers(modifiers string) error
}

type RuleTree

type RuleTree[T Data] struct {
	// contains filtered or unexported fields
}

RuleTree is a trie-based matcher that is capable of parsing Adblock-style and hosts rules and matching URLs against them.

It is safe for concurrent use.

func NewRuleTree

func NewRuleTree[T Data]() *RuleTree[T]

func (*RuleTree[T]) Add

func (rt *RuleTree[T]) Add(urlPattern string, data T) error

func (*RuleTree[T]) FindMatchingRulesReq

func (rt *RuleTree[T]) FindMatchingRulesReq(req *http.Request) (data []T)

FindMatchingRulesReq finds all rules that match the given request.

func (*RuleTree[T]) FindMatchingRulesRes

func (rt *RuleTree[T]) FindMatchingRulesRes(req *http.Request, res *http.Response) (rules []T)

FindMatchingRulesRes finds all rules that match the given response. It assumes that the request that generated the response has already been matched by FindMatchingRulesReq.

type TokenInterner added in v0.11.2

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

TokenInterner hands out a small integer for each unique string.

func NewTokenInterner added in v0.11.2

func NewTokenInterner() *TokenInterner

func (*TokenInterner) Intern added in v0.11.2

func (in *TokenInterner) Intern(s string) uint32

Intern returns the unique ID for s, assigning a new one if needed.

Jump to

Keyboard shortcuts

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