Skip to content

Commit

Permalink
added multiple tests for IP headers (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
reed-tom authored Sep 11, 2023
1 parent 6272fd1 commit bf9532a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion routes/public/stats/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ module.exports = (baseRoute, middleWare, router) => {
*/
try {
if (!common.isHostAllowed(req, res)) return;
console.log("HEADERS" + JSON.stringify(req.headers), "remoteAddress" + req.connection.remoteAddress, "remotePort" + req.connection.remotePort, "localAddress" + req.connection.localAddress);
// IP FROM PROXY
const ip = req.headers["proxy-ip"] === undefined ? "LOCAL_DEBUGGING" : req.headers["proxy-ip"];
let ip = req.headers["x-real-ip"];
if (ip === undefined) ip = req.headers["proxy-ip"];
if (ip === undefined) ip = req.headers["x-forwarded-for"];
if (ip === undefined) ip = req.connection.remoteAddress;
if (ip === "::1") ip = "LOCAL_DEBUGGING";

// INSERT APP STAT
appStats.insertAppStat(req.params.appName, req.params.actionType, req.params.description, ip);
Expand Down

0 comments on commit bf9532a

Please sign in to comment.