Documentation
¶
Index ¶
- Constants
- Variables
- type ASNs
- type BotConfig
- type BotOrImport
- type ChallengeRules
- type Config
- type DnsTTL
- 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 Logging
- type LoggingFileConfig
- type OpenGraph
- type Rule
- type StatusCodes
- type Store
- type Threshold
- type Weight
Constants ¶
View Source
const ( LogSinkStdio = "stdio" LogSinkFile = "file" )
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 ( ErrMissingLoggingFileConfig = errors.New("config.Logging: missing value parameters in logging block") ErrInvalidLoggingSink = errors.New("config.Logging: invalid sink") ErrInvalidLoggingFileConfig = errors.New("config.LoggingFileConfig: invalid parameters") ErrOutOfRange = errors.New("config: error out of range") )
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, }, }, } )
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"`
// Thoth features
GeoIP *GeoIP `json:"geoip,omitempty"`
ASNs *ASNs `json:"asns,omitempty"`
Name string `json:"name" yaml:"name"`
Action Rule `json:"action" yaml:"action"`
RemoteAddr []string `json:"remote_addresses,omitempty" yaml:"remote_addresses,omitempty"`
}
type BotOrImport ¶
type BotOrImport struct {
*BotConfig `json:",inline"`
*ImportStatement `json:",inline"`
}
func (*BotOrImport) Valid ¶
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 ¶
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 ¶
func (eol ExpressionOrList) Equal(rhs *ExpressionOrList) bool
func (*ExpressionOrList) MarshalJSON ¶
func (eol *ExpressionOrList) MarshalJSON() ([]byte, error)
func (*ExpressionOrList) MarshalYAML ¶
func (eol *ExpressionOrList) MarshalYAML() (any, error)
func (ExpressionOrList) String ¶
func (eol ExpressionOrList) String() string
func (*ExpressionOrList) UnmarshalJSON ¶
func (eol *ExpressionOrList) UnmarshalJSON(data []byte) error
func (*ExpressionOrList) Valid ¶
func (eol *ExpressionOrList) Valid() error
type ImportStatement ¶
func (*ImportStatement) Valid ¶
func (is *ImportStatement) Valid() error
type Impressum ¶
type Impressum struct {
Page ImpressumPage `json:"page" yaml:"page"`
}
type ImpressumPage ¶
type ImpressumPage struct {
Title string `json:"title" yaml:"title"`
Body string `json:"body" yaml:"body"`
}
func (ImpressumPage) Valid ¶
func (ip ImpressumPage) Valid() error
type Logging ¶
type Logging struct {
Sink string `json:"sink"` // Logging sink, either "stdio" or "file"
Level *slog.Level `json:"level"` // Log level, if set supercedes the level in flags
Parameters *LoggingFileConfig `json:"parameters"` // Logging parameters, to be dynamic in the future
}
type LoggingFileConfig ¶
type LoggingFileConfig struct {
Filename string `json:"file"`
MaxBackups int `json:"maxBackups"`
MaxBytes int64 `json:"maxBytes"`
MaxAge int `json:"maxAge"`
Compress bool `json:"compress"`
UseLocalTime bool `json:"useLocalTime"`
}
func (LoggingFileConfig) Default ¶
func (LoggingFileConfig) Default() *LoggingFileConfig
func (*LoggingFileConfig) Valid ¶
func (lfc *LoggingFileConfig) Valid() error
func (LoggingFileConfig) Zero ¶
func (lfc LoggingFileConfig) Zero() bool
type StatusCodes ¶
func (StatusCodes) Valid ¶
func (sc StatusCodes) Valid() error
type Store ¶
type Store struct {
Backend string `json:"backend"`
Parameters json.RawMessage `json:"parameters"`
}
type Threshold ¶
type Threshold struct {
Expression *ExpressionOrList `json:"expression" yaml:"expression"`
Challenge *ChallengeRules `json:"challenge" yaml:"challenge"`
Name string `json:"name" yaml:"name"`
Action Rule `json:"action" yaml:"action"`
}
Click to show internal directories.
Click to hide internal directories.