domain

package
v5.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MatcherFull    = "full"
	MatcherDomain  = "domain"
	MatcherRegexp  = "regexp"
	MatcherKeyword = "keyword"
)

Variables

View Source
var ErrNodefaultMatcher = errors.New("default matcher is not set")

Functions

func Load

func Load[T any](m WriteableMatcher[T], s string, parseString ParseStringFunc[T]) error

Load loads data from a string, parsing it with parseString function.

func LoadFromTextReader

func LoadFromTextReader[T any](m WriteableMatcher[T], r io.Reader, parseString ParseStringFunc[T]) error

LoadFromTextReader loads multiple lines from reader r. r

func NormalizeDomain

func NormalizeDomain(s string) string

NormalizeDomain normalize domain string s. It removes the suffix "." and make sure the domain is in lower case. e.g. a fqdn "GOOGLE.com." will become "google.com"

func TrimDot

func TrimDot(s string) string

TrimDot trims suffix '.'

Types

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

Add adds domain s to this matcher, s can be a fqdn or not.

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

type MixMatcher

type MixMatcher[T any] struct {
	// contains filtered or unexported fields
}

func NewDomainMixMatcher

func NewDomainMixMatcher() *MixMatcher[struct{}]

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

func (m *MixMatcher[T]) GetSubMatcher(typ string) WriteableMatcher[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

func (m *MixMatcher[T]) SetDefaultMatcher(s string)

type ParseStringFunc

type ParseStringFunc[T any] func(s string) (pattern string, v T, err error)

ParseStringFunc parse data string to matcher pattern and additional attributions.

type RegexMatcher

type RegexMatcher[T any] struct {
	// contains filtered or unexported fields
}

RegexMatcher contains regexp rules. Note: the regexp rule is expect to match a lower-case non fqdn.

func NewRegexMatcher

func NewRegexMatcher[T any]() *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)

type ReverseDomainScanner

type ReverseDomainScanner struct {
	// contains filtered or unexported fields
}

func NewReverseDomainScanner

func NewReverseDomainScanner(s string) *ReverseDomainScanner

func (*ReverseDomainScanner) NextLabel

func (s *ReverseDomainScanner) NextLabel() (label string)

func (*ReverseDomainScanner) NextLabelOffset

func (s *ReverseDomainScanner) NextLabelOffset() int

func (*ReverseDomainScanner) Scan

func (s *ReverseDomainScanner) Scan() bool

type SubDomainMatcher

type SubDomainMatcher[T any] struct {
	// contains filtered or unexported fields
}

func NewSubDomainMatcher

func NewSubDomainMatcher[T any]() *SubDomainMatcher[T]

func (*SubDomainMatcher[T]) Add

func (m *SubDomainMatcher[T]) Add(s string, v T) error

func (*SubDomainMatcher[T]) Len

func (m *SubDomainMatcher[T]) Len() int

func (*SubDomainMatcher[T]) Match

func (m *SubDomainMatcher[T]) Match(s string) (T, bool)

type WriteableMatcher

type WriteableMatcher[T any] interface {
	Matcher[T]
	Add(pattern string, v T) error
}

Jump to

Keyboard shortcuts

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