print CF-Connecting-IP/X-Forwarded-For when present in socket.io requests
This commit is contained in:
@ -27,12 +27,7 @@ function setupRoutes() {
|
||||
function handleRequest(req, res) {
|
||||
var requestUrl = url.parse(req.url).pathname;
|
||||
|
||||
let remoteAddress = req.connection.remoteAddress;
|
||||
if (req.headers && (req.headers['cf-connecting-ip'] || req.headers['x-forwarded-for'])) {
|
||||
remoteAddress = req.headers['cf-connecting-ip'] || req.headers['x-forwarded-for'];
|
||||
}
|
||||
|
||||
logger.log('info', '%s requested: %s', remoteAddress, requestUrl);
|
||||
logger.log('info', '%s requested: %s', util.getRemoteAddr(req), requestUrl);
|
||||
|
||||
if (requestUrl === '/publicConfig.json') {
|
||||
res.setHeader('Content-Type', 'application/javascript');
|
||||
|
@ -174,3 +174,8 @@ exports.unfurlSRV = function(hostname, port, callback) {
|
||||
callback(records[0].name, records[0].port);
|
||||
})
|
||||
};
|
||||
|
||||
exports.getRemoteAddr = function(req) {
|
||||
let remoteAddress = req.headers['cf-connecting-ip'] || req.headers['x-forwarded-for'] || req.connection.remoteAddress;
|
||||
return remoteAddress;
|
||||
};
|
Reference in New Issue
Block a user