From 87e783da8c09cf836b792282d125fa811a72d06e Mon Sep 17 00:00:00 2001 From: Nick Silkey Date: Thu, 15 Jun 2017 20:29:28 -0500 Subject: [PATCH] Fix CAP match for some IRC daemons 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 --- lib/irc.js | 11 ++++++++--- package.json | 3 ++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/irc.js b/lib/irc.js index 23ccfe08..2e326f8a 100644 --- a/lib/irc.js +++ b/lib/irc.js @@ -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': diff --git a/package.json b/package.json index f70dcdbe..fee6faf8 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "Chris Nehren ", "Henri Niemeläinen ", "Alex Miles ", - "Simmo Saan " + "Simmo Saan ", + "Nick Silkey " ], "repository": { "type": "git",