From 4dbdd9bdde90fba5dd201d7a0f8944e7a8f82c4a Mon Sep 17 00:00:00 2001 From: hanez Date: Sat, 25 Jul 2026 20:44:13 +0200 Subject: [PATCH] 0.42.0 Add detailed changelog for flood protection, bump version. Note: the previous commit (3b97b4d) implemented the flood protection changes but was committed as 0.41.2. This commit corrects the version to 0.42.0 to reflect the scope of the changes (breaking rate_limit_check signature, new constants, new outgoing throttle, etc.) and adds the matching detailed CHANGELOG.md entry. Changes documented in CHANGELOG.md: - Per-poll line limit (MAX_LINES_PER_POLL = 50) in irc_feed() - Userhost-based rate limiting replacing nick-based tracking - Violation tracking in RateLimitEntry for escalating penalties - RATE_LIMIT_MAX increased from 8 to 32 - Outgoing message throttle (OUTGOING_DELAY_MS = 100) in net_send() - 200ms inter-line delay in !gitlog output - 150ms inter-chunk delay in AI response delivery - AI_COOLDOWN_SECS = 5 after query completion - Rate limiting added to greeting/chat responses - TELL_DELIVER_MAX = 5 messages per nick per delivery - Updated all 19 command headers for new rate_limit_check() signature --- CHANGELOG.md | 16 ++++++++++++++++ CMakeLists.txt | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78443f8..f893e11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +2026.07.25 - Comprehensive flood protection: per-poll limits, userhost rate limiting, outgoing throttle. (0.42.0) + +- Added `MAX_LINES_PER_POLL = 50` constant and per-poll line counting in `irc_feed()`: the bot now drops excess lines when a single poll iteration delivers more than 50 complete IRC messages, preventing burst flooding from overwhelming the bot or triggering IRC server excess flood disconnects. +- Added `poll_lines_left` counter to `Session` struct, reset at the start of each poll cycle in `main()` before calling `irc_feed()`. +- Changed `RateLimitEntry` to track by `user@host` instead of nick: the rate limiter now keys on the full userhost extracted from the IRC prefix (`nick!user@host`) rather than the nick alone, preventing trivial bypass via nick cycling. Added `userhost[128]` field replacing the old `nick[32]` field. +- Added `current_userhost[128]` global variable, parsed from the IRC message prefix in `irc_handle()` before dispatching to command handlers. Updated `rate_limit_check()` signature to accept the userhost parameter. +- Added violation tracking to `RateLimitEntry` with a `violations` counter: repeated rate limit hits from the same userhost increment the counter, enabling future escalating penalties (warnings at 3 violations, kick requests at 5). +- Increased `RATE_LIMIT_MAX` from 8 to 32, expanding the rate limit tracking buffer to handle more concurrent users without evicting entries. +- Added outgoing message throttle to `net_send()`: uses `clock_gettime(CLOCK_MONOTONIC)` timestamp tracking to enforce a minimum `OUTGOING_DELAY_MS = 100` millisecond delay between consecutive sends, preventing the bot from flooding the IRC server with rapid bursts. +- Added 200ms inter-line delay in `!gitlog` output (`cmd_gitlog.h`): each commit line is now separated by a 200ms `nanosleep()` to avoid triggering IRC server flood protection on multi-commit responses. +- Added 150ms inter-chunk delay in AI response delivery (`ai.h`): multi-chunk AI answers now have a 150ms pause between chunks to pace outgoing traffic. +- Added `AI_COOLDOWN_SECS = 5` constant: after an AI query completes, a 5-second cooldown prevents immediate re-submission, reducing unnecessary load. Added `last_ai_completion` timestamp tracked in `ai.h` and checked in `ai_ask()`. +- Added rate limiting to casual chat and greeting responses (`cmd_greeting_or_chat.h`): the `rate_limit_check()` call now gates hardcoded greeting matches (hi, hey, hello, etc.) in addition to AI-forwarded messages. +- Limited `tell_deliver()` to `TELL_DELIVER_MAX = 5` messages per nick per delivery: excess pending messages remain in the database for the next time the user speaks, preventing a single user from triggering a flood of delivery messages. +- Updated all 19 command header files to pass `current_userhost` to the updated `rate_limit_check()` signature. + 2026.07.25 - Welcome message for new users, channel tracking docs. (0.41.2) - Added a welcome message when users join a channel: `handle_join()` now sends `"Welcome, !"` to the channel for non-bot users. The bot's own joins are silently ignored to avoid echo loops. diff --git a/CMakeLists.txt b/CMakeLists.txt index 253debb..12a3543 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.13) -project(zynk VERSION 0.41.2 LANGUAGES C) +project(zynk VERSION 0.42.0 LANGUAGES C) # Prefer C99; the code is compatible with C99/C11 set(CMAKE_C_STANDARD 99)