From 5be8bd16315d6d143fcfe701d7027566f0f95a0e Mon Sep 17 00:00:00 2001 From: Jabo Date: Fri, 1 Apr 2016 12:35:46 +0200 Subject: [PATCH] logging of ip adress added logging option to record the requesting machine's ip adress --- config.js | 3 +++ server.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/config.js b/config.js index e331f64..12518ac 100644 --- a/config.js +++ b/config.js @@ -4,6 +4,9 @@ var path = require('path'), module.exports = { // Logging config loggingOpts: { + + // show the ip address of the machine requesting the npm package + logRequesterIP: true, // Print to stdout with colors logToConsole: true, // Write to file diff --git a/server.js b/server.js index c982ed2..a5a7c0e 100644 --- a/server.js +++ b/server.js @@ -67,6 +67,9 @@ function start(config) { var server = http.createServer(); server.on('request', function(req, res) { + if (config.loggingOpts.logRequesterIP) { + log.info("Request from ip: "+req.connection.remoteAddress+ " for "+req.url); + } if (!api.route(req, res)) { log.error('No route found', req.url); Package.proxy(req, res);