Large number of files

This commit is contained in:
Jim Cartlidge
2020-09-12 16:41:37 +01:00
parent 6bf0acb854
commit 9ef79d190b
43 changed files with 1977 additions and 1345 deletions

View File

@@ -1,9 +1,11 @@
using System.Linq;
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
{
@@ -38,36 +40,35 @@ namespace Jellyfin.Server.Middleware
return;
}
var remoteIp = httpContext.GetNormalizedRemoteIp();
var remoteIp = httpContext.Connection.RemoteIpAddress;
if (serverConfigurationManager.Configuration.EnableRemoteAccess)
{
var addressFilter = serverConfigurationManager.Configuration.RemoteIPFilter.Where(i => !string.IsNullOrWhiteSpace(i)).ToArray();
// Comma separated list of IP addresses or IP/netmask entries for networks that will be allowed to connect remotely.
// If left blank, all remote addresses will be allowed.
NetCollection remoteAddressFilter = networkManager.RemoteAddressFilter;
if (addressFilter.Length > 0 && !networkManager.IsInLocalNetwork(remoteIp))
if (remoteAddressFilter.Count > 0 && !networkManager.IsInLocalNetwork(remoteIp))
{
if (serverConfigurationManager.Configuration.IsRemoteIPFilterBlacklist)
// remoteAddressFilter is a whitelist or blacklist.
bool isListed = remoteAddressFilter.Contains(remoteIp);
if (!serverConfigurationManager.Configuration.IsRemoteIPFilterBlacklist)
{
if (networkManager.IsAddressInSubnets(remoteIp, addressFilter))
{
return;
}
// Black list, so flip over.
isListed = !isListed;
}
else
if (!isListed)
{
if (!networkManager.IsAddressInSubnets(remoteIp, addressFilter))
{
return;
}
// If your name isn't on the list, you arn't coming in.
return;
}
}
}
else
else if (!networkManager.IsInLocalNetwork(remoteIp))
{
if (!networkManager.IsInLocalNetwork(remoteIp))
{
return;
}
// Remote not enabled. So everyone should be LAN.
return;
}
await _next(httpContext).ConfigureAwait(false);