spray/internal/types.go

63 lines
1.1 KiB
Go
Raw Normal View History

2022-09-15 19:27:07 +08:00
package internal
type ErrorType uint
const (
ErrBadStatus ErrorType = iota
ErrSameStatus
ErrRequestFailed
2022-09-15 19:27:07 +08:00
ErrWaf
ErrRedirect
2022-11-17 05:53:04 +08:00
ErrCompareFailed
ErrFuzzyCompareFailed
ErrCustomCompareFailed
ErrCustomFilter
2022-09-15 19:27:07 +08:00
)
func (e ErrorType) Error() string {
switch e {
case ErrBadStatus:
2022-12-02 15:21:17 +08:00
return "blacklist status"
case ErrSameStatus:
2022-12-02 15:21:17 +08:00
return "same status with random baseline"
case ErrRequestFailed:
return "request failed"
2022-09-15 19:27:07 +08:00
case ErrWaf:
return "maybe banned by waf"
2022-09-15 19:27:07 +08:00
case ErrRedirect:
return "duplicate redirect url"
2022-11-17 05:53:04 +08:00
case ErrCompareFailed:
return "compare failed"
case ErrFuzzyCompareFailed:
return "fuzzy compare failed"
case ErrCustomCompareFailed:
return "custom compare failed"
case ErrCustomFilter:
return "custom filtered"
2022-09-15 19:27:07 +08:00
default:
return "unknown error"
}
}
2022-10-19 16:38:23 +08:00
type sourceType int
const (
CheckSource sourceType = iota + 1
InitRandomSource
InitIndexSource
2022-11-29 21:55:27 +08:00
RedirectSource
2022-10-19 16:38:23 +08:00
WordSource
WafSource
)
func newUnit(path string, source sourceType) *Unit {
return &Unit{path: path, source: source}
}
type Unit struct {
2022-11-29 21:55:27 +08:00
path string
source sourceType
frontUrl string
reCount int
2022-10-19 16:38:23 +08:00
}