Documentation
¶
Index ¶
- type CaddyWAF
- func (CaddyWAF) CaddyModule() caddy.ModuleInfo
- func (m *CaddyWAF) Cleanup() error
- func (m *CaddyWAF) Provision(ctx caddy.Context) error
- func (m *CaddyWAF) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error
- func (m *CaddyWAF) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- func (m *CaddyWAF) Validate() error
- type Engine
- type EnginePool
- type LoadBalancing
- type RandomSelection
- type RoundRobinSelection
- type Selector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CaddyWAF ¶
type CaddyWAF struct {
WafEngineAddrs []string `json:"waf_engine_addrs,omitempty"` // WAF Engine address, expects a URL or IP address
// Multiple WAF engine pools
Engines EnginePool
// Load balancing distributes load/requests between backends.
LoadBalancing *LoadBalancing `json:"load_balancing,omitempty"`
InitialCap int `json:"initial_cap,omitempty"`
MaxIdle int `json:"max_idle,omitempty"`
MaxCap int `json:"max_cap,omitempty"`
IdleTimeout time.Duration `json:"idle_timeout,omitempty"`
// MaxBodySize limits the number of request-body bytes sent to the detection engine;
// the full body is still forwarded downstream. A value of 0 preserves unlimited detection.
MaxBodySize int64 `json:"max_body_size,omitempty"`
HealthFailDuration caddy.Duration `json:"health_fail_duration,omitempty"`
HealthMaxFails int `json:"health_max_fails,omitempty"`
// contains filtered or unexported fields
}
CaddyWAF implements an HTTP handler for WAF.
func (CaddyWAF) CaddyModule ¶
func (CaddyWAF) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (*CaddyWAF) Cleanup ¶ added in v0.0.3
Cleanup releases the shared Engines this instance acquired at provisioning time. Metric series are per-Engine and are removed by the Engine's Destruct when the last referencing instance cleans up (registry reference count hits zero); the global metrics updater keeps running for the remaining Engines.
func (*CaddyWAF) ServeHTTP ¶
ServeHTTP processes incoming HTTP requests by utilizing the Caddy WAF engine to detect potential threats. If a request is identified as malicious, it redirects the request to an intercept handler. Otherwise, it passes the request to the next handler in the chain. The method handles detection errors and enforces a timeout for the detection process, logging relevant information in each case.
func (*CaddyWAF) UnmarshalCaddyfile ¶
UnmarshalCaddyfile implements caddyfile.Unmarshaler.
type Engine ¶ added in v0.0.10
type Engine struct {
// contains filtered or unexported fields
}
Engine wraps a t1k.ChannelPool with per-engine health state. An Engine is self-contained: it owns its Passive health check parameters (health_max_fails / health_fail_duration) and its own teardown, so availability decisions on a shared Engine are unambiguous.
func (*Engine) Destruct ¶ added in v0.0.17
Destruct tears the Engine down: it releases the Connection pool and removes this Engine's metric label series. The registry calls it when the last reference to the Engine is released. It is idempotent, and it marks the Engine destroyed so the metrics updater does not recreate its series after teardown.
func (*Engine) DetectHttpRequest ¶ added in v0.0.10
type EnginePool ¶ added in v0.0.6
type EnginePool []*Engine
type LoadBalancing ¶ added in v0.0.6
type LoadBalancing struct {
// A selection policy is how to choose an available backend.
// The default policy is random selection.
SelectionPolicyRaw json.RawMessage `json:"selection_policy,omitempty" caddy:"namespace=http.waf_chaitin.selection_policies inline_key=policy"`
// Retries is how many additional engines to try after the first
// Detect failure (engine errors only). Default 0 disables retry.
Retries int `json:"retries,omitempty"`
SelectionPolicy Selector `json:"-"`
}
LoadBalancing has parameters related to load balancing.
type RandomSelection ¶ added in v0.0.6
type RandomSelection struct{}
RandomSelection is a policy that selects an available host at random.
func (RandomSelection) CaddyModule ¶ added in v0.0.6
func (RandomSelection) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (RandomSelection) Select ¶ added in v0.0.6
func (r RandomSelection) Select(pool EnginePool, request *http.Request, _ http.ResponseWriter) *Engine
Select returns an available host, if any.
func (*RandomSelection) UnmarshalCaddyfile ¶ added in v0.0.6
func (r *RandomSelection) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile sets up the module from Caddyfile tokens.
type RoundRobinSelection ¶ added in v0.0.6
type RoundRobinSelection struct {
// contains filtered or unexported fields
}
RoundRobinSelection is a policy that selects a host based on round-robin ordering.
func (RoundRobinSelection) CaddyModule ¶ added in v0.0.6
func (RoundRobinSelection) CaddyModule() caddy.ModuleInfo
CaddyModule returns the Caddy module information.
func (*RoundRobinSelection) Select ¶ added in v0.0.6
func (r *RoundRobinSelection) Select(pool EnginePool, _ *http.Request, _ http.ResponseWriter) *Engine
Select returns an available host, if any.
func (*RoundRobinSelection) UnmarshalCaddyfile ¶ added in v0.0.6
func (r *RoundRobinSelection) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
UnmarshalCaddyfile sets up the module from Caddyfile tokens.
type Selector ¶ added in v0.0.6
type Selector interface {
Select(EnginePool, *http.Request, http.ResponseWriter) *Engine
}
Selector selects an available upstream from the pool.