mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-13 13:04:16 +01:00
adjust extensions, again and again
This commit is contained in:
parent
03d7549d29
commit
3490c5c8d8
1 changed files with 24 additions and 16 deletions
|
|
@ -4,7 +4,10 @@ namespace MareSynchronosShared;
|
|||
|
||||
public static class Extensions
|
||||
{
|
||||
private static long _noIpCntr = 0;
|
||||
public static string GetIpAddress(this IHttpContextAccessor accessor)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(accessor.HttpContext.Request.Headers["CF-CONNECTING-IP"]))
|
||||
return accessor.HttpContext.Request.Headers["CF-CONNECTING-IP"];
|
||||
|
|
@ -26,6 +29,11 @@ public static class Extensions
|
|||
}
|
||||
}
|
||||
|
||||
return accessor.HttpContext.Connection.RemoteIpAddress.ToString();
|
||||
return accessor.HttpContext.Connection.RemoteIpAddress?.ToString() ?? "NoIp";
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "NoIp" + _noIpCntr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue