Revert "Fix usercounter behind cloudflare"

This reverts commit 9bcceb7e5b.
This commit is contained in:
Ajay
2024-02-27 03:49:03 -05:00
parent f1c5b8a359
commit a54bf556ed
2 changed files with 3 additions and 6 deletions

View File

@@ -2,7 +2,7 @@ import { config } from "../config";
import { Request } from "express";
import { IPAddress } from "../types/segments.model";
export function getIP(req: Request, checkCloudflare = false): IPAddress {
export function getIP(req: Request): IPAddress {
// if in testing mode, return immediately
if (config.mode === "test") return "127.0.0.1" as IPAddress;
@@ -10,14 +10,11 @@ export function getIP(req: Request, checkCloudflare = false): IPAddress {
config.behindProxy = "X-Forwarded-For";
}
const cloudflareIP = req.headers["cf-connecting-ip"] as IPAddress;
if (checkCloudflare && cloudflareIP) return cloudflareIP;
switch (config.behindProxy as string) {
case "X-Forwarded-For":
return req.headers["x-forwarded-for"] as IPAddress;
case "Cloudflare":
return cloudflareIP;
return req.headers["cf-connecting-ip"] as IPAddress;
case "X-Real-IP":
return req.headers["x-real-ip"] as IPAddress;
default: