filter

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxParentPathCount         = 32 // 相对于上一级目录,本级path目录的数量修正最大值
	MaxParamKeySingleCount     = 8  // 某个URL参数名重复修正最大值
	MaxParamKeyAllCount        = 10 // 本轮所有URL中某个参数名的重复修正最大值
	MaxPathParamEmptyCount     = 10 // 某个path下的参数值为空,参数名个数修正最大值
	MaxPathParamKeySymbolCount = 5  // 某个Path下的某个参数的标记数量超过此值,则该参数被全局标记
)
View Source
const (
	CustomValueMark    = "{{Crawlergo}}"
	FixParamRepeatMark = "{{fix_param}}"
	FixPathMark        = "{{fix_path}}"
	TooLongMark        = "{{long}}"
	NumberMark         = "{{number}}"
	ChineseMark        = "{{chinese}}"
	UpperMark          = "{{upper}}"
	LowerMark          = "{{lower}}"
	UrlEncodeMark      = "{{urlencode}}"
	UnicodeMark        = "{{unicode}}"
	BoolMark           = "{{bool}}"
	ListMark           = "{{list}}"
	TimeMark           = "{{time}}"
	MixAlphaNumMark    = "{{mix_alpha_num}}"
	MixSymbolMark      = "{{mix_symbol}}"
	MixNumMark         = "{{mix_num}}"
	NoLowerAlphaMark   = "{{no_lower}}"
	MixStringMark      = "{{mix_str}}"
)

Variables

View Source
var OneNumberRegex = regexp.MustCompile(`[0-9]`)

Functions

func MarkPath

func MarkPath(path string) string

MarkPath 标记路径

Types

type Handler

type Handler interface {
	DoFilter(req *model.Request) bool
}

type SimpleFilter

type SimpleFilter struct {
	UniqueSet mapset.Set[string]
	HostLimit string
	// contains filtered or unexported fields
}

func NewSimpleFilter

func NewSimpleFilter(host string) *SimpleFilter

func (*SimpleFilter) DoFilter

func (s *SimpleFilter) DoFilter(req *model.Request) bool

DoFilter 需要过滤则返回 true

func (*SimpleFilter) DomainFilter

func (s *SimpleFilter) DomainFilter(req *model.Request) bool

* 只保留指定域名的链接

func (*SimpleFilter) StaticFilter

func (s *SimpleFilter) StaticFilter(req *model.Request) bool

* 静态资源过滤

func (*SimpleFilter) UniqueFilter

func (s *SimpleFilter) UniqueFilter(req *model.Request) bool

UniqueFilter 请求去重

type SmartFilter

type SmartFilter struct {
	StrictMode bool
	*SimpleFilter
	// contains filtered or unexported fields
}

func NewSmartFilter

func NewSmartFilter(base *SimpleFilter, strictMode bool) *SmartFilter

func (*SmartFilter) DoFilter

func (s *SmartFilter) DoFilter(req *model.Request) bool

DoFilter 智能去重 可选严格模式 需要过滤则返回 true

Jump to

Keyboard shortcuts

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