Documentation ¶
Index ¶
- Constants
- func BatchLoad[T any](m WriteableMatcher[T], b []string, parseString ParseStringFunc[T]) error
- func Load[T any](m WriteableMatcher[T], s string, parseString ParseStringFunc[T]) error
- func LoadFromTextReader[T any](m WriteableMatcher[T], r io.Reader, parseString ParseStringFunc[T]) error
- func LoadGeoSiteList(b []byte) (*v2data.GeoSiteList, error)
- func TrimDot(s string) string
- func UnifyDomain(s string) string
- type DomainScanner
- type DynamicMatcher
- type FullMatcher
- type KeywordMatcher
- type LabelNode
- type Matcher
- type MatcherGroup
- type MixMatcher
- func BuildDomainMatcher(domains []*v2data.Domain, attrs []string, m *MixMatcher[struct{}]) (*MixMatcher[struct{}], error)
- func NewDomainMixMatcher() *MixMatcher[struct{}]
- func NewMixMatcher[T any]() *MixMatcher[T]
- func NewV2rayDomainDat(v *v2data.GeoSiteList, filters ...*V2filter) (*MixMatcher[struct{}], error)
- func ParseTextDomainFile(in []byte) (*MixMatcher[struct{}], error)
- func ParseV2rayDomainFile(in []byte, filters ...*V2filter) (*MixMatcher[struct{}], error)
- type ParseStringFunc
- type RegexMatcher
- type SubDomainMatcher
- type V2filter
- type WriteableMatcher
Constants ¶
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, parseString ParseStringFunc[T]) error
BatchLoad loads multiple data strings using Load.
func Load ¶
func Load[T any](m WriteableMatcher[T], s string, parseString ParseStringFunc[T]) error
Load loads data from a string. LoadFromText.
func LoadFromTextReader ¶
func LoadFromTextReader[T any](m WriteableMatcher[T], r io.Reader, parseString ParseStringFunc[T]) error
LoadFromTextReader loads multiple lines from reader r. r
func LoadGeoSiteList ¶
func LoadGeoSiteList(b []byte) (*v2data.GeoSiteList, error)
func UnifyDomain ¶
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]) StoreValue ¶
func (n *LabelNode[T]) StoreValue(v T)
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], parseString ParseStringFunc[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 ParseStringFunc ¶ added in v4.1.5
ParseStringFunc parse data string to matcher pattern and 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 ¶
func ParseV2Suffix ¶
ParseV2Suffix parses s into V2filter. The format of s is "tag[@attr@attr...],tag[@attr@attr...]..."