domain

package
v4.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MatcherFull    = "full"
	MatcherDomain  = "domain"
	MatcherRegexp  = "regexp"
	MatcherKeyword = "keyword"
)

Variables

This section is empty.

Functions

func BatchLoad

func BatchLoad[T any](m WriteableMatcher[T], b []string, processAttr ProcessAttrFunc[T]) error

BatchLoad loads multiple data strings using Load.

func Load

func Load[T any](m WriteableMatcher[T], s string, processAttr ProcessAttrFunc[T]) error

Load loads data from a string. LoadFromText.

func LoadFromTextReader

func LoadFromTextReader[T any](m WriteableMatcher[T], r io.Reader, processAttr ProcessAttrFunc[T]) error

LoadFromTextReader loads multiple lines from reader r. r

func LoadGeoSiteList

func LoadGeoSiteList(b []byte) (*v2data.GeoSiteList, error)

func TrimDot

func TrimDot(s string) string

TrimDot trims the suffix '.'.

func UnifyDomain

func UnifyDomain(s string) string

UnifyDomain unifies domain strings. It removes the suffix "." and make sure the domain is in lower case.

Types

type DomainScanner

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

func NewUnifiedDomainScanner

func NewUnifiedDomainScanner(s string) *DomainScanner

func (*DomainScanner) PrevLabel

func (s *DomainScanner) PrevLabel() (label string, end bool)

func (*DomainScanner) PrevLabelOffset

func (s *DomainScanner) PrevLabelOffset() int

func (*DomainScanner) PrevSubDomain

func (s *DomainScanner) PrevSubDomain() (sub string, end bool)

func (*DomainScanner) Scan

func (s *DomainScanner) Scan() bool

type DynamicMatcher

type DynamicMatcher[T any] struct {
	// contains filtered or unexported fields
}

func NewDynamicMatcher

func NewDynamicMatcher[T any](parserFunc func(b []byte) (Matcher[T], error)) *DynamicMatcher[T]

func (*DynamicMatcher[T]) Len

func (d *DynamicMatcher[T]) Len() int

func (*DynamicMatcher[T]) Match

func (d *DynamicMatcher[T]) Match(s string) (v T, ok bool)

func (*DynamicMatcher[T]) Update

func (d *DynamicMatcher[T]) Update(b []byte) error

type FullMatcher

type FullMatcher[T any] struct {
	// contains filtered or unexported fields
}

func NewFullMatcher

func NewFullMatcher[T any]() *FullMatcher[T]

func (*FullMatcher[T]) Add

func (m *FullMatcher[T]) Add(s string, v T) error

func (*FullMatcher[T]) Len

func (m *FullMatcher[T]) Len() int

func (*FullMatcher[T]) Match

func (m *FullMatcher[T]) Match(s string) (v T, ok bool)

type KeywordMatcher

type KeywordMatcher[T any] struct {
	// contains filtered or unexported fields
}

func NewKeywordMatcher

func NewKeywordMatcher[T any]() *KeywordMatcher[T]

func (*KeywordMatcher[T]) Add

func (m *KeywordMatcher[T]) Add(keyword string, v T) error

func (*KeywordMatcher[T]) Len

func (m *KeywordMatcher[T]) Len() int

func (*KeywordMatcher[T]) Match

func (m *KeywordMatcher[T]) Match(s string) (v T, ok bool)

type LabelNode

type LabelNode[T any] struct {
	// contains filtered or unexported fields
}

LabelNode can store dns labels.

func (*LabelNode[T]) GetChild

func (n *LabelNode[T]) GetChild(key string) *LabelNode[T]

func (*LabelNode[T]) GetValue

func (n *LabelNode[T]) GetValue() (T, bool)

func (*LabelNode[T]) HasValue

func (n *LabelNode[T]) HasValue() bool

func (*LabelNode[T]) Len

func (n *LabelNode[T]) Len() int

func (*LabelNode[T]) NewChild

func (n *LabelNode[T]) NewChild(key string) *LabelNode[T]

func (*LabelNode[T]) StoreValue

func (n *LabelNode[T]) StoreValue(v T)

type Matcher

type Matcher[T any] interface {
	// Match matches the domain s.
	// s could be a fqdn or not, and should be case-insensitive.
	Match(s string) (v T, ok bool)
	Len() int
}

type MatcherGroup

type MatcherGroup[T any] struct {
	// contains filtered or unexported fields
}

func BatchLoadDomainProvider

func BatchLoadDomainProvider(
	e []string,
	dm *data_provider.DataManager,
) (*MatcherGroup[struct{}], error)

