spray/internal/types.go

80 lines
1.6 KiB
Go
Raw Normal View History

2022-09-15 19:27:07 +08:00
package internal
import (
"github.com/chainreactors/spray/pkg"
"github.com/chainreactors/words/rule"
)
2022-09-15 19:27:07 +08:00
type ErrorType uint
const (
NoErr ErrorType = iota
ErrBadStatus
ErrSameStatus
ErrRequestFailed
2022-09-15 19:27:07 +08:00
ErrWaf
ErrRedirect
2022-11-17 05:53:04 +08:00
ErrCompareFailed
ErrCustomCompareFailed
ErrCustomFilter
ErrFuzzyCompareFailed
ErrFuzzyRedirect
ErrFuzzyNotUnique
2022-09-15 19:27:07 +08:00
)
var ErrMap = map[ErrorType]string{
NoErr: "",
ErrBadStatus: "blacklist status",
ErrSameStatus: "same status with random baseline",
ErrRequestFailed: "request failed",
ErrWaf: "maybe banned by waf",
ErrRedirect: "duplicate redirect url",
ErrCompareFailed: "compare failed",
ErrCustomCompareFailed: "custom compare failed",
ErrCustomFilter: "custom filtered",
ErrFuzzyCompareFailed: "fuzzy compare failed",
ErrFuzzyRedirect: "fuzzy redirect",
ErrFuzzyNotUnique: "not unique",
}
2022-09-15 19:27:07 +08:00
func (e ErrorType) Error() string {
return ErrMap[e]
2022-09-15 19:27:07 +08:00
}
2022-10-19 16:38:23 +08:00
const (
CheckSource = iota + 1
InitRandomSource
InitIndexSource
2022-11-29 21:55:27 +08:00
RedirectSource
2023-01-03 17:09:32 +08:00
CrawlSource
2023-01-03 17:16:55 +08:00
ActiveSource
2022-10-19 16:38:23 +08:00
WordSource
WafSource
RuleSource
BakSource
CommonFileSource
2022-10-19 16:38:23 +08:00
)
func newUnit(path string, source int) *Unit {
2022-10-19 16:38:23 +08:00
return &Unit{path: path, source: source}
}
func newUnitWithNumber(path string, source int, number int) *Unit {
return &Unit{path: path, source: source, number: number}
}
2022-10-19 16:38:23 +08:00
type Unit struct {
number int
2022-11-29 21:55:27 +08:00
path string
source int
2022-11-29 21:55:27 +08:00
frontUrl string
2023-01-03 17:09:32 +08:00
depth int // redirect depth
2022-10-19 16:38:23 +08:00
}
type Task struct {
baseUrl string
depth int
rule []rule.Expression
origin *pkg.Statistor
}