Fixed testing units.

This commit is contained in:
Jim Cartlidge 2020-09-12 17:21:03 +01:00
parent 9ef79d190b
commit 288d89493e
2 changed files with 6 additions and 2 deletions

View File

@ -34,8 +34,9 @@ namespace Jellyfin.Server.Middleware
/// <returns>The async task.</returns> /// <returns>The async task.</returns>
public async Task Invoke(HttpContext httpContext, INetworkManager networkManager, IServerConfigurationManager serverConfigurationManager) 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); await _next(httpContext).ConfigureAwait(false);
return; return;
} }

View File

@ -1,10 +1,13 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using Jellyfin.Networking.Manager; using Jellyfin.Networking.Manager;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net; using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using NetworkCollection;
namespace Jellyfin.Server.Middleware namespace Jellyfin.Server.Middleware
{ {
@ -33,7 +36,7 @@ namespace Jellyfin.Server.Middleware
/// <returns>The async task.</returns> /// <returns>The async task.</returns>
public async Task Invoke(HttpContext httpContext, INetworkManager networkManager, IServerConfigurationManager serverConfigurationManager) 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) if (!networkManager.IsInLocalNetwork(host) && !serverConfigurationManager.Configuration.EnableRemoteAccess)
{ {