Skip to content

Add feature: CAPabilities before nickpass #469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions lib/irc.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ function Client(server, nick, opt) {
channelPrefixes: '&#',
messageSplit: 512,
encoding: false,
capIdentifyMsg: false,
webirc: {
pass: '',
ip: '',
host: ''
},
millisecondsOfSilenceBeforePingSent: 15 * 1000,
millisecondsBeforePingTimeout: 8 * 1000
millisecondsBeforePingTimeout: 8 * 1000,
caps: []
};

// Features supported by the server
Expand Down Expand Up @@ -597,10 +599,15 @@ 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
self.send('AUTHENTICATE', 'PLAIN');
if (message.args[1] === 'NAK') {
self.emit('error', 'CAP ERROR for ": ' + self.CAP.join(' ') + '" CAP sent. Response:' + util.inspect(message));
} else if (message.args[1] === 'ACK') {
if (message.args[0] === '*' && message.args[2].indexOf('sasl') !== -1) {
self.send('AUTHENTICATE', 'PLAIN');
} else {
self.emit('cap', message);
}
}
break;
case 'AUTHENTICATE':
if (message.args[0] === '+') self.send('AUTHENTICATE',
Expand Down Expand Up @@ -714,10 +721,23 @@ Client.prototype._connectionHandler = function() {
if (this.opt.webirc.ip && this.opt.webirc.pass && this.opt.webirc.host) {
this.send('WEBIRC', this.opt.webirc.pass, this.opt.userName, this.opt.webirc.host, this.opt.webirc.ip);
}

if (this.opt.capIdentifyMsg) {
this.opt.caps.push('identify-msg');
}
if (this.opt.sasl) {
// see http://ircv3.atheme.org/extensions/sasl-3.1
this.send('CAP REQ', 'sasl');
} else if (this.opt.password) {
this.opt.caps.push('sasl');
}
if (this.opt.caps.length) {
if (this.opt.debug)
util.log('Sending irc CAPS');

this.send('CAP REQ', this.opt.caps.join(' '));
this.send('CAP', 'END');
}

if (this.opt.password) {
this.send('PASS', this.opt.password);
}
if (this.opt.debug)
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
"Chris Nehren <[email protected]>",
"Henri Niemeläinen <[email protected]>",
"Alex Miles <[email protected]>",
"Simmo Saan <[email protected]>"
"Simmo Saan <[email protected]>",
"Dariusz Niemczyk <[email protected]>",
"Barry Carlyon <[email protected]>"
],
"repository": {
"type": "git",
Expand Down