From 95733b2fc7428138bce463316b4297da2f59c433 Mon Sep 17 00:00:00 2001 From: Thomas FORGIONE Date: Thu, 2 Jul 2015 15:33:13 +0200 Subject: [PATCH] Log --- server.js | 8 ++++++-- socket.js | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/server.js b/server.js index 48613ca..83763d6 100644 --- a/server.js +++ b/server.js @@ -35,9 +35,13 @@ app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.json()); app.use(function(req, res, next) { + // Log connection - console.dir(req.headers) - console.log('[REQ] ' + new Date() + ' ' + req.headers['X-Forwarded-For'] + ' : ' + req.url); + console.log( + '[REQ] ' + new Date() + ' ' + + (req.headers['x-forwarded-for'] || req.connection.remoteAddress) + + ' : ' + req.url + ); res.locals.title = "3DUI"; res.locals.urls = urls; diff --git a/socket.js b/socket.js index 8edf303..8a351d7 100644 --- a/socket.js +++ b/socket.js @@ -4,10 +4,10 @@ var geo = require('./lib/geo.min.js'); module.exports = function(io) { io.on('connection', function(socket) { - console.log('[SOK] ' + new Date() + ' ' + socket.conn.remoteAddress + ' connection'); + console.log('[SOK] ' + new Date() + ' ' + socket.handshake.address + ' connection'); socket.on('disconnect', function() { - console.log('[SOK] ' + new Date() + ' ' + socket.conn.remoteAddress + ' disconnect'); + console.log('[SOK] ' + new Date() + ' ' + socket.handshake.address + ' disconnect'); }); var streamer = new geo.MeshStreamer();