Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CosmeticEngine ¶
type CosmeticEngine struct {
// contains filtered or unexported fields
}
CosmeticEngine combines all the cosmetic rules and allows to quickly find all rules matching this or that hostname
func NewCosmeticEngine ¶
func NewCosmeticEngine(s *filterlist.RuleStorage) *CosmeticEngine
NewCosmeticEngine builds a new cosmetic engine from the specified rule storage
func (*CosmeticEngine) Match ¶
func (e *CosmeticEngine) Match(hostname string, includeCSS bool, includeJS bool, includeGenericCSS bool) CosmeticResult
Match builds scripts and styles that needs to be injected into the specified page hostname is the page hostname includeCSS defines if we should inject any CSS and element hiding rules (see $elemhide) includeJS defines if we should inject JS into the page (see $jsinject) includeGenericCSS defines if we should inject generic CSS and element hiding rules (see $generichide) TODO: Additionally, we should provide a method that writes result to an io.Writer
type CosmeticResult ¶
type CosmeticResult struct {
ElementHiding StylesResult
CSS StylesResult
JS ScriptsResult
}
CosmeticResult represents all scripts and styles that needs to be injected into the page
type DNSEngine ¶
type DNSEngine struct {
RulesCount int // count of rules loaded to the engine
// contains filtered or unexported fields
}
DNSEngine combines host rules and network rules and is supposed to quickly find matching rules for hostnames. First, it looks over network rules and returns first rule found. Then, if nothing found, it looks up the host rules.
func NewDNSEngine ¶
func NewDNSEngine(s *filterlist.RuleStorage) *DNSEngine
NewDNSEngine parses the specified filter lists and returns a DNSEngine built from them. key of the map is the filter list ID, value is the raw content of the filter list.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine represents the filtering engine with all the loaded rules
func NewEngine ¶
func NewEngine(s *filterlist.RuleStorage) *Engine
NewEngine parses the filtering rules and creates a filtering engine of them
func (*Engine) GetCosmeticResult ¶ added in v0.6.0
func (e *Engine) GetCosmeticResult(hostname string, option rules.CosmeticOption) CosmeticResult
GetCosmeticResult gets cosmetic result for the specified hostname and cosmetic options
func (*Engine) MatchRequest ¶ added in v0.6.0
func (e *Engine) MatchRequest(r *rules.Request) rules.MatchingResult
MatchRequest - matches the specified request against the filtering engine and returns the matching result.
type NetworkEngine ¶
type NetworkEngine struct {
RulesCount int // RulesCount -- count of rules added to the engine
// contains filtered or unexported fields
}
NetworkEngine is the engine that supports quick search over network rules
func NewNetworkEngine ¶
func NewNetworkEngine(s *filterlist.RuleStorage) *NetworkEngine
NewNetworkEngine builds an instance of the network engine
func (*NetworkEngine) Match ¶
func (n *NetworkEngine) Match(r *rules.Request) (*rules.NetworkRule, bool)
Match searches over all filtering rules loaded to the engine It returns true if a match was found alongside the matching rule
func (*NetworkEngine) MatchAll ¶
func (n *NetworkEngine) MatchAll(r *rules.Request) []*rules.NetworkRule
MatchAll finds all rules matching the specified request regardless of the rule types It will find both whitelist and blacklist rules
type ScriptsResult ¶ added in v0.6.0
ScriptsResult contains scripts to be executed on a page