embolalia/willie — pull request #692 by Khabi (2014-12-19 02:34:13+00:00)
Title: Core: Delay 'CAP LS' until after USER to fix authentication issues under...

... rare cicumstances

On some servers it seems that issuing CAP before NICK and USER can cause the connection to fail. I suspect it has something to do with a timeout while trying to ident, but can replicate this on multiple servers.

Example from a failed attempt via telnet.

Trying 2610:150:4b0f::...
Connected to chat.freenode.net.
Escape character is '^]'.
:morgan.freenode.net NOTICE * :*** Looking up your hostname...
:morgan.freenode.net NOTICE * :*** Checking Ident
:morgan.freenode.net NOTICE * :*** Couldn't look up your hostname
CAP LS
NICK atestuser
USER willie +iw willie :willie
:morgan.freenode.net NOTICE * :*** No Ident response
:morgan.freenode.net CAP * LS :account-notify extended-join identify-msg multi-prefix sasl
ERROR :Closing Link: 2607:f4e8:120:10:44f5:dc8b:7e80:1b47 (Connection timed out)
Connection closed by foreign host.

Example after moving CAP LS to after Authentication:
Trying 2610:150:4b0f::...
Connected to chat.freenode.net.
Escape character is '^]'.
:morgan.freenode.net NOTICE * :*** Looking up your hostname...
:morgan.freenode.net NOTICE * :*** Checking Ident
:morgan.freenode.net NOTICE * :*** Couldn't look up your hostname
NICK atestuser
USER willie +iw willie :willie
CAP LS
:morgan.freenode.net NOTICE * :*** No Ident response
:morgan.freenode.net 001 atestuser :Welcome to the freenode Internet Relay Chat Network atestuser
[snip]
:morgan.freenode.net 376 atestuser :End of /MOTD command.
:atestuser MODE atestuser :+i
:morgan.freenode.net CAP atestuser LS :account-notify extended-join identify-msg multi-prefix sas