Server: extra entropy for clients hash. Logging IRC connection issues
authorDarren <darren@darrenwhitlen.com>
Mon, 29 Oct 2012 20:48:55 +0000 (20:48 +0000)
committerDarren <darren@darrenwhitlen.com>
Mon, 29 Oct 2012 20:48:55 +0000 (20:48 +0000)
server/client.js
server/irc/connection.js

index 666384cb521e6079f72f8396a24f77d2432690c5..bec0412122dbbdd64955909850aa9bab6e5e0764 100755 (executable)
@@ -18,7 +18,11 @@ var Client = function (websocket) {
     this.real_address = this.websocket.handshake.real_address;
 
     // A hash to identify this client instance
-    this.hash = crypto.createHash('sha256').update(this.real_address).update('' + Date.now()).digest('hex');
+    this.hash = crypto.createHash('sha256')
+        .update(this.real_address)
+        .update('' + Date.now())
+        .update(Math.floor(Math.random() * 100000).toString())
+        .digest('hex');
     
     this.irc_connections = [];
     this.next_connection = 0;
@@ -120,11 +124,11 @@ function kiwiCommand(command, callback) {
                                irc_commands.bindEvents();
                                
                                con.on('connected', function () {
-                    console.log("con.on('connected')");
                                        return callback(null, con_num);
                                });
                                
                                con.on('error', function (err) {
+                    console.log('irc_connection error (' + command.hostname + '):', err);
                     // TODO: Once multiple servers implemented, specify which server failed
                     //that.sendKiwiCommand('error', {server: con_num, error: err});
                     return callback(err.code, null);
index 9e069deb65bcfaf21cbece37420d7b923557222a..1a1d8562bfba61608c189503013a5497a2fc7e3b 100644 (file)
@@ -54,7 +54,6 @@ IrcConnection.prototype.write = function (data, callback) {
 };
 
 IrcConnection.prototype.end = function (data, callback) {
-    console.log('Closing IRC socket');
     end.call(this, data + '\r\n', 'utf-8', callback);
 };
 
@@ -103,7 +102,6 @@ var connect_handler = function () {
     this.write('USER ' + connect_data.username + ' 0 0 :' + connect_data.realname);
     
     this.connected = true;
-    console.log("IrcConnection.emit('connected')");
     this.emit('connected');
 };