degesch: fixing the registration process

Note that the parent project has since been renamed, including its binaries.

Degesch was initially put together from source code of the ZyklonB IRC bot, which in turn was mostly just a C rewrite of my VitaminA IRC bot, written in GNU AWK and dating all the way back to year 2010 or so.

As such, there are still many ugly areas in the code, be it because of different requirements being put on IRC bots, or because of my general inexperience at the time of writing them.

One of them was the registration process. To fill you in on what happens when you try to connect to an IRC server:

The bots were working under the assumption that nothing happens on the connection between the point where we send the USER/NICK pair and the point where we know we’ve registered.

That is, however, not generally the case, as we may e.g. automatically try another nickname if the one written in configuration is rejected. In addition to that, in the case of a client, the user may also issue commands at this point if the connection attempt gets stuck here to resolve the issue manually.

The detection of successful registration was also a bit screwed up, as we were waiting for any of RPL_ENDOFMOTD, ERR_NOMOTD, or MODE instead of just looking for RPL_WELCOME. Most of the time it’s completely unnecessary and achieves exactly nothing.

The only time this makes any sense is when you need any information from the messages in between (that is, 002 through 004 which are always present, or RPL_ISUPPORT) in order to do any post-connection steps.

Today I’ve fixed the code to assign ourselves a nickname only in reaction to the welcome message, and made sure nothing bad happens when it’s unassigned. The client also no longer crashes on reconnection.

Comments

Use e-mail, webchat, or the form below. I'll also pick up on new HN, Lobsters, and Reddit posts.