From a0bf87be5260213994270c80c7e6a9b429f99950 Mon Sep 17 00:00:00 2001 From: Darren Date: Thu, 29 Aug 2013 13:56:23 +0100 Subject: [PATCH] Server: Using socket.meta instead of socket.kiwi for meta data --- server/client.js | 4 ++-- server/weblistener.js | 19 ++++++------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/server/client.js b/server/client.js index d2d76f0..e26d405 100755 --- a/server/client.js +++ b/server/client.js @@ -16,7 +16,7 @@ var Client = function (websocket) { this.rpc = new WebsocketRpc(this.websocket); // Clients address - this.real_address = this.websocket.kiwi.real_address; + this.real_address = this.websocket.meta.real_address; // A hash to identify this client instance this.hash = crypto.createHash('sha256') @@ -131,7 +131,7 @@ function kiwiCommand(command, callback) { global.config.restrict_server_ssl : command.ssl), command.nick, - {hostname: this.websocket.kiwi.revdns, address: this.websocket.kiwi.real_address}, + {hostname: this.websocket.meta.revdns, address: this.websocket.meta.real_address}, options, callback); } else { diff --git a/server/weblistener.js b/server/weblistener.js index f3af63d..25d2688 100644 --- a/server/weblistener.js +++ b/server/weblistener.js @@ -27,7 +27,7 @@ var http_handler; var WebListener = module.exports = function (web_config, transports) { - var hs, opts, ws_opts, + var hs, opts, that = this; @@ -35,13 +35,6 @@ var WebListener = module.exports = function (web_config, transports) { http_handler = new HttpHandler(web_config); - // Standard options for the socket.io connections - ws_opts = { - 'log level': 0, - 'log colors': 0 - }; - - if (web_config.ssl) { opts = { key: fs.readFileSync(web_config.ssl_key), @@ -132,7 +125,7 @@ function initialiseSocket(socket, callback) { // Key/val data stored to the socket to be read later on // May also be synced to a redis DB to lookup clients - socket.kiwi = {}; + socket.meta = {}; // If a forwarded-for header is found, switch the source address if (request.headers[global.config.http_proxy_ip_header || 'x-forwarded-for']) { @@ -147,7 +140,7 @@ function initialiseSocket(socket, callback) { address = request.headers[global.config.http_proxy_ip_header || 'x-forwarded-for']; } - socket.kiwi.real_address = address; + socket.meta.real_address = address; // If enabled, don't go over the connection limit if (global.config.max_client_conns && global.config.max_client_conns > 0) { @@ -160,16 +153,16 @@ function initialiseSocket(socket, callback) { try { dns.reverse(address, function (err, domains) { if (err || domains.length === 0) { - socket.kiwi.revdns = address; + socket.meta.revdns = address; } else { - socket.kiwi.revdns = _.first(domains) || address; + socket.meta.revdns = _.first(domains) || address; } // All is well, authorise the connection callback(null, true); }); } catch (err) { - socket.kiwi.revdns = address; + socket.meta.revdns = address; callback(null, true); } } -- 2.25.1