Skip to content

Loading…

flood protection timeout configurable, another socket message to ignore for self signed certificates #54

Closed
wants to merge 2 commits into from

4 participants

@erikzaadi

fixed self signed certificate problem, made floodProtection timeout configurable and put some more safeties around when joining an empty channel

erikzaadi added some commits
@erikzaadi erikzaadi fixed self signed certificate problem, made floodProtection timeout c…
…onfigurable and put some more safeties around when joining an empty channel
2f4a8f4
@erikzaadi erikzaadi fixed scope 988ba99
@fent

Nice. I was just about to do the configurable timeout on flood protection. Well, I wanted to rewrite most of the activateFloodProtection function because it uses a set interval to check if there is a new message to be sent in the queue every so often.

It was mentioned in the first flood protection pull request that this method might make a user's message be delayed by the amount of time the interval is set to. Node.js is also meant to be fully evented. It would be better to check if a message has been sent in the last timeout, if so, add to a message queue, if not, send the message and call setTimeout to call a function that looks at the queue and sends the oldest message queue'd.

@martynsmith
Owner

Having a quick read through your patch there looks to be three things in there.

Two of them I believe are resolved with other pull requests, and so this doesn't cleanly merge anymore.

Are you able to re-do the pull request with just the flood protection timeout (and ideally a patch to the documentation too) then I can merge it :-)

@erikzaadi

Sounds good, will do..

@lewinski

I just attached a separate/documented version of the flood protection portions of this original pull request. Please let me know if anything needs rewording.

@martynsmith
Owner

Hmmm, that looks good, I just need to work out how to merge it (since it's not its own pull request).

If I get around to it I'll sort it out, otherwise if you get a chance perhaps you could make a pull request with that commit in it?

@martynsmith
Owner

This pull request has too many different things on it. The commit referenced by lewinski looks good, I'll pull that separately when I organise myself (or if he could make a new pull request even better) :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 3, 2011
  1. @erikzaadi

    fixed self signed certificate problem, made floodProtection timeout c…

    erikzaadi committed
    …onfigurable and put some more safeties around when joining an empty channel
  2. @erikzaadi

    fixed scope

    erikzaadi committed
This page is out of date. Refresh to see the latest.
Showing with 21 additions and 12 deletions.
  1. +21 −12 lib/irc.js
View
33 lib/irc.js
@@ -46,6 +46,7 @@ function Client(server, nick, opt) {
secure: false,
selfSigned: false,
floodProtection: false,
+ floodProtectionTimeout: 1000,
stripColors: false
};
@@ -59,7 +60,7 @@ function Client(server, nick, opt) {
}
if (self.opt.floodProtection) {
- self.activateFloodProtection();
+ self.activateFloodProtection(self.opt.floodProtectionTimeout);
}
// TODO - fail if nick or server missing
@@ -200,18 +201,20 @@ function Client(server, nick, opt) {
if ( channel ) {
users.forEach(function (user) {
var match = user.match(/^(.)(.*)$/);
- if ( match[1] in self.modeForPrefix ) {
- channel.users[match[2]] = match[1];
- }
- else {
- channel.users[match[1] + match[2]] = '';
+ if (channel && channel.users){
+ if ( match[1] in self.modeForPrefix ) {
+ channel.users[match[2]] = match[1];
+ }
+ else {
+ channel.users[match[1] + match[2]] = '';
+ }
}
});
}
break;
case "rpl_endofnames":
var channel = self.chanData(message.args[1]);
- if ( channel ) {
+ if ( channel && channel.users) {
self.emit('names', message.args[1], channel.users);
self.send('MODE', message.args[1]);
}
@@ -464,9 +467,15 @@ Client.prototype.connect = function ( retryCount, callback ) { // {{{
// callback called only after successful socket connection
self.conn.connected = true;
if (self.conn.authorized ||
- (self.opt.selfSigned &&
- self.conn.authorizationError === 'DEPTH_ZERO_SELF_SIGNED_CERT')) {
- // authorization successful
+ (self.opt.selfSigned &&
+ (
+ self.conn.authorizationError === 'DEPTH_ZERO_SELF_SIGNED_CERT'
+ ||
+ self.conn.authorizationError === 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
+ )
+ )
+ ) {
+ // authorization successful
self.conn.setEncoding('utf-8');
if ( self.opt.password !== null ) {
@@ -572,10 +581,10 @@ Client.prototype.send = function(command) { // {{{
this.conn.write(command + " " + args.join(" ") + "\r\n");
}
}; // }}}
-Client.prototype.activateFloodProtection = function() { // {{{
+Client.prototype.activateFloodProtection = function(interval) { // {{{
var cmdQueue = [],
- safeInterval = 1000,
+ safeInterval = interval || 1000,
self = this,
origSend = this.send,
dequeue;
Something went wrong with that request. Please try again.