mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-11 22:17:14 +03:00
17 lines
484 B
JavaScript
17 lines
484 B
JavaScript
var config = require('../config.js');
|
|
|
|
module.exports = function getIP(req) {
|
|
if (config.behindProxy === true || 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;
|
|
}
|
|
}
|