IRC server rejects custom quit message: solution
I was working on my IRC bot recently when I stumbled upon a confusing problem while trying to add a graceful shutdown. The idea is that when a process receives a request to terminate itself (SIGTERM), it should send a QUIT command with some text, rather than disappearing like some barbarian.
Like this:
<= QUIT :bye
=> :poring-dev!~poring@user/poring QUIT :Quit: bye
Alas, the IRC server completely ignored my message, replacing it with a generic "Client Quit" text:
<= QUIT :bye
=> :poring-dev!~poring@user/poring QUIT :Client Quit
I spent about two hours trying different things and debugging my code to no avail. I knew the command I was sending was valid and that Libera Chat supported this feature.
What I didn't know is that there's apparently a type of spam attack that utilizes quit messages. I imagine that, instead of sending the same text to n channels separately, which can trigger anti-flood protections IRC servers had for decades, one can simply join n channels and then quit the network with a message like: "GET FREE SSD TO STORE YOUR NODE_MODULES HERE: HTTPS://WWW.FAKEPLASTICTREES.EE" - achieving more or less the same result.
When I was running and shutting down the bot in my IDE, the whole process took about 30 seconds. Solanum IRCd - an IRCv3 server used by Libera Chat - can be, and apparently is, configured to block custom quit messages unless the user was connected for a specified amount of minutes.
All this time, my code was working flawlessly! I just needed to stay connected for a little longer.