print CF-Connecting-IP/X-Forwarded-For when present in socket.io requests

This commit is contained in:
Nick Krecklow
2020-04-01 21:54:43 -05:00
parent 1382a6a21e
commit 7e4e0390f1
3 changed files with 8 additions and 8 deletions

View File

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