From 5a5e86fdc0c50f32f04138a3d59220ffba05ed19 Mon Sep 17 00:00:00 2001 From: Ruben Bisharyan Date: Tue, 1 Oct 2024 11:30:24 +0400 Subject: [PATCH] Add Cloudflare "CF-Connecting-IP" header --- .../Helpers/HttpContextParser.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Pandatech.ModularMonolith.SharedKernel/Helpers/HttpContextParser.cs b/src/Pandatech.ModularMonolith.SharedKernel/Helpers/HttpContextParser.cs index 1a1cfe6..0801055 100644 --- a/src/Pandatech.ModularMonolith.SharedKernel/Helpers/HttpContextParser.cs +++ b/src/Pandatech.ModularMonolith.SharedKernel/Helpers/HttpContextParser.cs @@ -89,7 +89,8 @@ public static string TryParseUserAgent(this HttpContext httpContext) "X-Forwarded-Host", "X-Forwarded-Proto", "X-Forwarded-Server", - "X-Forwarded-Port" + "X-Forwarded-Port", + "CF-Connecting-IP" }; var stringBuilder = new StringBuilder(); @@ -166,7 +167,7 @@ public static decimal TryParseAccuracy(this HttpContext httpContext) public static string TryParseUserNetworkAddress(this HttpContext httpContext) { - string[] headersToCheck = ["X-Forwarded-For", "Forwarded", "X-Real-IP"]; + string[] headersToCheck = ["CF-Connecting-IP", "X-Forwarded-For", "Forwarded", "X-Real-IP"]; foreach (var header in headersToCheck) {