working handling of setting client ip and anonymizing etc

This commit is contained in:
John McLear 2014-11-04 23:25:18 +00:00
parent f418dfa205
commit 9fa77cdea2
4 changed files with 24 additions and 15 deletions

View file

@ -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;