More GeoIP debugging

This commit is contained in:
Rick Falkvinge
2015-05-21 16:22:53 +02:00
parent 4d1a403da5
commit 7f3720c8ca
2 changed files with 21 additions and 1 deletions
+20
View File
@@ -36,6 +36,7 @@ namespace Swarmops.Logic.Support
return result.ToString();
}
// ReSharper disable once InconsistentNaming -- IPAddress is the canonical writing
public static string GetRemoteIPAddressChain()
{
string forwardedIps =
@@ -54,5 +55,24 @@ namespace Swarmops.Logic.Support
return result;
}
// ReSharper disable once InconsistentNaming -- IPAddress is the canonical writing
public static string GetMostLikelyRemoteIPAddress()
{
// All of this can be faked trivially by the client, so you can't rely on it for any kind of security.
string forwardedIps =
HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
string directIp =
HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
if (!string.IsNullOrEmpty (forwardedIps))
{
return forwardedIps.Split (',').Last();
}
return directIp;
}
}
}
+1 -1
View File
@@ -296,7 +296,7 @@ namespace Swarmops.Frontend.Pages.Public
try
{
string ipAddress = HttpContext.Current.Request.UserHostAddress;
string ipAddress = Logic.Support.SupportFunctions.GetMostLikelyRemoteIPAddress();
NGeoIP.Request request = new Request()
{