rules

package
v0.10.5 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EscapeString

func EscapeString(in string) string

func UnescapeString

func UnescapeString(in string) string

Types

type Parser

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

func NewParser

func NewParser(beginMarker, endMarker string) *Parser

func (*Parser) Parse

func (p *Parser) Parse(in []string) (*Storage, error)

func (*Parser) ParseRule

func (p *Parser) ParseRule(in []byte) (Rule, error)

ParseRule parses AdBlock rule with dnsrewrite option AdBlock syntax: https://github.com/AdguardTeam/AdGuardHome/wiki/Hosts-Blocklists#adblock-style examples:

|4.3.2.1.in-addr.arpa^$dnsrewrite=NOERROR;PTR;example.net.
|2.0.0.0.0.0.0.0.4.f.7.0.0.0.0.0.0.0.4.3.0.0.0.0.8.b.6.0.2.0.a.2.ip6.arpa^$dnsrewrite=NOERROR;PTR;example.net.
|ya.ru^$dnsrewrite=NOERROR;A;1.2.3.3
|ya.ru^$dnsrewrite=NOERROR;AAAA;::1

Limitation:

  • only dnsrewrite
  • only strict match

type Rule

type Rule struct {
	*upstream.Rule
}

func (*Rule) Format

func (r *Rule) Format() string

func (*Rule) Same

func (r *Rule) Same(other Rule) bool

func (*Rule) SameUpstreamRule

func (r *Rule) SameUpstreamRule(other *upstream.Rule) bool

type Storage

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

func (*Storage) Append

func (s *Storage) Append(r upstream.Rule)

func (*Storage) Delete

func (s *Storage) Delete(q upstream.Rule) []upstream.Rule

func (*Storage) Dump

func (s *Storage) Dump() []string

func (*Storage) Query

func (s *Storage) Query(q upstream.Rule) []upstream.Rule

func (*Storage) Rules

func (s *Storage) Rules() []upstream.Rule

Jump to

Keyboard shortcuts

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