Documentation
¶
Index ¶
- Constants
- func BatchLoad[T any](m Matcher[T], entries []string, processAttr ProcessAttrFunc[T]) error
- func Load[T any](m Matcher[T], entry string, processAttr ProcessAttrFunc[T]) error
- func LoadFromFile[T any](m Matcher[T], file string, processAttr ProcessAttrFunc[T]) error
- func LoadFromText[T any](m Matcher[T], s string, processAttr ProcessAttrFunc[T]) error
- func LoadFromTextFile[T any](m Matcher[T], file string, processAttr ProcessAttrFunc[T]) error
- func LoadFromTextReader[T any](m Matcher[T], r io.Reader, processAttr ProcessAttrFunc[T]) error
- func LoadGeoSiteFromDAT(file, countryCode string) (*v2data.GeoSite, error)
- func LoadGeoSiteList(file string) (*v2data.GeoSiteList, error)
- func LoadMixMatcherFromDAT[T any](m *MixMatcher[T], file, countryCode string, attrs []string) error
- func TrimDot(s string) string
- func UnifyDomain(s string) string
- type DomainMatcher
- type DomainScanner
- type FullMatcher
- type KeywordMatcher
- type LabelNode
- type Matcher
- type MixMatcher
- type ProcessAttrFunc
- type RegexMatcher
Constants ¶
View Source
const ( MatcherFull = "full" MatcherDomain = "domain" MatcherRegexp = "regexp" MatcherKeyword = "keyword" )
Variables ¶
This section is empty.
Functions ¶
func BatchLoad ¶ added in v3.9.0
func BatchLoad[T any](m Matcher[T], entries []string, processAttr ProcessAttrFunc[T]) error
BatchLoad loads multiple files or entries using Load.
func Load ¶
func Load[T any](m Matcher[T], entry string, processAttr ProcessAttrFunc[T]) 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 LoadFromFile ¶
func LoadFromFile[T any](m Matcher[T], file string, processAttr ProcessAttrFunc[T]) error
LoadFromFile loads data from a file.
func LoadFromText ¶
func LoadFromText[T any](m Matcher[T], s string, processAttr ProcessAttrFunc[T]) error
func LoadFromTextFile ¶
func LoadFromTextFile[T any](m Matcher[T], file string, processAttr ProcessAttrFunc[T]) error
func LoadFromTextReader ¶
func LoadGeoSiteFromDAT ¶ added in v3.9.0
func LoadGeoSiteList ¶ added in v3.9.0
func LoadGeoSiteList(file string) (*v2data.GeoSiteList, error)
func LoadMixMatcherFromDAT ¶ added in v3.9.0
func LoadMixMatcherFromDAT[T any](m *MixMatcher[T], file, countryCode string, attrs []string) error
func UnifyDomain ¶
UnifyDomain unifies domain strings. It removes the suffix "." and make sure the domain is in lower case.
Types ¶
type DomainMatcher ¶
type DomainMatcher[T any] struct { // contains filtered or unexported fields }
func NewDomainMatcher ¶
func NewDomainMatcher[T any]() *DomainMatcher[T]
func (*DomainMatcher[T]) Add ¶
func (m *DomainMatcher[T]) Add(s string, v T) error
func (*DomainMatcher[T]) Len ¶
func (m *DomainMatcher[T]) Len() int
func (*DomainMatcher[T]) Match ¶
func (m *DomainMatcher[T]) Match(s string) (T, 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[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 MixMatcher ¶
type MixMatcher[T any] struct { // contains filtered or unexported fields }
func NewMixMatcher ¶
func NewMixMatcher[T any]() *MixMatcher[T]
func (*MixMatcher[T]) Add ¶
func (m *MixMatcher[T]) Add(s string, v T) error
func (*MixMatcher[T]) GetSubMatcher ¶ added in v3.9.0
func (m *MixMatcher[T]) GetSubMatcher(typ string) Matcher[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 ¶ added in v3.9.0
func (m *MixMatcher[T]) SetDefaultMatcher(s string)
type ProcessAttrFunc ¶
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()
Click to show internal directories.
Click to hide internal directories.