class
Circed::Services::RateLimiter
- Circed::Services::RateLimiter
- Reference
- Object
Overview
Rate limiter for IRC commands to prevent flooding
Defined in:
circed/services/rate_limiter.crConstant Summary
-
COMMAND_LIMITS =
{"PRIVMSG" => {max_commands: 5, time_window: 10}, "NOTICE" => {max_commands: 5, time_window: 10}, "JOIN" => {max_commands: 3, time_window: 10}, "PART" => {max_commands: 3, time_window: 10}, "NICK" => {max_commands: 2, time_window: 30}, "WHOIS" => {max_commands: 3, time_window: 10}, "WHO" => {max_commands: 2, time_window: 10}, "NAMES" => {max_commands: 2, time_window: 10}, "LIST" => {max_commands: 1, time_window: 30}, "TOPIC" => {max_commands: 2, time_window: 10}, "MODE" => {max_commands: 3, time_window: 10}, "KICK" => {max_commands: 2, time_window: 10}, "INVITE" => {max_commands: 2, time_window: 10}}
-
Different rate limits for different command types
-
DEFAULT_BURST_SIZE =
5
-
DEFAULT_MAX_COMMANDS =
10
-
Per-client rate limiting configuration
-
DEFAULT_TIME_WINDOW =
60
Class Method Summary
- .check_rate_limit(client_id : String, command : String) : Bool
- .cleanup_old_entries : Void
- .clear_client_history(client_id : String) : Void
- .get_client_stats(client_id : String) : Hash(String, Int32)
- .get_remaining_quota(client_id : String, command : String) : Int32
- .get_reset_time(client_id : String, command : String) : Time | Nil
- .global_stats : Hash(String, Int32)
- .rate_limited?(client_id : String, command : String) : Bool
-
.registration_command?(command : String) : Bool
Special handling for burst commands during registration
- .should_rate_limit?(command : String) : Bool
Class Method Detail
def self.registration_command?(command : String) : Bool
#
Special handling for burst commands during registration