Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EvalComposite ¶
func EvalComposite(local, global *Engine, ctx *fingerprint.RequestCtx) (action Action, upstream, ruleID string, rule *Rule, prefix string)
EvalComposite evaluates the request against a listener-specific engine first and then the global engine. The global engine's DefaultAction is used when no rule matches. Either engine may be nil.
Types ¶
type And ¶
type And struct{ Kids []Expr }
func (And) Eval ¶
func (a And) Eval(c *fingerprint.RequestCtx) bool
type Cond ¶
type Cond struct {
Matcher func(*fingerprint.RequestCtx) bool
}
Cond wraps a matcher function.
func (Cond) Eval ¶
func (c Cond) Eval(ctx *fingerprint.RequestCtx) bool
type Engine ¶
Engine evaluates incoming requests against loaded rules.
func (*Engine) Eval ¶
func (e *Engine) Eval(ctx *fingerprint.RequestCtx) (action Action, upstream, ruleID string)
func (*Engine) EvalRule ¶
func (e *Engine) EvalRule(ctx *fingerprint.RequestCtx) *Rule
Eval finds the first matching rule for the request context. If no rule matches, ActionAllow and empty ruleID are returned.
func (*Engine) LoadFromFile ¶
LoadFromFile loads rule definitions from an HCL file.
type Expr ¶
type Expr interface {
Eval(*fingerprint.RequestCtx) bool
}
Expr represents a boolean expression node.
type FieldGetter ¶
type FieldGetter func(*fingerprint.RequestCtx) []string
FieldGetter returns zero or more values for a field.
type Or ¶
type Or struct{ Kids []Expr }
func (Or) Eval ¶
func (o Or) Eval(c *fingerprint.RequestCtx) bool
type Rule ¶
type Rule struct {
ID string
Action Action
DeceptionMode string
Upstream *url.URL
StripPrefix string
Expires *time.Time
Expr Expr
}
Rule is a compiled rule from the HCL file.
func (*Rule) Matches ¶
func (r *Rule) Matches(ctx *fingerprint.RequestCtx) bool
type RuleSet ¶
type RuleSet struct{ Rules []*Rule }
RuleSet is a set of compiled rules.
func LoadHCLBytes ¶
LoadHCLBytes loads rules from an HCL byte slice.