Skip to content

Throttle

class Azu::Handler::Throttle
inherits Reference

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

Constants

CONTENT_LENGTH = "Content-Length"

CONTENT_TYPE = "Content-Type"

MAPPER = {} of String => Hash(String, Int32 | Int64)

REMOTE_ADDR = "REMOTE_ADDR"

RETRY_AFTER = "Retry-After"

Class methods

.new(interval, duration, threshold, blacklist, whitelist)

View source

Methods

#call(context : HTTP::Server::Context)

View source