Documentation ¶
Index ¶
- Variables
- func BatchLoadMatcher(m Matcher, entries []string, processAttr ProcessAttrFunc) error
- func BatchLoadMatcherFromFiles(m Matcher, fs []string, processAttr ProcessAttrFunc) error
- func Load(m Matcher, entry string, processAttr ProcessAttrFunc) error
- func LoadFromDAT(m *MixMatcher, file, countryCode string, processAttr ProcessAttrFunc) error
- func LoadFromFile(m Matcher, file string, processAttr ProcessAttrFunc) error
- func LoadFromText(m Matcher, s string, processAttr ProcessAttrFunc) error
- func LoadFromTextFile(m Matcher, file string, processAttr ProcessAttrFunc) error
- func LoadFromTextReader(m Matcher, r io.Reader, processAttr ProcessAttrFunc) error
- func TrimDot(s string) string
- func UnifyDomain(s string) string
- type Appendable
- type DomainMatcher
- type DomainScanner
- type FullMatcher
- type KeywordMatcher
- type LabelNode
- type Matcher
- type MixMatcher
- func (m *MixMatcher) Add(pattern string, v interface{}) error
- func (m *MixMatcher) AddElem(typ MixMatcherPatternType, pattern string, v interface{}) error
- func (m *MixMatcher) Len() int
- func (m *MixMatcher) Match(s string) (v interface{}, ok bool)
- func (m *MixMatcher) SetPattenTypeMap(typMap map[string]MixMatcherPatternType)
- type MixMatcherOption
- type MixMatcherPatternType
- type ProcessAttrFunc
- type RegexMatcher
- type SimpleDomainMatcher
Constants ¶
This section is empty.
Variables ¶
var LoadFromDATFunc func(m *MixMatcher, file, countryCode string, processAttr ProcessAttrFunc) error
var MixMatcherStrToPatternTypeDefaultDomain = map[string]MixMatcherPatternType{ "": MixMatcherPatternTypeDomain, "domain": MixMatcherPatternTypeDomain, "keyword": MixMatcherPatternTypeKeyword, "regexp": MixMatcherPatternTypeRegexp, "full": MixMatcherPatternTypeFull, }
var MixMatcherStrToPatternTypeDefaultFull = map[string]MixMatcherPatternType{ "domain": MixMatcherPatternTypeDomain, "keyword": MixMatcherPatternTypeKeyword, "regexp": MixMatcherPatternTypeRegexp, "full": MixMatcherPatternTypeFull, "": MixMatcherPatternTypeFull, }
Functions ¶
func BatchLoadMatcher ¶
func BatchLoadMatcher(m Matcher, entries []string, processAttr ProcessAttrFunc) error
BatchLoadMatcher loads multiple files or entries using Load.
func BatchLoadMatcherFromFiles ¶ added in v1.8.5
func BatchLoadMatcherFromFiles(m Matcher, fs []string, processAttr ProcessAttrFunc) error
BatchLoadMatcherFromFiles loads multiple files using LoadFromFile.
func Load ¶
func Load(m Matcher, entry string, processAttr ProcessAttrFunc) error
Load loads data from a entry. If entry begin with "ext:", Load loads the file by using LoadFromFile. Else it loads the entry as a text pattern by using LoadFromText.
func LoadFromDAT ¶ added in v1.8.4
func LoadFromDAT(m *MixMatcher, file, countryCode string, processAttr ProcessAttrFunc) error
func LoadFromFile ¶
func LoadFromFile(m Matcher, file string, processAttr ProcessAttrFunc) error
LoadFromFile loads data from a file. v2ray data file can also have multiple @attr. e.g. 'geosite.dat:cn@attr1@attr2'. Only the record with all of the @attr will be loaded.
func LoadFromText ¶
func LoadFromText(m Matcher, s string, processAttr ProcessAttrFunc) error
func LoadFromTextFile ¶
func LoadFromTextFile(m Matcher, file string, processAttr ProcessAttrFunc) error
func LoadFromTextReader ¶
func LoadFromTextReader(m Matcher, r io.Reader, processAttr ProcessAttrFunc) error
func UnifyDomain ¶ added in v1.7.2
UnifyDomain unifies domain strings. It remove the suffix "." and make sure the domain is in lower case.
Types ¶
type Appendable ¶
type Appendable interface { // Append appends v to Appendable. // v might be any type and nil. Append(v interface{}) }
type DomainMatcher ¶
type DomainMatcher struct {
// contains filtered or unexported fields
}
func NewDomainMatcher ¶
func NewDomainMatcher() *DomainMatcher
func (*DomainMatcher) Add ¶
func (m *DomainMatcher) Add(s string, v interface{}) error
func (*DomainMatcher) Len ¶
func (m *DomainMatcher) Len() int
func (*DomainMatcher) Match ¶
func (m *DomainMatcher) Match(s string) (interface{}, bool)
type DomainScanner ¶ added in v1.7.1
type DomainScanner struct {
// contains filtered or unexported fields
}
func NewUnifiedDomainScanner ¶ added in v1.8.1
func NewUnifiedDomainScanner(s string) *DomainScanner
func (*DomainScanner) PrevLabel ¶ added in v1.7.1
func (s *DomainScanner) PrevLabel() (label string, end bool)
func (*DomainScanner) PrevLabelOffset ¶ added in v1.7.1
func (s *DomainScanner) PrevLabelOffset() int
func (*DomainScanner) PrevSubDomain ¶ added in v1.7.1
func (s *DomainScanner) PrevSubDomain() (sub string, end bool)
func (*DomainScanner) Scan ¶ added in v1.7.1
func (s *DomainScanner) Scan() bool
type FullMatcher ¶ added in v1.6.4
type FullMatcher struct {
// contains filtered or unexported fields
}
func NewFullMatcher ¶ added in v1.6.4
func NewFullMatcher() *FullMatcher
func (*FullMatcher) Add ¶ added in v1.6.4
func (m *FullMatcher) Add(s string, v interface{}) error
func (*FullMatcher) Len ¶ added in v1.6.4
func (m *FullMatcher) Len() int
func (*FullMatcher) Match ¶ added in v1.6.4
func (m *FullMatcher) Match(s string) (v interface{}, ok bool)
type KeywordMatcher ¶
type KeywordMatcher struct {
// contains filtered or unexported fields
}
func NewKeywordMatcher ¶
func NewKeywordMatcher() *KeywordMatcher
func (*KeywordMatcher) Add ¶
func (m *KeywordMatcher) Add(keyword string, v interface{}) error
func (*KeywordMatcher) Len ¶
func (m *KeywordMatcher) Len() int
func (*KeywordMatcher) Match ¶
func (m *KeywordMatcher) Match(s string) (v interface{}, ok bool)
type LabelNode ¶ added in v1.6.4
type LabelNode struct {
// contains filtered or unexported fields
}
LabelNode can store dns labels efficiently.
func (*LabelNode) MarkAsEndNode ¶ added in v1.6.4
func (n *LabelNode) MarkAsEndNode()
func (*LabelNode) StoreValue ¶ added in v1.6.4
func (n *LabelNode) StoreValue(v interface{})
type MixMatcher ¶
type MixMatcher struct {
// contains filtered or unexported fields
}
func NewMixMatcher ¶
func NewMixMatcher(options ...MixMatcherOption) *MixMatcher
NewMixMatcher creates a MixMatcher.
func NewMixMatcherFrom ¶ added in v1.7.1
func NewMixMatcherFrom(full, domain, keyword, regex Matcher) *MixMatcher
NewMixMatcherFrom creates a MixMatcher from those sub matcher. It ok to pass nil Matcher here. MixMatcher can lazy init nil sub matcher.
func (*MixMatcher) Add ¶
func (m *MixMatcher) Add(pattern string, v interface{}) error
func (*MixMatcher) AddElem ¶
func (m *MixMatcher) AddElem(typ MixMatcherPatternType, pattern string, v interface{}) error
func (*MixMatcher) Len ¶
func (m *MixMatcher) Len() int
func (*MixMatcher) Match ¶
func (m *MixMatcher) Match(s string) (v interface{}, ok bool)
func (*MixMatcher) SetPattenTypeMap ¶
func (m *MixMatcher) SetPattenTypeMap(typMap map[string]MixMatcherPatternType)
type MixMatcherOption ¶ added in v1.7.1
type MixMatcherOption func(mm *MixMatcher)
func WithDomainMatcher ¶ added in v1.7.1
func WithDomainMatcher(m Matcher) MixMatcherOption
func WithFullMatcher ¶ added in v1.7.1
func WithFullMatcher(m Matcher) MixMatcherOption
func WithKeywordMatcher ¶ added in v1.7.1
func WithKeywordMatcher(m Matcher) MixMatcherOption
func WithRegexpMatcher ¶ added in v1.7.1
func WithRegexpMatcher(m Matcher) MixMatcherOption
type MixMatcherPatternType ¶
type MixMatcherPatternType uint8
const ( MixMatcherPatternTypeDomain MixMatcherPatternType = iota MixMatcherPatternTypeFull MixMatcherPatternTypeKeyword MixMatcherPatternTypeRegexp )
type ProcessAttrFunc ¶
ProcessAttrFunc processes the additional attributions. The given []string could have a 0 length or is nil.
type RegexMatcher ¶
type RegexMatcher struct {
// contains filtered or unexported fields
}
func NewRegexMatcher ¶
func NewRegexMatcher() *RegexMatcher
func NewRegexMatcherWithCache ¶ added in v1.6.5
func NewRegexMatcherWithCache(cap int) *RegexMatcher
func (*RegexMatcher) Add ¶
func (m *RegexMatcher) Add(expr string, v interface{}) error
func (*RegexMatcher) Len ¶
func (m *RegexMatcher) Len() int
func (*RegexMatcher) Match ¶
func (m *RegexMatcher) Match(s string) (v interface{}, ok bool)
func (*RegexMatcher) ResetCache ¶ added in v1.6.5
func (m *RegexMatcher) ResetCache()
type SimpleDomainMatcher ¶ added in v1.7.1
type SimpleDomainMatcher struct {
// contains filtered or unexported fields
}
SimpleDomainMatcher just like DomainMatcher, but it can not store value. It allocates less memory than DomainMatcher.
func NewSimpleDomainMatcher ¶ added in v1.7.1
func NewSimpleDomainMatcher() *SimpleDomainMatcher
func (*SimpleDomainMatcher) Add ¶ added in v1.7.1
func (m *SimpleDomainMatcher) Add(s string, _ interface{}) error
func (*SimpleDomainMatcher) Len ¶ added in v1.7.1
func (m *SimpleDomainMatcher) Len() int
func (*SimpleDomainMatcher) Match ¶ added in v1.7.1
func (m *SimpleDomainMatcher) Match(s string) (v interface{}, ok bool)