Files
SponsorBlockServer/src/utils/getIP.js
Ajay Ramachandran 9a317a2c23 Added getIP options
2020-04-30 00:34:34 -04:00

17 lines
474 B
JavaScript

var fs = require('fs');
var config = require('../config.js');
module.exports = function getIP(req) {
if (config.behindProxy === true) config.behindProxy = "X-Forwarded-For";
switch (config.behindProxy) {
case "X-Forwarded-For":
return req.headers['X-Forwarded-For'];
case "Cloudflare":
return req.headers['CF-Connecting-IP'];
case "X-Real-IP":
return req.headers['X-Real-IP'];
default:
return req.connection.remoteAddress;
}
}