From a67e805da0f356cb584aa338c7c448d1969eb577 Mon Sep 17 00:00:00 2001 From: John McLear Date: Sat, 1 Nov 2014 21:25:49 +0000 Subject: [PATCH 01/15] basics, still not working --- src/node/hooks/express/socketio.js | 2 ++ src/package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/node/hooks/express/socketio.js b/src/node/hooks/express/socketio.js index 524bab3d9..39b325808 100644 --- a/src/node/hooks/express/socketio.js +++ b/src/node/hooks/express/socketio.js @@ -42,6 +42,7 @@ exports.expressCreateServer = function (hook_name, args, cb) { io.set('transports', settings.socketTransportProtocols ); var socketIOLogger = log4js.getLogger("socket.io"); + /* io.set('logger', { debug: function (str) { @@ -60,6 +61,7 @@ exports.expressCreateServer = function (hook_name, args, cb) { socketIOLogger.error.apply(socketIOLogger, arguments); }, }); + */ //minify socket.io javascript if(settings.minify) diff --git a/src/package.json b/src/package.json index 652aebaf8..1adbe8917 100644 --- a/src/package.json +++ b/src/package.json @@ -15,7 +15,7 @@ "request" : "2.9.100", "require-kernel" : "1.0.5", "resolve" : ">=1.0.0", - "socket.io" : "0.9.x", + "socket.io" : ">=1.2.0", "ueberDB" : ">=0.2.6", "express" : "3.1.0", "async" : "0.1.x", From 2c801cc558bd358d1de6a0cdfcd3de8201739f7b Mon Sep 17 00:00:00 2001 From: John McLear Date: Sat, 1 Nov 2014 22:36:19 +0000 Subject: [PATCH 02/15] no errors but no connections --- src/node/hooks/express/socketio.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/node/hooks/express/socketio.js b/src/node/hooks/express/socketio.js index 39b325808..17ce3864a 100644 --- a/src/node/hooks/express/socketio.js +++ b/src/node/hooks/express/socketio.js @@ -16,6 +16,7 @@ exports.expressCreateServer = function (hook_name, args, cb) { /* Require an express session cookie to be present, and load the * session. See http://www.danielbaulig.de/socket-ioexpress for more * info */ + /* io.set('authorization', function (data, accept) { if (!data.headers.cookie) return accept('No session cookie transmitted.', false); @@ -35,11 +36,12 @@ exports.expressCreateServer = function (hook_name, args, cb) { }); }); }); + */ // there shouldn't be a browser that isn't compatible to all // transports in this list at once // e.g. XHR is disabled in IE by default, so in IE it should use jsonp-polling - io.set('transports', settings.socketTransportProtocols ); + // io.set('transports', settings.socketTransportProtocols ); var socketIOLogger = log4js.getLogger("socket.io"); /* @@ -65,7 +67,7 @@ exports.expressCreateServer = function (hook_name, args, cb) { //minify socket.io javascript if(settings.minify) - io.enable('browser client minification'); + // io.enable('browser client minification'); //Initalize the Socket.IO Router socketIORouter.setSocketIO(io); From 1e53c4f5f0440b00a30037793783f862f3cced7d Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 4 Nov 2014 17:57:18 +0000 Subject: [PATCH 03/15] identify which parts are causing issues and comment them out, obviously this needs fixing --- src/node/handler/PadMessageHandler.js | 8 +++++++- src/node/handler/SocketIORouter.js | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index e1ac994e8..c81c9d17b 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -1015,6 +1015,7 @@ function handleClientReady(client, message) return callback(); //Check if this author is already on the pad, if yes, kick the other sessions! +/* var roomClients = socketio.sockets.clients(padIds.padId); for(var i = 0; i < roomClients.length; i++) { var sinfo = sessioninfos[roomClients[i].id]; @@ -1025,6 +1026,7 @@ function handleClientReady(client, message) roomClients[i].json.send({disconnect:"userdup"}); } } +*/ //Save in sessioninfos that this session belonges to this pad sessioninfos[client.id].padId = padIds.padId; @@ -1032,6 +1034,7 @@ function handleClientReady(client, message) sessioninfos[client.id].readonly = padIds.readonly; //Log creation/(re-)entering of a pad +/* client.get('remoteAddress', function(er, ip) { //Anonymize the IP address if IP logging is disabled if(settings.disableIPlogging) { @@ -1045,6 +1048,7 @@ function handleClientReady(client, message) accessLogger.info('[CREATE] Pad "'+padIds.padId+'": Client '+client.id+' with IP "'+ip+'" created the pad'); } }) +*/ //If this is a reconnect, we don't have to send the client the ClientVars again if(message.reconnect == true) @@ -1100,7 +1104,7 @@ function handleClientReady(client, message) // tell the client the number of the latest chat-message, which will be // used to request the latest 100 chat-messages later (GET_CHAT_MESSAGES) "chatHead": pad.chatHead, - "numConnectedUsers": roomClients.length, + "numConnectedUsers": 0, "readOnlyId": padIds.readOnlyPadId, "readonly": padIds.readonly, "serverTimestamp": new Date().getTime(), @@ -1165,6 +1169,7 @@ function handleClientReady(client, message) client.broadcast.to(padIds.padId).json.send(messageToTheOtherUsers); //Run trough all sessions of this pad +/* async.forEach(socketio.sockets.clients(padIds.padId), function(roomClient, callback) { var author; @@ -1211,6 +1216,7 @@ function handleClientReady(client, message) } ], callback); }, callback); +*/ } ],function(err) { diff --git a/src/node/handler/SocketIORouter.js b/src/node/handler/SocketIORouter.js index b3e046d2c..96260254d 100644 --- a/src/node/handler/SocketIORouter.js +++ b/src/node/handler/SocketIORouter.js @@ -56,11 +56,13 @@ exports.setSocketIO = function(_socket) { socket.sockets.on('connection', function(client) { + +// Broken: See http://stackoverflow.com/questions/4647348/send-message-to-specific-client-with-socket-io-and-node-js if(settings.trustProxy && client.handshake.headers['x-forwarded-for'] !== undefined){ - client.set('remoteAddress', client.handshake.headers['x-forwarded-for']); +// client.set('remoteAddress', client.handshake.headers['x-forwarded-for']); } else{ - client.set('remoteAddress', client.handshake.address.address); +// client.set('remoteAddress', client.handshake.address); } var clientAuthorized = false; From adef0af227a765b8d2ddfece29449bf6b4053313 Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 4 Nov 2014 18:01:41 +0000 Subject: [PATCH 04/15] more stuff required to stop it crashing, now we have identified what needs fixing we can fix it --- src/node/handler/PadMessageHandler.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index c81c9d17b..da2a7a144 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -115,6 +115,7 @@ exports.handleDisconnect = function(client) //if this connection was already etablished with a handshake, send a disconnect message to the others if(session && session.author) { + /* client.get('remoteAddress', function(er, ip) { //Anonymize the IP address if IP logging is disabled if(settings.disableIPlogging) { @@ -123,6 +124,7 @@ exports.handleDisconnect = function(client) accessLogger.info('[LEAVE] Pad "'+session.padId+'": Author "'+session.author+'" on client '+client.id+' with IP "'+ip+'" left the pad') }) + */ //get the author color out of the db authorManager.getAuthorColorId(session.author, function(err, color) @@ -752,6 +754,7 @@ function handleUserChanges(data, cb) exports.updatePadClients = function(pad, callback) { + /* //skip this step if noone is on this pad var roomClients = socketio.sockets.clients(pad.id); if(roomClients.length==0) @@ -827,6 +830,7 @@ exports.updatePadClients = function(pad, callback) callback ); },callback); + */ } /** From 5d0ccb5f8f7b029ed71b0cd5bc668a3fe088a96f Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 4 Nov 2014 18:17:39 +0000 Subject: [PATCH 05/15] auth fix --- src/node/hooks/express/socketio.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/node/hooks/express/socketio.js b/src/node/hooks/express/socketio.js index 17ce3864a..32c5fd889 100644 --- a/src/node/hooks/express/socketio.js +++ b/src/node/hooks/express/socketio.js @@ -16,8 +16,9 @@ exports.expressCreateServer = function (hook_name, args, cb) { /* Require an express session cookie to be present, and load the * session. See http://www.danielbaulig.de/socket-ioexpress for more * info */ - /* - io.set('authorization', function (data, accept) { + + io.use(function(socket, accept) { + var data = socket.request; if (!data.headers.cookie) return accept('No session cookie transmitted.', false); // Use connect's cookie parser, because it knows how to parse signed cookies @@ -36,7 +37,6 @@ exports.expressCreateServer = function (hook_name, args, cb) { }); }); }); - */ // there shouldn't be a browser that isn't compatible to all // transports in this list at once From cb28d109631e7bd5357fcd754b60fd89e820e7e6 Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 4 Nov 2014 18:32:26 +0000 Subject: [PATCH 06/15] move logging into debug environment variable .. sighs --- src/node/utils/Settings.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/node/utils/Settings.js b/src/node/utils/Settings.js index c455617b0..1f22ccfd7 100644 --- a/src/node/utils/Settings.js +++ b/src/node/utils/Settings.js @@ -228,6 +228,7 @@ exports.reloadSettings = function reloadSettings() { log4js.configure(exports.logconfig);//Configure the logging appenders log4js.setGlobalLogLevel(exports.loglevel);//set loglevel + process.env['DEBUG'] = 'socket.io:' + exports.loglevel; // Used by SocketIO for Debug log4js.replaceConsole(); if(!exports.sessionKey){ // If the secretKey isn't set we also create yet another unique value here From 95e7b0f15609fc850b71717a672abd02237a0f33 Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 4 Nov 2014 19:11:06 +0000 Subject: [PATCH 07/15] transports --- src/node/hooks/express/socketio.js | 39 +++++++++--------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/src/node/hooks/express/socketio.js b/src/node/hooks/express/socketio.js index 32c5fd889..98146bbbb 100644 --- a/src/node/hooks/express/socketio.js +++ b/src/node/hooks/express/socketio.js @@ -1,10 +1,17 @@ var log4js = require('log4js'); -var socketio = require('socket.io'); var settings = require('../../utils/Settings'); var socketIORouter = require("../../handler/SocketIORouter"); var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks"); var webaccess = require("ep_etherpad-lite/node/hooks/express/webaccess"); +// there shouldn't be a browser that isn't compatible to all +// transports in this list at once +// e.g. XHR is disabled in IE by default, so in IE it should use jsonp-polling + +var socketio = require('socket.io')({ + transports: settings.socketTransportProtocols +}); + var padMessageHandler = require("../../handler/PadMessageHandler"); var connect = require('connect'); @@ -38,32 +45,10 @@ exports.expressCreateServer = function (hook_name, args, cb) { }); }); - // there shouldn't be a browser that isn't compatible to all - // transports in this list at once - // e.g. XHR is disabled in IE by default, so in IE it should use jsonp-polling - // io.set('transports', settings.socketTransportProtocols ); - - var socketIOLogger = log4js.getLogger("socket.io"); - /* - io.set('logger', { - debug: function (str) - { - socketIOLogger.debug.apply(socketIOLogger, arguments); - }, - info: function (str) - { - socketIOLogger.info.apply(socketIOLogger, arguments); - }, - warn: function (str) - { - socketIOLogger.warn.apply(socketIOLogger, arguments); - }, - error: function (str) - { - socketIOLogger.error.apply(socketIOLogger, arguments); - }, - }); - */ + // var socketIOLogger = log4js.getLogger("socket.io"); + // Debug logging now has to be set at an environment level, this is stupid. + // https://github.com/Automattic/socket.io/wiki/Migrating-to-1.0 + // This debug logging environment is set in Settings.js //minify socket.io javascript if(settings.minify) From 68eaa09708241b0551f5d345f45d8f7ba00913d2 Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 4 Nov 2014 19:55:05 +0000 Subject: [PATCH 08/15] Begin to repair damage done to rooms logic --- src/node/handler/PadMessageHandler.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index da2a7a144..2072a784b 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -754,9 +754,14 @@ function handleUserChanges(data, cb) exports.updatePadClients = function(pad, callback) { - /* //skip this step if noone is on this pad - var roomClients = socketio.sockets.clients(pad.id); + var roomClients = [], room = socketio.sockets.adapter.rooms[pad.id]; + if (room) { + for (var id in room) { + roomClients.push(socketio.sockets.adapter.nsp.connected[id]); + } + } + if(roomClients.length==0) return callback(); @@ -769,10 +774,8 @@ exports.updatePadClients = function(pad, callback) var revCache = {}; //go trough all sessions on this pad - async.forEach(roomClients, function(client, callback) - { + async.forEach(roomClients, function(client, callback){ var sid = client.id; - //https://github.com/caolan/async#whilst //send them all new changesets async.whilst( @@ -802,7 +805,8 @@ exports.updatePadClients = function(pad, callback) if(author == sessioninfos[sid].author) { - client.json.send({"type":"COLLABROOM","data":{type:"ACCEPT_COMMIT", newRev:r}}); + // client.json.send({"type":"COLLABROOM","data":{type:"ACCEPT_COMMIT", newRev:r}}); + socketio.in(pad).send({"type":"COLLABROOM","data":{type:"ACCEPT_COMMIT", newRev:r}}); } else { @@ -817,7 +821,9 @@ exports.updatePadClients = function(pad, callback) timeDelta: currentTime - sessioninfos[sid].time }}; - client.json.send(wireMsg); + // client.json.send(wireMsg); + socketio.in(pad).send({"type":"COLLABROOM","data":{type:"ACCEPT_COMMIT", newRev:r}}); + } sessioninfos[sid].time = currentTime; @@ -830,7 +836,6 @@ exports.updatePadClients = function(pad, callback) callback ); },callback); - */ } /** From a6cbb4af409b5448e2b27d4f28234efd8c0e3c17 Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 4 Nov 2014 19:58:38 +0000 Subject: [PATCH 09/15] working messages --- src/node/handler/PadMessageHandler.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index 2072a784b..0dc18d7e0 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -805,8 +805,7 @@ exports.updatePadClients = function(pad, callback) if(author == sessioninfos[sid].author) { - // client.json.send({"type":"COLLABROOM","data":{type:"ACCEPT_COMMIT", newRev:r}}); - socketio.in(pad).send({"type":"COLLABROOM","data":{type:"ACCEPT_COMMIT", newRev:r}}); + client.json.send({"type":"COLLABROOM","data":{type:"ACCEPT_COMMIT", newRev:r}}); } else { @@ -821,9 +820,7 @@ exports.updatePadClients = function(pad, callback) timeDelta: currentTime - sessioninfos[sid].time }}; - // client.json.send(wireMsg); - socketio.in(pad).send({"type":"COLLABROOM","data":{type:"ACCEPT_COMMIT", newRev:r}}); - + client.json.send(wireMsg); } sessioninfos[sid].time = currentTime; From 8391f902fbda5f687bb9efd3152352ddcdc11a81 Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 4 Nov 2014 22:31:09 +0000 Subject: [PATCH 10/15] re-apply roomsize --- src/node/handler/PadMessageHandler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index 0dc18d7e0..af83dfac4 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -1110,7 +1110,7 @@ function handleClientReady(client, message) // tell the client the number of the latest chat-message, which will be // used to request the latest 100 chat-messages later (GET_CHAT_MESSAGES) "chatHead": pad.chatHead, - "numConnectedUsers": 0, + "numConnectedUsers": roomClients.length, "readOnlyId": padIds.readOnlyPadId, "readonly": padIds.readonly, "serverTimestamp": new Date().getTime(), From af3e8e5e15b66ccae2306ba6b956d8acd8143eed Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 4 Nov 2014 22:34:43 +0000 Subject: [PATCH 11/15] fix room client leave --- src/node/handler/PadMessageHandler.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index af83dfac4..8657460c5 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -1021,8 +1021,13 @@ function handleClientReady(client, message) return callback(); //Check if this author is already on the pad, if yes, kick the other sessions! -/* - var roomClients = socketio.sockets.clients(padIds.padId); + var roomClients = [], room = socketio.sockets.adapter.rooms[pad.id]; + if (room) { + for (var id in room) { + roomClients.push(socketio.sockets.adapter.nsp.connected[id]); + } + } + for(var i = 0; i < roomClients.length; i++) { var sinfo = sessioninfos[roomClients[i].id]; if(sinfo && sinfo.author == author) { @@ -1032,7 +1037,6 @@ function handleClientReady(client, message) roomClients[i].json.send({disconnect:"userdup"}); } } -*/ //Save in sessioninfos that this session belonges to this pad sessioninfos[client.id].padId = padIds.padId; From f418dfa2053c4b40bd46d586b960a2de8167388c Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 4 Nov 2014 22:37:10 +0000 Subject: [PATCH 12/15] fix author notification handler --- src/node/handler/PadMessageHandler.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index 8657460c5..3c39c4d86 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -1179,8 +1179,14 @@ function handleClientReady(client, message) client.broadcast.to(padIds.padId).json.send(messageToTheOtherUsers); //Run trough all sessions of this pad -/* - async.forEach(socketio.sockets.clients(padIds.padId), function(roomClient, callback) + var roomClients = [], room = socketio.sockets.adapter.rooms[pad.id]; + if (room) { + for (var id in room) { + roomClients.push(socketio.sockets.adapter.nsp.connected[id]); + } + } + + async.forEach(roomClients, function(roomClient, callback) { var author; @@ -1226,7 +1232,6 @@ function handleClientReady(client, message) } ], callback); }, callback); -*/ } ],function(err) { From 9fa77cdea251b5e32a351298bbe97a88abec3e56 Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 4 Nov 2014 23:25:18 +0000 Subject: [PATCH 13/15] working handling of setting client ip and anonymizing etc --- src/node/handler/PadMessageHandler.js | 21 ++++++++++++--------- src/node/handler/SocketIORouter.js | 9 ++++++--- src/node/hooks/express/socketio.js | 8 +++++--- src/node/utils/RemoteAddress.js | 1 + 4 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 src/node/utils/RemoteAddress.js diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index 3c39c4d86..b4e6243f0 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -37,6 +37,7 @@ var _ = require('underscore'); var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks.js"); var channels = require("channels"); var stats = require('../stats'); +var remoteAddress = require("../utils/RemoteAddress").remoteAddress; /** * A associative array that saves informations about a session @@ -115,16 +116,18 @@ exports.handleDisconnect = function(client) //if this connection was already etablished with a handshake, send a disconnect message to the others if(session && session.author) { - /* - client.get('remoteAddress', function(er, ip) { - //Anonymize the IP address if IP logging is disabled - if(settings.disableIPlogging) { - ip = 'ANONYMOUS'; - } - accessLogger.info('[LEAVE] Pad "'+session.padId+'": Author "'+session.author+'" on client '+client.id+' with IP "'+ip+'" left the pad') - }) - */ +console.log(remoteAddress); + + // Get the IP address from our persistant object + var ip = remoteAddress[client.id]; + + // Anonymize the IP address if IP logging is disabled + if(settings.disableIPlogging) { + ip = 'ANONYMOUS'; + } + + accessLogger.info('[LEAVE] Pad "'+session.padId+'": Author "'+session.author+'" on client '+client.id+' with IP "'+ip+'" left the pad') //get the author color out of the db authorManager.getAuthorColorId(session.author, function(err, color) diff --git a/src/node/handler/SocketIORouter.js b/src/node/handler/SocketIORouter.js index 96260254d..0a7361f42 100644 --- a/src/node/handler/SocketIORouter.js +++ b/src/node/handler/SocketIORouter.js @@ -24,6 +24,7 @@ var log4js = require('log4js'); var messageLogger = log4js.getLogger("message"); var securityManager = require("../db/SecurityManager"); var readOnlyManager = require("../db/ReadOnlyManager"); +var remoteAddress = require("../utils/RemoteAddress").remoteAddress; var settings = require('../utils/Settings'); /** @@ -57,12 +58,14 @@ exports.setSocketIO = function(_socket) { socket.sockets.on('connection', function(client) { -// Broken: See http://stackoverflow.com/questions/4647348/send-message-to-specific-client-with-socket-io-and-node-js + // Broken: See http://stackoverflow.com/questions/4647348/send-message-to-specific-client-with-socket-io-and-node-js + // Fixed by having a persistant object, ideally this would actually be in the database layer + // TODO move to database layer if(settings.trustProxy && client.handshake.headers['x-forwarded-for'] !== undefined){ -// client.set('remoteAddress', client.handshake.headers['x-forwarded-for']); + remoteAddress[client.id] = client.handshake.headers['x-forwarded-for']; } else{ -// client.set('remoteAddress', client.handshake.address); + remoteAddress[client.id] = client.handshake.address; } var clientAuthorized = false; diff --git a/src/node/hooks/express/socketio.js b/src/node/hooks/express/socketio.js index 98146bbbb..e88a3f4c0 100644 --- a/src/node/hooks/express/socketio.js +++ b/src/node/hooks/express/socketio.js @@ -51,9 +51,11 @@ exports.expressCreateServer = function (hook_name, args, cb) { // This debug logging environment is set in Settings.js //minify socket.io javascript - if(settings.minify) - // io.enable('browser client minification'); - + // Due to a shitty decision by the SocketIO team minification is + // no longer available, details available at: + // http://stackoverflow.com/questions/23981741/minify-socket-io-socket-io-js-with-1-0 + // if(settings.minify) io.enable('browser client minification'); + //Initalize the Socket.IO Router socketIORouter.setSocketIO(io); socketIORouter.addComponent("pad", padMessageHandler); diff --git a/src/node/utils/RemoteAddress.js b/src/node/utils/RemoteAddress.js new file mode 100644 index 000000000..86a4a5b26 --- /dev/null +++ b/src/node/utils/RemoteAddress.js @@ -0,0 +1 @@ +exports.remoteAddress = {}; From 053ff3097d097ad89337740a0209c50f4726399d Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 4 Nov 2014 23:29:45 +0000 Subject: [PATCH 14/15] whoops I missed this one --- src/node/handler/PadMessageHandler.js | 28 ++++++++++++--------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index b4e6243f0..36da4842b 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -117,8 +117,6 @@ exports.handleDisconnect = function(client) if(session && session.author) { -console.log(remoteAddress); - // Get the IP address from our persistant object var ip = remoteAddress[client.id]; @@ -1047,21 +1045,19 @@ function handleClientReady(client, message) sessioninfos[client.id].readonly = padIds.readonly; //Log creation/(re-)entering of a pad -/* - client.get('remoteAddress', function(er, ip) { - //Anonymize the IP address if IP logging is disabled - if(settings.disableIPlogging) { - ip = 'ANONYMOUS'; - } + var ip = remoteAddress[client.id]; - if(pad.head > 0) { - accessLogger.info('[ENTER] Pad "'+padIds.padId+'": Client '+client.id+' with IP "'+ip+'" entered the pad'); - } - else if(pad.head == 0) { - accessLogger.info('[CREATE] Pad "'+padIds.padId+'": Client '+client.id+' with IP "'+ip+'" created the pad'); - } - }) -*/ + //Anonymize the IP address if IP logging is disabled + if(settings.disableIPlogging) { + ip = 'ANONYMOUS'; + } + + if(pad.head > 0) { + accessLogger.info('[ENTER] Pad "'+padIds.padId+'": Client '+client.id+' with IP "'+ip+'" entered the pad'); + } + else if(pad.head == 0) { + accessLogger.info('[CREATE] Pad "'+padIds.padId+'": Client '+client.id+' with IP "'+ip+'" created the pad'); + } //If this is a reconnect, we don't have to send the client the ClientVars again if(message.reconnect == true) From 57f56d8fe11ee28b9f3f2a1e969f86038ca27d34 Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 4 Nov 2014 23:42:40 +0000 Subject: [PATCH 15/15] bump express to a working version --- src/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/package.json b/src/package.json index 1adbe8917..4639abcfe 100644 --- a/src/package.json +++ b/src/package.json @@ -17,7 +17,7 @@ "resolve" : ">=1.0.0", "socket.io" : ">=1.2.0", "ueberDB" : ">=0.2.6", - "express" : "3.1.0", + "express" : ">3.1.0 <3.9.0", "async" : "0.1.x", "connect" : "2.7.x", "clean-css" : "0.3.2",