mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-12 18:47:23 +01:00
adjust ip address extensions again
This commit is contained in:
parent
42694a872f
commit
03d7549d29
1 changed files with 6 additions and 3 deletions
|
|
@ -16,11 +16,14 @@ public static class Extensions
|
|||
|
||||
var ipAddress = accessor.HttpContext.GetServerVariable("HTTP_X_FORWARDED_FOR");
|
||||
|
||||
if (!string.IsNullOrEmpty(ipAddress))
|
||||
if (!string.IsNullOrWhiteSpace(ipAddress))
|
||||
{
|
||||
var addresses = ipAddress.Split(',', StringSplitOptions.RemoveEmptyEntries);
|
||||
if (addresses.Length != 0)
|
||||
return addresses.Last();
|
||||
var lastEntry = addresses.LastOrDefault();
|
||||
if (lastEntry != null)
|
||||
{
|
||||
return lastEntry;
|
||||
}
|
||||
}
|
||||
|
||||
return accessor.HttpContext.Connection.RemoteIpAddress.ToString();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue