domain

package
v3.9.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2022 License: GPL-3.0 Imports: 14 Imported by: 1

Documentation

Index

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 LoadFromTextReader[T any](m Matcher[T], r io.Reader, processAttr ProcessAttrFunc[T]) error

func LoadGeoSiteFromDAT added in v3.9.0

func LoadGeoSiteFromDAT(file, countryCode string) (*v2data.GeoSite, error)

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 TrimDot

func TrimDot(s string) string

TrimDot trims the suffix '.'.

func UnifyDomain

func UnifyDomain(s string) string

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]) GetChild

func (n *LabelNode[T]) GetChild(key string) *LabelNode[T]

func (*LabelNode[T]) GetValue

func (n *LabelNode[T]) GetValue() (T, bool)

func (*LabelNode[T]) HasValue added in v3.9.0

func (n *LabelNode[T]) HasValue() bool

func (*LabelNode[T]) Len

func (n *LabelNode[T]) Len() int

func (*LabelNode[T]) NewChild

func (n *LabelNode[T]) NewChild(key string) *LabelNode[T]

func (*LabelNode[T]) StoreValue

func (n *LabelNode[T]) StoreValue(v T)

type Matcher

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

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

type ProcessAttrFunc[T any] func(attr string) (v T, err error)

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()

Jump to

Keyboard shortcuts

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