From ee89696c4dc59f94774fd100885dfca24775094e Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Sun, 10 Feb 2013 16:03:49 +0100 Subject: [PATCH] Log the client ip on pad access with logger 'access' also, don't log every message with log level info! --- src/node/handler/PadMessageHandler.js | 9 +++++++++ src/node/handler/SocketIORouter.js | 5 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index 19ebfe92e..5c19a56c9 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -32,6 +32,7 @@ var securityManager = require("../db/SecurityManager"); var plugins = require("ep_etherpad-lite/static/js/pluginfw/plugins.js"); var log4js = require('log4js'); var messageLogger = log4js.getLogger("message"); +var accessLogger = log4js.getLogger("access"); var _ = require('underscore'); var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks.js"); @@ -121,6 +122,10 @@ exports.handleDisconnect = function(client) }); } + client.get('remoteAddress', function(er, ip) { + accessLogger.info('[LEAVE] Author "'+session.author+'" on client '+client.id+' with IP "'+ip+'" left pad "'+session.padId+'"') + }) + //Delete the sessioninfos entrys of this session delete sessioninfos[client.id]; } @@ -910,6 +915,10 @@ function handleClientReady(client, message) sessioninfos[client.id].readOnlyPadId = padIds.readOnlyPadId; sessioninfos[client.id].readonly = padIds.readonly; + client.get('remoteAddress', function(er, ip) { + accessLogger.info('[ENTER] Client '+client.id+' with IP "'+ip+'" entered pad "'+padIds.padId+'"') + }) + //If this is a reconnect, we don't have to send the client the ClientVars again if(message.reconnect == true) { diff --git a/src/node/handler/SocketIORouter.js b/src/node/handler/SocketIORouter.js index f3b82b8c7..483bb1d17 100644 --- a/src/node/handler/SocketIORouter.js +++ b/src/node/handler/SocketIORouter.js @@ -55,13 +55,14 @@ exports.setSocketIO = function(_socket) socket.sockets.on('connection', function(client) { + client.set('remoteAddress', client.handshake.address.address); var clientAuthorized = false; //wrap the original send function to log the messages client._send = client.send; client.send = function(message) { - messageLogger.info("to " + client.id + ": " + stringifyWithoutPassword(message)); + messageLogger.debug("to " + client.id + ": " + stringifyWithoutPassword(message)); client._send(message); } @@ -79,7 +80,7 @@ exports.setSocketIO = function(_socket) //check if component is registered in the components array if(components[message.component]) { - messageLogger.info("from " + client.id + ": " + stringifyWithoutPassword(message)); + messageLogger.debug("from " + client.id + ": " + stringifyWithoutPassword(message)); components[message.component].handleMessage(client, message); } }