mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-26 02:27:06 +01:00
@@ -9,7 +9,7 @@ using MediaBrowser.Model.Tasks;
|
||||
|
||||
namespace Emby.Server.Implementations.Channels
|
||||
{
|
||||
class RefreshChannelsScheduledTask : IScheduledTask
|
||||
class RefreshChannelsScheduledTask : IScheduledTask, IConfigurableScheduledTask
|
||||
{
|
||||
private readonly IChannelManager _channelManager;
|
||||
private readonly IUserManager _userManager;
|
||||
@@ -39,6 +39,21 @@ namespace Emby.Server.Implementations.Channels
|
||||
get { return "Internet Channels"; }
|
||||
}
|
||||
|
||||
public bool IsHidden
|
||||
{
|
||||
get { return ((ChannelManager)_channelManager).Channels.Length == 0; }
|
||||
}
|
||||
|
||||
public bool IsEnabled
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public bool IsLogged
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public async Task Execute(System.Threading.CancellationToken cancellationToken, IProgress<double> progress)
|
||||
{
|
||||
var manager = (ChannelManager)_channelManager;
|
||||
@@ -65,15 +80,5 @@ namespace Emby.Server.Implementations.Channels
|
||||
{
|
||||
get { return "RefreshInternetChannels"; }
|
||||
}
|
||||
|
||||
public bool IsHidden
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public bool IsEnabled
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,18 +124,6 @@ namespace Emby.Server.Implementations.HttpClientManager
|
||||
}
|
||||
}
|
||||
|
||||
private void AddIpv4Option(HttpWebRequest request, HttpRequestOptions options)
|
||||
{
|
||||
request.ServicePoint.BindIPEndPointDelegate = (servicePount, remoteEndPoint, retryCount) =>
|
||||
{
|
||||
if (remoteEndPoint.AddressFamily == AddressFamily.InterNetwork)
|
||||
{
|
||||
return new IPEndPoint(IPAddress.Any, 0);
|
||||
}
|
||||
throw new InvalidOperationException("no IPv4 address");
|
||||
};
|
||||
}
|
||||
|
||||
private WebRequest GetRequest(HttpRequestOptions options, string method)
|
||||
{
|
||||
var url = options.Url;
|
||||
@@ -153,11 +141,6 @@ namespace Emby.Server.Implementations.HttpClientManager
|
||||
|
||||
if (httpWebRequest != null)
|
||||
{
|
||||
if (options.PreferIpv4)
|
||||
{
|
||||
AddIpv4Option(httpWebRequest, options);
|
||||
}
|
||||
|
||||
AddRequestHeaders(httpWebRequest, options);
|
||||
|
||||
if (options.EnableHttpCompression)
|
||||
|
||||
@@ -506,7 +506,7 @@ namespace Emby.Server.Implementations.Library
|
||||
throw new ArgumentNullException("type");
|
||||
}
|
||||
|
||||
if (ConfigurationManager.Configuration.EnableLocalizedGuids && key.StartsWith(ConfigurationManager.ApplicationPaths.ProgramDataPath))
|
||||
if (key.StartsWith(ConfigurationManager.ApplicationPaths.ProgramDataPath))
|
||||
{
|
||||
// Try to normalize paths located underneath program-data in an attempt to make them more portable
|
||||
key = key.Substring(ConfigurationManager.ApplicationPaths.ProgramDataPath.Length)
|
||||
|
||||
@@ -653,6 +653,14 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||
// Schedules direct requires that the client support compression and will return a 400 response without it
|
||||
options.EnableHttpCompression = true;
|
||||
|
||||
// On windows 7 under .net core, this header is not getting added
|
||||
#if NETSTANDARD2_0
|
||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||
{
|
||||
options.RequestHeaders["Accept-Encoding"] = "deflate";
|
||||
}
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
return await _httpClient.Post(options).ConfigureAwait(false);
|
||||
@@ -684,6 +692,14 @@ namespace Emby.Server.Implementations.LiveTv.Listings
|
||||
// Schedules direct requires that the client support compression and will return a 400 response without it
|
||||
options.EnableHttpCompression = true;
|
||||
|
||||
// On windows 7 under .net core, this header is not getting added
|
||||
#if NETSTANDARD2_0
|
||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||
{
|
||||
options.RequestHeaders["Accept-Encoding"] = "deflate";
|
||||
}
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
return await _httpClient.SendAsync(options, "GET").ConfigureAwait(false);
|
||||
|
||||
@@ -103,7 +103,10 @@ namespace Emby.Server.Implementations.Networking
|
||||
}
|
||||
|
||||
return endpoint.StartsWith("localhost", StringComparison.OrdinalIgnoreCase) ||
|
||||
endpoint.StartsWith("127.0.0.1", StringComparison.OrdinalIgnoreCase) ||
|
||||
endpoint.StartsWith("127.", StringComparison.OrdinalIgnoreCase) ||
|
||||
endpoint.StartsWith("192.168", StringComparison.OrdinalIgnoreCase) ||
|
||||
endpoint.StartsWith("169.", StringComparison.OrdinalIgnoreCase) ||
|
||||
endpoint.StartsWith("10.", StringComparison.OrdinalIgnoreCase) ||
|
||||
IsInPrivateAddressSpaceAndLocalSubnet(endpoint);
|
||||
}
|
||||
|
||||
@@ -111,46 +114,42 @@ namespace Emby.Server.Implementations.Networking
|
||||
{
|
||||
var endpointFirstPart = endpoint.Split('.')[0];
|
||||
|
||||
string subnet_Match = "";
|
||||
if (
|
||||
endpoint.StartsWith("127.", StringComparison.OrdinalIgnoreCase) ||
|
||||
endpoint.StartsWith("10.", StringComparison.OrdinalIgnoreCase) ||
|
||||
endpoint.StartsWith("192.168", StringComparison.OrdinalIgnoreCase) ||
|
||||
endpoint.StartsWith("169.", StringComparison.OrdinalIgnoreCase)
|
||||
)
|
||||
if (endpoint.StartsWith("10.", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
foreach (NetworkInterface adapter in NetworkInterface.GetAllNetworkInterfaces())
|
||||
foreach (UnicastIPAddressInformation unicastIPAddressInformation in adapter.GetIPProperties().UnicastAddresses)
|
||||
if (unicastIPAddressInformation.Address.AddressFamily == AddressFamily.InterNetwork && endpointFirstPart == unicastIPAddressInformation.Address.ToString().Split('.')[0])
|
||||
{
|
||||
int subnet_Test = 0;
|
||||
foreach (string part in unicastIPAddressInformation.IPv4Mask.ToString().Split('.'))
|
||||
{
|
||||
if (part.Equals("0")) break;
|
||||
subnet_Test++;
|
||||
}
|
||||
var subnets = GetSubnets(endpointFirstPart);
|
||||
|
||||
subnet_Match = String.Join(".", unicastIPAddressInformation.Address.ToString().Split('.').Take(subnet_Test).ToArray());
|
||||
}
|
||||
foreach (var subnet_Match in subnets)
|
||||
{
|
||||
//Logger.Debug("subnet_Match:" + subnet_Match);
|
||||
|
||||
if (endpoint.StartsWith(subnet_Match + ".", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return endpoint.StartsWith(subnet_Match + ".", StringComparison.OrdinalIgnoreCase);
|
||||
return false;
|
||||
}
|
||||
|
||||
private Dictionary<string, string> _subnetLookup = new Dictionary<string, string>(StringComparer.Ordinal);
|
||||
private string GetSubnet(string endpointFirstPart)
|
||||
private Dictionary<string, List<string>> _subnetLookup = new Dictionary<string, List<string>>(StringComparer.Ordinal);
|
||||
private List<string> GetSubnets(string endpointFirstPart)
|
||||
{
|
||||
string subnet_Match = "";
|
||||
List<string> subnets;
|
||||
|
||||
lock (_subnetLookup)
|
||||
{
|
||||
if (_subnetLookup.TryGetValue(endpointFirstPart, out subnet_Match))
|
||||
if (_subnetLookup.TryGetValue(endpointFirstPart, out subnets))
|
||||
{
|
||||
return subnet_Match;
|
||||
return subnets;
|
||||
}
|
||||
|
||||
subnets = new List<string>();
|
||||
|
||||
foreach (NetworkInterface adapter in NetworkInterface.GetAllNetworkInterfaces())
|
||||
{
|
||||
foreach (UnicastIPAddressInformation unicastIPAddressInformation in adapter.GetIPProperties().UnicastAddresses)
|
||||
{
|
||||
if (unicastIPAddressInformation.Address.AddressFamily == AddressFamily.InterNetwork && endpointFirstPart == unicastIPAddressInformation.Address.ToString().Split('.')[0])
|
||||
{
|
||||
int subnet_Test = 0;
|
||||
@@ -160,16 +159,21 @@ namespace Emby.Server.Implementations.Networking
|
||||
subnet_Test++;
|
||||
}
|
||||
|
||||
subnet_Match = String.Join(".", unicastIPAddressInformation.Address.ToString().Split('.').Take(subnet_Test).ToArray());
|
||||
var subnet_Match = String.Join(".", unicastIPAddressInformation.Address.ToString().Split('.').Take(subnet_Test).ToArray());
|
||||
|
||||
// TODO: Is this check necessary?
|
||||
if (adapter.OperationalStatus == OperationalStatus.Up)
|
||||
{
|
||||
subnets.Add(subnet_Match);
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(subnet_Match))
|
||||
{
|
||||
_subnetLookup[endpointFirstPart] = subnet_Match;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return subnet_Match;
|
||||
_subnetLookup[endpointFirstPart] = subnets;
|
||||
|
||||
return subnets;
|
||||
}
|
||||
}
|
||||
|
||||
private bool Is172AddressPrivate(string endpoint)
|
||||
|
||||
Reference in New Issue
Block a user