class

KemalWAF::RateLimiter

Inherits Reference / Object

============================================================================= Rate Limiter with Sharded State Map

Constants

Log = ::Log.for("rate_limiter")

Constructors

new(default_limit : Int32 = 100, default_window_sec : Int32 = 60, block_duration_sec : Int32 = 300)
Source

Instance methods

add_endpoint_limit(path_pattern : String, limit : Int32, window_sec : Int32)

Add endpoint limit

Source
block_ip(ip : String, duration_sec : Int32 | Nil = nil)

Block IP temporarily

Source
check(ip : String, path : String) : RateLimitResult

Check rate limit

Source
set_headers(response : HTTP::Server::Response, result : RateLimitResult)

Set rate limit headers

Source
stats

Get statistics

Source
unblock_ip(ip : String)

Unblock IP

Source