BatchLoadDomainProvider loads multiple domain entries.

func BatchLoadProvider

func BatchLoadProvider[T any](
	e []string,
	staticMatcher WriteableMatcher[T],
	processAttr ProcessAttrFunc[T],
	dm *data_provider.DataManager,
	parserFunc func(b []byte) (Matcher[T], error),
) (*MatcherGroup[T], error)

BatchLoadProvider loads multiple data entries.

func (*MatcherGroup[T]) Append

func (m *MatcherGroup[T]) Append(nm Matcher[T])

func (*MatcherGroup[T]) Len

func (m *MatcherGroup[T]) Len() int

func (*MatcherGroup[T]) Match

func (m *MatcherGroup[T]) Match(s string) (v T, ok bool)

type MixMatcher

type MixMatcher[T any] struct {
	// contains filtered or unexported fields
}

func BuildDomainMatcher

func BuildDomainMatcher(domains []*v2data.Domain, attrs []string, m *MixMatcher[struct{}]) (*MixMatcher[struct{}], error)

func NewDomainMixMatcher

func NewDomainMixMatcher() *MixMatcher[struct{}]

NewDomainMixMatcher is a helper function for BatchLoadDomainProvider.

func NewMixMatcher

func NewMixMatcher[T any]() *MixMatcher[T]

func NewV2rayDomainDat

func NewV2rayDomainDat(v *v2data.GeoSiteList, filters ...*V2filter) (*MixMatcher[struct{}], error)

NewV2rayDomainDat builds a V2rayDomainDat from given v and args. The format of args is "tag1@attr1@attr2,tag2@attr1...". Only domains that are matched by the args will be loaded to V2rayDomainDat.

func ParseTextDomainFile

func ParseTextDomainFile(in []byte) (*MixMatcher[struct{}], error)

func ParseV2rayDomainFile

func ParseV2rayDomainFile(in []byte, filters ...*V2filter) (*MixMatcher[struct{}], error)

ParseV2rayDomainFile See NewV2rayDomainDat.

func (*MixMatcher[T]) Add

func (m *MixMatcher[T]) Add(s string, v T) error

func (*MixMatcher[T]) GetSubMatcher

func (m *MixMatcher[T]) GetSubMatcher(typ string) WriteableMatcher[T]

func (*MixMatcher[T]) Len

func (m *MixMatcher[T]) Len() int

func (*MixMatcher[T]) Match

func (m *MixMatcher[T]) Match(s string) (v T, ok bool)

func (*MixMatcher[T]) SetDefaultMatcher

func (m *MixMatcher[T]) SetDefaultMatcher(s string)

type ProcessAttrFunc

type ProcessAttrFunc[T any] func(attr string) (v T, err error)

ProcessAttrFunc processes the additional attributions.

type RegexMatcher

type RegexMatcher[T any] struct {
	// contains filtered or unexported fields
}

func NewRegexMatcher

func NewRegexMatcher[T any]() *RegexMatcher[T]

func NewRegexMatcherWithCache

func NewRegexMatcherWithCache[T any](cap int) *RegexMatcher[T]

func (*RegexMatcher[T]) Add

func (m *RegexMatcher[T]) Add(expr string, v T) error

func (*RegexMatcher[T]) Len

func (m *RegexMatcher[T]) Len() int

func (*RegexMatcher[T]) Match

func (m *RegexMatcher[T]) Match(s string) (v T, ok bool)

func (*RegexMatcher[T]) ResetCache

func (m *RegexMatcher[T]) ResetCache()

type SubDomainMatcher

type SubDomainMatcher[T any] struct {
	// contains filtered or unexported fields
}

func NewSubDomainMatcher

func NewSubDomainMatcher[T any]() *SubDomainMatcher[T]

func (*SubDomainMatcher[T]) Add

func (m *SubDomainMatcher[T]) Add(s string, v T) error

func (*SubDomainMatcher[T]) Len

func (m *SubDomainMatcher[T]) Len() int

func (*SubDomainMatcher[T]) Match

func (m *SubDomainMatcher[T]) Match(s string) (T, bool)

type V2filter

type V2filter struct {
	Tag   string
	Attrs []string
}

func ParseV2Suffix

func ParseV2Suffix(s string) []*V2filter

ParseV2Suffix parses s into V2filter. The format of s is "tag[@attr@attr...],tag[@attr@attr...]..."

type WriteableMatcher

type WriteableMatcher[T any] interface {
	Matcher[T]
	Add(pattern string, v T) error
}

Jump to

Keyboard shortcuts

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