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 ¶
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 an 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 ¶
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 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 ¶
UnifyDomain unifies domain strings. It removes 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 ¶
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 FullMatcher ¶
type FullMatcher struct {
// contains filtered or unexported fields
}
func NewFullMatcher ¶
func NewFullMatcher() *FullMatcher
func (*FullMatcher) Add ¶
func (m *FullMatcher) Add(s string, v interface{}) error
func (*FullMatcher) Len ¶
func (m *FullMatcher) Len() int
func (*FullMatcher) Match ¶
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 ¶
type LabelNode struct {
// contains filtered or unexported fields
}
LabelNode can store dns labels efficiently.
func (*LabelNode) MarkAsEndNode ¶
func (n *LabelNode) MarkAsEndNode()
func (*LabelNode) StoreValue ¶
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 ¶
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 ¶
type MixMatcherOption func(mm *MixMatcher)
func WithDomainMatcher ¶
func WithDomainMatcher(m Matcher) MixMatcherOption
func WithFullMatcher ¶
func WithFullMatcher(m Matcher) MixMatcherOption
func WithKeywordMatcher ¶
func WithKeywordMatcher(m Matcher) MixMatcherOption
func WithRegexpMatcher ¶
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 ¶
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 ¶
func (m *RegexMatcher) ResetCache()
type SimpleDomainMatcher ¶
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 ¶
func NewSimpleDomainMatcher() *SimpleDomainMatcher
func (*SimpleDomainMatcher) Add ¶
func (m *SimpleDomainMatcher) Add(s string, _ interface{}) error
func (*SimpleDomainMatcher) Len ¶
func (m *SimpleDomainMatcher) Len() int
func (*SimpleDomainMatcher) Match ¶
func (m *SimpleDomainMatcher) Match(s string) (v interface{}, ok bool)