From 79f507087fedd6cbf418b81dc2b02fa55b165857 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Fri, 12 Jun 2015 20:44:50 +0200 Subject: [PATCH] Bugfix to SupportFuncations.GetMostLikelyRemoteIPAddress() --- Logic/Support/General.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Logic/Support/General.cs b/Logic/Support/General.cs index 4cbbb364..43d64e3b 100644 --- a/Logic/Support/General.cs +++ b/Logic/Support/General.cs @@ -63,6 +63,13 @@ namespace Swarmops.Logic.Support // While it is possible to set up a server environment that strips out such fakes, doing so should not // be a requirement for running Swarmops. + string cloudFlareClient = HttpContext.Current.Request.Headers["CF-Connecting-IP"]; + + if (!string.IsNullOrEmpty (cloudFlareClient)) + { + return cloudFlareClient; + } + string forwardedIps = HttpContext.Current.Request.Headers["X-Forwarded-For"]; @@ -71,7 +78,7 @@ namespace Swarmops.Logic.Support if (!string.IsNullOrEmpty (forwardedIps)) { - return forwardedIps.Split (',').Last(); + return forwardedIps.Split (',').First(); } return directIp;