IRCd reconnection only when registered for 10+ secs
authorDarren <darren@darrenwhitlen.com>
Sat, 26 Jul 2014 23:59:37 +0000 (00:59 +0100)
committerDarren <darren@darrenwhitlen.com>
Sat, 26 Jul 2014 23:59:37 +0000 (00:59 +0100)
Some networks may /kill a user after connected with a custom banning system, causing an ever lasting reconnection loop

server/irc/commands/registration.js
server/irc/connection.js
server/irc/server.js

index a19d87ad52da5ac193f47182d863ab21a2e7fda9..4b58c4030abfa0e31e2a381f9034c423622da471 100644 (file)
@@ -10,7 +10,6 @@ module.exports = function AddCommandHandlers(command_controller) {
 var handlers = {
        RPL_WELCOME: function (command) {
         var nick =  command.params[0];
-        this.irc_connection.registered = true;
         this.cap_negotiation = false;
         this.emit('server ' + this.irc_connection.irc_host.hostname + ' connect', {
             nick: nick
index 97cf2728240f4946ae8a88671839cb28463b73d4..8b8e197fe66e4a78aa5dee0a3f8c36572612a549 100644 (file)
@@ -52,9 +52,6 @@ var IrcConnection = function (hostname, port, ssl, nick, user, options, state, c
     // Max number of lines to write a second
     this.write_buffer_lines_second = 2;
 
-    // If registeration with the IRCd has completed
-    this.registered = false;
-
     // If we are in the CAP negotiation stage
     this.cap_negotiation = true;
 
@@ -300,7 +297,7 @@ IrcConnection.prototype.connect = function () {
         that.socket.on('close', function socketCloseCb(had_error) {
             // If that.connected is false, we never actually managed to connect
             var was_connected = that.connected,
-                had_registered = that.server.registered,
+                safely_registered = (new Date()) - that.server.registered > 10000, // Safely = registered + 10secs after.
                 should_reconnect = false;
 
             that.connected = false;
@@ -316,7 +313,7 @@ IrcConnection.prototype.connect = function () {
                 should_reconnect = true;
 
             // If this was an unplanned disconnect and we were originally connected OK, reconnect
-            } else if (!that.requested_disconnect  && was_connected && had_registered) {
+            } else if (!that.requested_disconnect  && was_connected && safely_registered) {
                 should_reconnect = true;
 
             } else {
index 2dec7899c413e291779163c14e252aab8cc11611..831e9bf58fb179de4dc51dfae63aeba27ac50422 100755 (executable)
@@ -8,6 +8,7 @@ var IrcServer = function (irc_connection) {
     this.list_buffer = [];
     this.motd_buffer = '';
 
+    // Date when registeration with the IRCd had completed
     this.registered = false;
 
     this.irc_events = {
@@ -60,7 +61,7 @@ IrcServer.prototype.reset = function() {
 
 
 function onConnect(event) {
-    this.registered = true;
+    this.registered = new Date();
 
     this.irc_connection.clientEvent('connect', {
         nick: event.nick