adjust extensions, again and again
This commit is contained in:
@@ -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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user