class Azu::Handler::Throttle
- Azu::Handler::Throttle
- Reference
- Object
Overview
Handler for protecting against Denial-of-service attacks and/or to rate limit requests.
DDoS errors occur when the client is sending too many requests at once. these attacks are essentially rate-limiting problems.
By blocking a certain IP address, or allowing a certain IP address to make a limited number of requests over a certain period of time, you are building the first line of defense in blocking DDoS attacks. http://en.wikipedia.org/wiki/Denial-of-service_attack.
Options
- interval Duration in seconds until the request counter is reset. Defaults to 5
- duration Duration in seconds that a remote address will be blocked. Defaults to 900 (15 minutes)
- threshold Number of requests allowed. Defaults to 100
- blacklist Array of remote addresses immediately considered malicious.
- whitelist Array of remote addresses which bypass Deflect.
Usage
Azu::Throttle.new(
interval: 5,
duration: 5,
threshold: 10,
blacklist: ["111.111.111.111"],
whitelist: ["222.222.222.222"]
)
Included Modules
- HTTP::Handler
Defined in:
azu/handler/throttle.crConstant Summary
-
CONTENT_LENGTH =
"Content-Length"
-
CONTENT_TYPE =
"Content-Type"
-
MAPPER =
{} of String => Hash(String, Int32 | Int64)
-
REMOTE_ADDR =
"REMOTE_ADDR"
-
RETRY_AFTER =
"Retry-After"
Constructors
Instance Method Summary
Constructor Detail
def self.new(interval : Int32, duration : Int32, threshold : Int32, blacklist : Array(String), whitelist : Array(String))
#