From 40464a6fddf3b522c57a72e16bd036fbe8ac4580 Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Tue, 15 Sep 2020 13:47:01 +0100 Subject: [PATCH 1/2] Update LanFilteringMiddleware.cs --- .../Middleware/LanFilteringMiddleware.cs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/Jellyfin.Server/Middleware/LanFilteringMiddleware.cs b/Jellyfin.Server/Middleware/LanFilteringMiddleware.cs index 7963d0d8c6..a1d21f39e6 100644 --- a/Jellyfin.Server/Middleware/LanFilteringMiddleware.cs +++ b/Jellyfin.Server/Middleware/LanFilteringMiddleware.cs @@ -43,18 +43,6 @@ namespace Jellyfin.Server.Middleware } await _next(httpContext).ConfigureAwait(false); - } - - private static string NormalizeConfiguredLocalAddress(string address) - { - var add = address.AsSpan().Trim('/'); - int index = add.IndexOf('/'); - if (index != -1) - { - add = add.Slice(index + 1); - } - - return add.TrimStart('/').ToString(); - } + } } } From 96c3c4af4237c1fd1955fe5840904015ae592bef Mon Sep 17 00:00:00 2001 From: BaronGreenback Date: Tue, 15 Sep 2020 13:48:40 +0100 Subject: [PATCH 2/2] Update IpBasedAccessValidationMiddleware.cs --- .../Middleware/IpBasedAccessValidationMiddleware.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jellyfin.Server/Middleware/IpBasedAccessValidationMiddleware.cs b/Jellyfin.Server/Middleware/IpBasedAccessValidationMiddleware.cs index 7f6b6bcce9..0713d97d65 100644 --- a/Jellyfin.Server/Middleware/IpBasedAccessValidationMiddleware.cs +++ b/Jellyfin.Server/Middleware/IpBasedAccessValidationMiddleware.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Net; using System.Threading.Tasks; using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Net; @@ -33,14 +33,14 @@ namespace Jellyfin.Server.Middleware /// The async task. public async Task Invoke(HttpContext httpContext, INetworkManager networkManager, IServerConfigurationManager serverConfigurationManager) { - if (httpContext.Connection.RemoteIpAddress == null) + if (httpContext.IsLocal()) { // Running locally. await _next(httpContext).ConfigureAwait(false); return; } - var remoteIp = httpContext.Connection.RemoteIpAddress; + var remoteIp = httpContext.Connection.RemoteIpAddress ?? IPAddress.Loopback; if (serverConfigurationManager.Configuration.EnableRemoteAccess) {