Batch autojoin channels into comma-separated JOIN commands#283
Open
kofany wants to merge 1 commit intoaatxe:developfrom
Open
Batch autojoin channels into comma-separated JOIN commands#283kofany wants to merge 1 commit intoaatxe:developfrom
kofany wants to merge 1 commit intoaatxe:developfrom
Conversation
Instead of sending individual JOIN per channel on connect, batch channels into comma-separated JOIN commands (RFC 2812 §3.2.1). Keyed channels are placed first in each batch so positional key matching works correctly. Commands are split into multiple JOINs when they would exceed the 512-byte IRC line length limit. This reduces the number of messages sent during autojoin, which matters especially with flood protection enabled — 20 individual JOINs would incur ~34s of penalty delay vs ~2s for a single batched JOIN.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When connecting to a server with multiple autojoin channels configured, the client sends individual
JOINcommands for each channel:For a typical configuration with 20 channels, this generates 20 separate messages. With any form of server-side or client-side flood protection, this introduces significant delay — each
JOINcarries a penalty (~2s per command on most IRCd implementations following RFC 2813 §5.8), resulting in ~34 seconds to complete autojoin for 20 channels.Solution
Batch autojoin channels into comma-separated
JOINcommands per RFC 2812 §3.2.1:Key design decisions
Keyed channels placed first — RFC 2812 specifies positional key matching (
JOIN #a,#b,#c key1,key2mapskey1→#a,key2→#b,#chas no key). Channels with keys must precede keyless channels within each batch to maintain correct alignment.Respects 512-byte IRC line limit — The batching algorithm splits into multiple
JOINcommands when adding another channel would exceed 512 bytes (includingJOIN, commas, the space-separated keylist, and\r\n). This is the only real constraint — RFC 2812 does not impose a limit on the number of channels perJOIN.Preserves config order within groups — Keyed and keyless channels each maintain their original configuration order.
Re-joined channels also batched — Previously joined channels (tracked in
chanlists) that aren't in the config are also batched when re-joining after reconnect.Example
Config with channels
[#public, #secret, #general]where#secrethas keymypass:Before:
JOIN #public\r\n+JOIN #secret mypass\r\n+JOIN #general\r\n(3 messages)After:
JOIN #secret,#public,#general mypass\r\n(1 message)Testing
build_batched_joins:cargo test --no-default-features✓cargo clippy --all-targets --all-features— no new warningscargo fmt --check✓git diff --check— no whitespace issues