domain

package
Version: v1.8.7 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2021 License: GPL-3.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LoadFromDATFunc func(m *MixMatcher, file, countryCode string, processAttr ProcessAttrFunc) error

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 TrimDot added in v1.7.2

func TrimDot(s string) string

TrimDot trims the suffix '.'.

func UnifyDomain added in v1.7.2

func UnifyDomain(s string) string

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) GetChild added in v1.6.4

func (n *LabelNode) GetChild(key string) *LabelNode

func (*LabelNode) GetValue added in v1.6.4

func (n *LabelNode) GetValue() interface{}

func (*LabelNode) IsEnd added in v1.6.4

func (n *LabelNode) IsEnd() bool

func (*LabelNode) Len added in v1.6.4

func (n *LabelNode) Len() int

func (*LabelNode) MarkAsEndNode added in v1.6.4

func (n *LabelNode) MarkAsEndNode()

func (*LabelNode) NewChild added in v1.6.4

func (n *LabelNode) NewChild(key string) *LabelNode

func (*LabelNode) StoreValue added in v1.6.4

func (n *LabelNode) StoreValue(v interface{})

type Matcher

type Matcher interface {
	// Match matches the domain s.
	// s could be an fqdn or not, and should be case insensitive.
	Match(s string) (v interface{}, ok bool)
	Len() int
	Add(pattern string, v interface{}) error
}

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

type ProcessAttrFunc func([]string) (v interface{}, accept bool, err error)

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)

Jump to

Keyboard shortcuts

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