class Azu::Handler::Throttle

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

Usage

Azu::Throttle.new(
  interval: 5,
  duration: 5,
  threshold: 10,
  blacklist: ["111.111.111.111"],
  whitelist: ["222.222.222.222"]
)

Included Modules

Defined in:

azu/handler/throttle.cr

Constant 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)) #

[View source]

Instance Method Detail

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

[View source]