Skip to main content

Module guard

Module guard 

Source
Expand description

Request limits per client, like Clio’s DOS guard.

Each client (IP address) has, per sweep interval, a budget of weighted requests and of response bytes, and a cap on connections open at once (HTTP requests in progress and WebSocket sessions). Past either budget, or at the connection cap, the client gets slowDown until the next sweep: over HTTP as status 503 with the error in the body, as Clio does, over WebSocket as an error response. Whitelisted addresses are not counted.

Behind a proxy every request comes from the proxy’s address. Only for a peer listed as a trusted proxy is the client taken from the request: from CF-Connecting-IP (Cloudflare), else the last for= of Forwarded (as Clio), else the first address of X-Forwarded-For. From anyone else these headers are ignored, so a client can’t pose as another.

Off unless configured: with no budgets set nothing is counted.

Structs§

Connection
An open connection; closing it gives the slot back.
Guard
GuardConfig
Limits; None means no limit of that kind.
Net
An address or a network in CIDR notation.

Functions§

weight
How much a request counts against the budget: reads that walk many objects or build proofs count more.