diff --git a/MareSynchronosServer/MareSynchronosShared/Extensions.cs b/MareSynchronosServer/MareSynchronosShared/Extensions.cs index 8e2665a..5d39bcd 100644 --- a/MareSynchronosServer/MareSynchronosShared/Extensions.cs +++ b/MareSynchronosServer/MareSynchronosShared/Extensions.cs @@ -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();