Documentation
¶
Index ¶
- Constants
- Variables
- type ASNs
- type BotConfig
- type BotOrImport
- type ChallengeRules
- type Config
- type ExpressionOrList
- func (eol ExpressionOrList) Equal(rhs *ExpressionOrList) bool
- func (eol *ExpressionOrList) MarshalJSON() ([]byte, error)
- func (eol *ExpressionOrList) MarshalYAML() (any, error)
- func (eol ExpressionOrList) String() string
- func (eol *ExpressionOrList) UnmarshalJSON(data []byte) error
- func (eol *ExpressionOrList) Valid() error
- type GeoIP
- type ImportStatement
- type Impressum
- type ImpressumPage
- type OpenGraph
- type Rule
- type StatusCodes
- type Store
- type Threshold
- type Weight
Constants ¶
View Source
const DefaultAlgorithm = "fast"
Variables ¶
View Source
var ( ErrNoBotRulesDefined = errors.New("config: must define at least one (1) bot rule") ErrBotMustHaveName = errors.New("config.Bot: must set name") ErrBotMustHaveUserAgentOrPath = errors.New("config.Bot: must set either user_agent_regex, path_regex, headers_regex, or remote_addresses") ErrBotMustHaveUserAgentOrPathNotBoth = errors.New("config.Bot: must set either user_agent_regex, path_regex, and not both") ErrUnknownAction = errors.New("config.Bot: unknown action") ErrInvalidUserAgentRegex = errors.New("config.Bot: invalid user agent regex") ErrInvalidPathRegex = errors.New("config.Bot: invalid path regex") ErrInvalidHeadersRegex = errors.New("config.Bot: invalid headers regex") ErrInvalidCIDR = errors.New("config.Bot: invalid CIDR") ErrRegexEndsWithNewline = errors.New("config.Bot: regular expression ends with newline (try >- instead of > in yaml)") ErrInvalidImportStatement = errors.New("config.ImportStatement: invalid source file") ErrCantSetBotAndImportValuesAtOnce = errors.New("config.BotOrImport: can't set bot rules and import values at the same time") ErrMustSetBotOrImportRules = errors.New("config.BotOrImport: rule definition is invalid, you must set either bot rules or an import statement, not both") ErrStatusCodeNotValid = errors.New("config.StatusCode: status code not valid, must be between 100 and 599") )
View Source
var ( ErrChallengeDifficultyTooLow = errors.New("config.ChallengeRules: difficulty is too low (must be >= 0)") ErrChallengeDifficultyTooHigh = errors.New("config.ChallengeRules: difficulty is too high (must be <= 64)") ErrChallengeMustHaveAlgorithm = errors.New("config.ChallengeRules: must have algorithm name set") )
View Source
var ( ErrExpressionOrListMustBeStringOrObject = errors.New("config: this must be a string or an object") ErrExpressionEmpty = errors.New("config: this expression is empty") ErrExpressionCantHaveBoth = errors.New("config: expression block can't contain multiple expression types") )
View Source
var ( ErrInvalidOpenGraphConfig = errors.New("config.OpenGraph: invalid OpenGraph configuration") ErrOpenGraphTTLDoesNotParse = errors.New("config.OpenGraph: ttl does not parse as a Duration, see https://pkg.go.dev/time#ParseDuration (formatted like 5m -> 5 minutes, 2h -> 2 hours, etc)") ErrOpenGraphMissingProperty = errors.New("config.OpenGraph: default opengraph tags missing a property") )
View Source
var ( ErrNoStoreBackend = errors.New("config.Store: no backend defined") ErrUnknownStoreBackend = errors.New("config.Store: unknown backend") )
View Source
var ( ErrNoThresholdRulesDefined = errors.New("config: no thresholds defined") ErrThresholdMustHaveName = errors.New("config.Threshold: must set name") ErrThresholdMustHaveExpression = errors.New("config.Threshold: must set expression") ErrThresholdChallengeMustHaveChallenge = errors.New("config.Threshold: a threshold with the CHALLENGE action must have challenge set") ErrThresholdCannotHaveWeighAction = errors.New("config.Threshold: a threshold cannot have the WEIGH action") DefaultThresholds = []Threshold{ { Name: "legacy-anubis-behaviour", Expression: &ExpressionOrList{ Expression: "weight > 0", }, Action: RuleChallenge, Challenge: &ChallengeRules{ Algorithm: "fast", Difficulty: anubis.DefaultDifficulty, ReportAs: anubis.DefaultDifficulty, }, }, } )
View Source
var ErrMissingValue = errors.New("config: missing value")
View Source
var (
ErrNotCountryCode = errors.New("config.Bot: invalid country code")
)
View Source
var (
ErrPrivateASN = errors.New("bot.ASNs: you have specified a private use ASN")
)
Functions ¶
This section is empty.
Types ¶
type BotConfig ¶
type BotConfig struct {
UserAgentRegex *string `json:"user_agent_regex,omitempty" yaml:"user_agent_regex,omitempty"`
PathRegex *string `json:"path_regex,omitempty" yaml:"path_regex,omitempty"`
HeadersRegex map[string]string `json:"headers_regex,omitempty" yaml:"headers_regex,omitempty"`
Expression *ExpressionOrList `json:"expression,omitempty" yaml:"expression,omitempty"`
Challenge *ChallengeRules `json:"challenge,omitempty" yaml:"challenge,omitempty"`
Weight *Weight `json:"weight,omitempty" yaml:"weight,omitempty"`
Name string `json:"name" yaml:"name"`
Action Rule `json:"action" yaml:"action"`
RemoteAddr []string `json:"remote_addresses,omitempty" yaml:"remote_addresses,omitempty"`
// Thoth features
GeoIP *GeoIP `json:"geoip,omitempty"`
ASNs *ASNs `json:"asns,omitempty"`
}
type BotOrImport ¶ added in v1.17.0
type BotOrImport struct {
*BotConfig `json:",inline"`
*ImportStatement `json:",inline"`
}
func (*BotOrImport) Valid ¶ added in v1.17.0
func (boi *BotOrImport) Valid() error
type ChallengeRules ¶
type ChallengeRules struct {
Algorithm string `json:"algorithm,omitempty" yaml:"algorithm,omitempty"`
Difficulty int `json:"difficulty,omitempty" yaml:"difficulty,omitempty"`
ReportAs int `json:"report_as,omitempty" yaml:"report_as,omitempty"`
}
func (ChallengeRules) Valid ¶
func (cr ChallengeRules) Valid() error
type Config ¶
type ExpressionOrList ¶ added in v1.18.0
type ExpressionOrList struct {
Expression string `json:"-" yaml:"-"`
All []string `json:"all,omitempty" yaml:"all,omitempty"`
Any []string `json:"any,omitempty" yaml:"any,omitempty"`
}
func (ExpressionOrList) Equal ¶ added in v1.18.0
func (eol ExpressionOrList) Equal(rhs *ExpressionOrList) bool
func (*ExpressionOrList) MarshalJSON ¶ added in v1.20.0
func (eol *ExpressionOrList) MarshalJSON() ([]byte, error)
func (*ExpressionOrList) MarshalYAML ¶ added in v1.20.0
func (eol *ExpressionOrList) MarshalYAML() (any, error)
func (ExpressionOrList) String ¶ added in v1.20.0
func (eol ExpressionOrList) String() string
func (*ExpressionOrList) UnmarshalJSON ¶ added in v1.18.0
func (eol *ExpressionOrList) UnmarshalJSON(data []byte) error
func (*ExpressionOrList) Valid ¶ added in v1.18.0
func (eol *ExpressionOrList) Valid() error
type ImportStatement ¶ added in v1.17.0
func (*ImportStatement) Valid ¶ added in v1.17.0
func (is *ImportStatement) Valid() error
type Impressum ¶ added in v1.20.0
type Impressum struct {
Page ImpressumPage `json:"page" yaml:"page"`
}
type ImpressumPage ¶ added in v1.20.0
type ImpressumPage struct {
Title string `json:"title" yaml:"title"`
Body string `json:"body" yaml:"body"`
}
func (ImpressumPage) Valid ¶ added in v1.20.0
func (ip ImpressumPage) Valid() error
type StatusCodes ¶ added in v1.17.1
func (StatusCodes) Valid ¶ added in v1.17.1
func (sc StatusCodes) Valid() error
type Store ¶ added in v1.21.0
type Store struct {
Backend string `json:"backend"`
Parameters json.RawMessage `json:"parameters"`
}
type Threshold ¶ added in v1.20.0
type Threshold struct {
Name string `json:"name" yaml:"name"`
Expression *ExpressionOrList `json:"expression" yaml:"expression"`
Action Rule `json:"action" yaml:"action"`
Challenge *ChallengeRules `json:"challenge" yaml:"challenge"`
}
Click to show internal directories.
Click to hide internal directories.