Skip to content

Commit

Permalink
Fix CAP match for some IRC daemons
Browse files Browse the repository at this point in the history
Some IRC daemons such as InspIRCd return an random string after a
client's CAP REQ request.  This would fail to match and block SASL
AUTHENTICATEs.  Also the space after sasl would also block the above
AUTHENTICATEs.

This change:

* allows for emitting that output in logs via debug in config
* stops matching on said field which can be an irrelevant moving
target
* removes the trailing space for the mentioned sasl field

Example:

$ openssl s_client -connect irc.corp.com:6697
...
CAP REQ :sasl
:irc.corp.com CAP 354AAUXBK ACK :sasl
^C
$ openssl s_client -connect irc.corp.com:6697
...
CAP REQ :sasl
:irc.corp.com CAP 354AAUXC8 ACK :sasl
  • Loading branch information
Nick Silkey committed Jun 16, 2017
1 parent e4000b7 commit 3873fca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 8 additions & 3 deletions lib/irc.js
Original file line number Diff line number Diff line change
Expand Up @@ -597,9 +597,14 @@ function Client(server, nick, opt) {

// for sasl
case 'CAP':
if (message.args[0] === '*' &&
message.args[1] === 'ACK' &&
message.args[2] === 'sasl ') // there's a space after sasl
// if we are debug, log output from the server
if (self.opt.debug) {
util.log(message.args[0] + '-')
util.log(message.args[1] + '-')
util.log(message.args[2] + '-')
}
if (message.args[1] === 'ACK' &&
message.args[2] === 'sasl')
self.send('AUTHENTICATE', 'PLAIN');
break;
case 'AUTHENTICATE':
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"Chris Nehren <[email protected]>",
"Henri Niemeläinen <[email protected]>",
"Alex Miles <[email protected]>",
"Simmo Saan <[email protected]>"
"Simmo Saan <[email protected]>",
"Nick Silkey <[email protected]>"
],
"repository": {
"type": "git",
Expand Down

0 comments on commit 3873fca

Please sign in to comment.