From 288d89493e76b8881c719fe549859b2c0b5f7e29 Mon Sep 17 00:00:00 2001 From: Jim Cartlidge Date: Sat, 12 Sep 2020 17:21:03 +0100 Subject: [PATCH] Fixed testing units. --- .../Middleware/IpBasedAccessValidationMiddleware.cs | 3 ++- Jellyfin.Server/Middleware/LanFilteringMiddleware.cs | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Jellyfin.Server/Middleware/IpBasedAccessValidationMiddleware.cs b/Jellyfin.Server/Middleware/IpBasedAccessValidationMiddleware.cs index 110290027b..ff82fe6cc6 100644 --- a/Jellyfin.Server/Middleware/IpBasedAccessValidationMiddleware.cs +++ b/Jellyfin.Server/Middleware/IpBasedAccessValidationMiddleware.cs @@ -34,8 +34,9 @@ namespace Jellyfin.Server.Middleware /// The async task. public async Task Invoke(HttpContext httpContext, INetworkManager networkManager, IServerConfigurationManager serverConfigurationManager) { - if (httpContext.IsLocal()) + if (httpContext.Connection.RemoteIpAddress == null) { + // Running locally. await _next(httpContext).ConfigureAwait(false); return; } diff --git a/Jellyfin.Server/Middleware/LanFilteringMiddleware.cs b/Jellyfin.Server/Middleware/LanFilteringMiddleware.cs index 2ff6f8a765..87c82bf583 100644 --- a/Jellyfin.Server/Middleware/LanFilteringMiddleware.cs +++ b/Jellyfin.Server/Middleware/LanFilteringMiddleware.cs @@ -1,10 +1,13 @@ using System; using System.Linq; +using System.Net; using System.Threading.Tasks; using Jellyfin.Networking.Manager; +using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Configuration; using Microsoft.AspNetCore.Http; +using NetworkCollection; namespace Jellyfin.Server.Middleware { @@ -33,7 +36,7 @@ namespace Jellyfin.Server.Middleware /// The async task. public async Task Invoke(HttpContext httpContext, INetworkManager networkManager, IServerConfigurationManager serverConfigurationManager) { - var host = httpContext.Connection.RemoteIpAddress; + var host = httpContext.Connection.RemoteIpAddress ?? IPAddress.Loopback; if (!networkManager.IsInLocalNetwork(host) && !serverConfigurationManager.Configuration.EnableRemoteAccess) {