Networking: 1 - Network Manager (#4124)
* NetworkManager * Config file with additional options. * Update Jellyfin.Networking/Manager/INetworkManager.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update Jellyfin.Networking/Manager/INetworkManager.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update MediaBrowser.Model/Configuration/ServerConfiguration.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update MediaBrowser.Model/Configuration/ServerConfiguration.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update MediaBrowser.Model/Configuration/ServerConfiguration.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Split function. * Update Jellyfin.Networking/Manager/INetworkManager.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * fixed iterations * Update Jellyfin.Networking.csproj * Update NetworkManager.cs * Updated to NetCollection 1.03. * Update ServerConfiguration.cs * Update StartupController.cs * Update INetworkManager.cs Removed public * Update INetworkManager.cs * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Claus Vium <cvium@users.noreply.github.com> * Updated comment * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Claus Vium <cvium@users.noreply.github.com> * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Claus Vium <cvium@users.noreply.github.com> * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Claus Vium <cvium@users.noreply.github.com> * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Claus Vium <cvium@users.noreply.github.com> * Update Jellyfin.Networking/Manager/INetworkManager.cs Co-authored-by: Claus Vium <cvium@users.noreply.github.com> * Remove mono code. Removed forced chromecast option * Inverted if * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Moved config into a separate container * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Changed sortedList to dictionary. * Update INetworkManager.cs Changed UpdateSettings param type * Update NetworkManager.cs * Update NetworkManager.cs * Update NetworkManager.cs * Update NetworkConfiguration.cs * Update INetworkManager.cs * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Claus Vium <cvium@users.noreply.github.com> * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Claus Vium <cvium@users.noreply.github.com> * Update MediaBrowser.Model/Configuration/ServerConfiguration.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update MediaBrowser.Model/Configuration/ServerConfiguration.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Updated changes github didn't update. * Fixed compilation. * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Removed read locking. * Update NetworkManager.cs Changed configuration event to NamedConfigurationUpdated * updated comment * removed whitespace * Updated NetCollection to 1.0.6 Updated DXCopAnalyser to 3.3.1 * removed NetCollection * Update NetworkManager.cs * Update NetworkExtensions.cs * Update NetworkExtensions.cs Removed function. * Update NetworkExtensions.cs * Update NetworkManager.cs Changed ToString() to AsString() as native collection formats incorrectly. * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update NetworkExtensions.cs * Update Jellyfin.Networking/Configuration/NetworkConfiguration.cs Co-authored-by: h1dden-da3m0n <33120068+h1dden-da3m0n@users.noreply.github.com> * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: h1dden-da3m0n <33120068+h1dden-da3m0n@users.noreply.github.com> * Update Jellyfin.Networking/Configuration/NetworkConfiguration.cs Co-authored-by: h1dden-da3m0n <33120068+h1dden-da3m0n@users.noreply.github.com> * Update Jellyfin.Networking/Configuration/NetworkConfiguration.cs Co-authored-by: h1dden-da3m0n <33120068+h1dden-da3m0n@users.noreply.github.com> * Update MediaBrowser.Common/Net/IPObject.cs Co-authored-by: h1dden-da3m0n <33120068+h1dden-da3m0n@users.noreply.github.com> * updated * Replaced NetCollection with Collection<IPObject> * Update MediaBrowser.Common/Net/NetworkExtensions.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update MediaBrowser.Model/Configuration/PathSubstitution.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update MediaBrowser.Common/Net/NetworkExtensions.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update MediaBrowser.Common/Net/IPObject.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update MediaBrowser.Common/Net/IPObject.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update MediaBrowser.Common/Net/IPObject.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update MediaBrowser.Common/Net/IPHost.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update MediaBrowser.Common/Net/IPHost.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update MediaBrowser.Common/Net/IPHost.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update MediaBrowser.Common/Net/IPHost.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update MediaBrowser.Common/Net/IPHost.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update MediaBrowser.Common/Net/IPHost.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update MediaBrowser.Common/Net/IPHost.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update MediaBrowser.Common/Net/IPObject.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * Update MediaBrowser.Common/Net/IPObject.cs Co-authored-by: Cody Robibero <cody@robibe.ro> * updated comments. * Updated comments / changes as suggested by @crobibero. * Split function as suggested * Fixed null ref. * Updated comment. * Updated cs to .net5 * Fixed issue with PublishedServerUrl * Fixes * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Claus Vium <cvium@users.noreply.github.com> * Restored locking * optimisation * Added comment * updates. * updated. * updates * updated. * Update IPHost.cs * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Claus Vium <cvium@users.noreply.github.com> * Update NetworkManager.cs * Removed whitespace. * Added debug logging * Added debug. * Update Jellyfin.Networking/Manager/NetworkManager.cs Co-authored-by: Bond-009 <bond.009@outlook.com> * Replaced GetAddressBytes Co-authored-by: Cody Robibero <cody@robibe.ro> Co-authored-by: Claus Vium <cvium@users.noreply.github.com> Co-authored-by: h1dden-da3m0n <33120068+h1dden-da3m0n@users.noreply.github.com> Co-authored-by: Bond-009 <bond.009@outlook.com>
This commit is contained in:
parent
d2cef78db3
commit
124bd4c2c0
|
@ -18,13 +18,12 @@ namespace Emby.Server.Implementations.Networking
|
||||||
public class NetworkManager : INetworkManager
|
public class NetworkManager : INetworkManager
|
||||||
{
|
{
|
||||||
private readonly ILogger<NetworkManager> _logger;
|
private readonly ILogger<NetworkManager> _logger;
|
||||||
|
|
||||||
private IPAddress[] _localIpAddresses;
|
|
||||||
private readonly object _localIpAddressSyncLock = new object();
|
private readonly object _localIpAddressSyncLock = new object();
|
||||||
|
|
||||||
private readonly object _subnetLookupLock = new object();
|
private readonly object _subnetLookupLock = new object();
|
||||||
private readonly Dictionary<string, List<string>> _subnetLookup = new Dictionary<string, List<string>>(StringComparer.Ordinal);
|
private readonly Dictionary<string, List<string>> _subnetLookup = new Dictionary<string, List<string>>(StringComparer.Ordinal);
|
||||||
|
|
||||||
|
private IPAddress[] _localIpAddresses;
|
||||||
|
|
||||||
private List<PhysicalAddress> _macAddresses;
|
private List<PhysicalAddress> _macAddresses;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -157,7 +156,9 @@ namespace Emby.Server.Implementations.Networking
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] octet = ipAddress.GetAddressBytes();
|
// GetAddressBytes
|
||||||
|
Span<byte> octet = stackalloc byte[ipAddress.AddressFamily == AddressFamily.InterNetwork ? 4 : 16];
|
||||||
|
ipAddress.TryWriteBytes(octet, out _);
|
||||||
|
|
||||||
if ((octet[0] == 10) ||
|
if ((octet[0] == 10) ||
|
||||||
(octet[0] == 172 && (octet[1] >= 16 && octet[1] <= 31)) || // RFC1918
|
(octet[0] == 172 && (octet[1] >= 16 && octet[1] <= 31)) || // RFC1918
|
||||||
|
@ -260,7 +261,9 @@ namespace Emby.Server.Implementations.Networking
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public bool IsAddressInSubnets(IPAddress address, bool excludeInterfaces, bool excludeRFC)
|
public bool IsAddressInSubnets(IPAddress address, bool excludeInterfaces, bool excludeRFC)
|
||||||
{
|
{
|
||||||
byte[] octet = address.GetAddressBytes();
|
// GetAddressBytes
|
||||||
|
Span<byte> octet = stackalloc byte[address.AddressFamily == AddressFamily.InterNetwork ? 4 : 16];
|
||||||
|
address.TryWriteBytes(octet, out _);
|
||||||
|
|
||||||
if ((octet[0] == 127) || // RFC1122
|
if ((octet[0] == 127) || // RFC1122
|
||||||
(octet[0] == 169 && octet[1] == 254)) // RFC3927
|
(octet[0] == 169 && octet[1] == 254)) // RFC3927
|
||||||
|
@ -503,18 +506,25 @@ namespace Emby.Server.Implementations.Networking
|
||||||
|
|
||||||
private IPAddress GetNetworkAddress(IPAddress address, IPAddress subnetMask)
|
private IPAddress GetNetworkAddress(IPAddress address, IPAddress subnetMask)
|
||||||
{
|
{
|
||||||
byte[] ipAdressBytes = address.GetAddressBytes();
|
int size = address.AddressFamily == AddressFamily.InterNetwork ? 4 : 16;
|
||||||
byte[] subnetMaskBytes = subnetMask.GetAddressBytes();
|
|
||||||
|
|
||||||
if (ipAdressBytes.Length != subnetMaskBytes.Length)
|
// GetAddressBytes
|
||||||
|
Span<byte> ipAddressBytes = stackalloc byte[size];
|
||||||
|
address.TryWriteBytes(ipAddressBytes, out _);
|
||||||
|
|
||||||
|
// GetAddressBytes
|
||||||
|
Span<byte> subnetMaskBytes = stackalloc byte[size];
|
||||||
|
subnetMask.TryWriteBytes(subnetMaskBytes, out _);
|
||||||
|
|
||||||
|
if (ipAddressBytes.Length != subnetMaskBytes.Length)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Lengths of IP address and subnet mask do not match.");
|
throw new ArgumentException("Lengths of IP address and subnet mask do not match.");
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] broadcastAddress = new byte[ipAdressBytes.Length];
|
byte[] broadcastAddress = new byte[ipAddressBytes.Length];
|
||||||
for (int i = 0; i < broadcastAddress.Length; i++)
|
for (int i = 0; i < broadcastAddress.Length; i++)
|
||||||
{
|
{
|
||||||
broadcastAddress[i] = (byte)(ipAdressBytes[i] & subnetMaskBytes[i]);
|
broadcastAddress[i] = (byte)(ipAddressBytes[i] & subnetMaskBytes[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new IPAddress(broadcastAddress);
|
return new IPAddress(broadcastAddress);
|
||||||
|
|
|
@ -72,9 +72,9 @@ namespace Jellyfin.Api.Controllers
|
||||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
public ActionResult UpdateInitialConfiguration([FromBody, Required] StartupConfigurationDto startupConfiguration)
|
public ActionResult UpdateInitialConfiguration([FromBody, Required] StartupConfigurationDto startupConfiguration)
|
||||||
{
|
{
|
||||||
_config.Configuration.UICulture = startupConfiguration.UICulture;
|
_config.Configuration.UICulture = startupConfiguration.UICulture ?? string.Empty;
|
||||||
_config.Configuration.MetadataCountryCode = startupConfiguration.MetadataCountryCode;
|
_config.Configuration.MetadataCountryCode = startupConfiguration.MetadataCountryCode ?? string.Empty;
|
||||||
_config.Configuration.PreferredMetadataLanguage = startupConfiguration.PreferredMetadataLanguage;
|
_config.Configuration.PreferredMetadataLanguage = startupConfiguration.PreferredMetadataLanguage ?? string.Empty;
|
||||||
_config.SaveConfiguration();
|
_config.SaveConfiguration();
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
221
Jellyfin.Networking/Configuration/NetworkConfiguration.cs
Normal file
221
Jellyfin.Networking/Configuration/NetworkConfiguration.cs
Normal file
|
@ -0,0 +1,221 @@
|
||||||
|
#pragma warning disable CA1819 // Properties should not return arrays
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using MediaBrowser.Model.Configuration;
|
||||||
|
|
||||||
|
namespace Jellyfin.Networking.Configuration
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the <see cref="NetworkConfiguration" />.
|
||||||
|
/// </summary>
|
||||||
|
public class NetworkConfiguration
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The default value for <see cref="HttpServerPortNumber"/>.
|
||||||
|
/// </summary>
|
||||||
|
public const int DefaultHttpPort = 8096;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The default value for <see cref="PublicHttpsPort"/> and <see cref="HttpsPortNumber"/>.
|
||||||
|
/// </summary>
|
||||||
|
public const int DefaultHttpsPort = 8920;
|
||||||
|
|
||||||
|
private string _baseUrl = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether the server should force connections over HTTPS.
|
||||||
|
/// </summary>
|
||||||
|
public bool RequireHttps { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value used to specify the URL prefix that your Jellyfin instance can be accessed at.
|
||||||
|
/// </summary>
|
||||||
|
public string BaseUrl
|
||||||
|
{
|
||||||
|
get => _baseUrl;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
// Normalize the start of the string
|
||||||
|
if (string.IsNullOrWhiteSpace(value))
|
||||||
|
{
|
||||||
|
// If baseUrl is empty, set an empty prefix string
|
||||||
|
_baseUrl = string.Empty;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value[0] != '/')
|
||||||
|
{
|
||||||
|
// If baseUrl was not configured with a leading slash, append one for consistency
|
||||||
|
value = "/" + value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normalize the end of the string
|
||||||
|
if (value[^1] == '/')
|
||||||
|
{
|
||||||
|
// If baseUrl was configured with a trailing slash, remove it for consistency
|
||||||
|
value = value.Remove(value.Length - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
_baseUrl = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the public HTTPS port.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The public HTTPS port.</value>
|
||||||
|
public int PublicHttpsPort { get; set; } = DefaultHttpsPort;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the HTTP server port number.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The HTTP server port number.</value>
|
||||||
|
public int HttpServerPortNumber { get; set; } = DefaultHttpPort;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the HTTPS server port number.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The HTTPS server port number.</value>
|
||||||
|
public int HttpsPortNumber { get; set; } = DefaultHttpsPort;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether to use HTTPS.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// In order for HTTPS to be used, in addition to setting this to true, valid values must also be
|
||||||
|
/// provided for <see cref="ServerConfiguration.CertificatePath"/> and <see cref="ServerConfiguration.CertificatePassword"/>.
|
||||||
|
/// </remarks>
|
||||||
|
public bool EnableHttps { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the public mapped port.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The public mapped port.</value>
|
||||||
|
public int PublicPort { get; set; } = DefaultHttpPort;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether the http port should be mapped as part of UPnP automatic port forwarding.
|
||||||
|
/// </summary>
|
||||||
|
public bool UPnPCreateHttpPortMap { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the UDPPortRange.
|
||||||
|
/// </summary>
|
||||||
|
public string UDPPortRange { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether gets or sets IPV6 capability.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableIPV6 { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether gets or sets IPV4 capability.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableIPV4 { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether detailed SSDP logs are sent to the console/log.
|
||||||
|
/// "Emby.Dlna": "Debug" must be set in logging.default.json for this property to have any effect.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableSSDPTracing { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the SSDPTracingFilter
|
||||||
|
/// Gets or sets a value indicating whether an IP address is to be used to filter the detailed ssdp logs that are being sent to the console/log.
|
||||||
|
/// If the setting "Emby.Dlna": "Debug" msut be set in logging.default.json for this property to work.
|
||||||
|
/// </summary>
|
||||||
|
public string SSDPTracingFilter { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the number of times SSDP UDP messages are sent.
|
||||||
|
/// </summary>
|
||||||
|
public int UDPSendCount { get; set; } = 2;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the delay between each groups of SSDP messages (in ms).
|
||||||
|
/// </summary>
|
||||||
|
public int UDPSendDelay { get; set; } = 100;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether address names that match <see cref="VirtualInterfaceNames"/> should be Ignore for the purposes of binding.
|
||||||
|
/// </summary>
|
||||||
|
public bool IgnoreVirtualInterfaces { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating the interfaces that should be ignored. The list can be comma separated. <seealso cref="IgnoreVirtualInterfaces"/>.
|
||||||
|
/// </summary>
|
||||||
|
public string VirtualInterfaceNames { get; set; } = "vEthernet*";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the time (in seconds) between the pings of SSDP gateway monitor.
|
||||||
|
/// </summary>
|
||||||
|
public int GatewayMonitorPeriod { get; set; } = 60;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether multi-socket binding is available.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableMultiSocketBinding { get; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether all IPv6 interfaces should be treated as on the internal network.
|
||||||
|
/// Depending on the address range implemented ULA ranges might not be used.
|
||||||
|
/// </summary>
|
||||||
|
public bool TrustAllIP6Interfaces { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the ports that HDHomerun uses.
|
||||||
|
/// </summary>
|
||||||
|
public string HDHomerunPortRange { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the PublishedServerUriBySubnet
|
||||||
|
/// Gets or sets PublishedServerUri to advertise for specific subnets.
|
||||||
|
/// </summary>
|
||||||
|
public string[] PublishedServerUriBySubnet { get; set; } = Array.Empty<string>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether Autodiscovery tracing is enabled.
|
||||||
|
/// </summary>
|
||||||
|
public bool AutoDiscoveryTracing { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether Autodiscovery is enabled.
|
||||||
|
/// </summary>
|
||||||
|
public bool AutoDiscovery { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the filter for remote IP connectivity. Used in conjuntion with <seealso cref="IsRemoteIPFilterBlacklist"/>.
|
||||||
|
/// </summary>
|
||||||
|
public string[] RemoteIPFilter { get; set; } = Array.Empty<string>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether <seealso cref="RemoteIPFilter"/> contains a blacklist or a whitelist. Default is a whitelist.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsRemoteIPFilterBlacklist { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether to enable automatic port forwarding.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableUPnP { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether access outside of the LAN is permitted.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableRemoteAccess { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the subnets that are deemed to make up the LAN.
|
||||||
|
/// </summary>
|
||||||
|
public string[] LocalNetworkSubnets { get; set; } = Array.Empty<string>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the interface addresses which Jellyfin will bind to. If empty, all interfaces will be used.
|
||||||
|
/// </summary>
|
||||||
|
public string[] LocalNetworkAddresses { get; set; } = Array.Empty<string>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the known proxies.
|
||||||
|
/// </summary>
|
||||||
|
public string[] KnownProxies { get; set; } = Array.Empty<string>();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
using Jellyfin.Networking.Configuration;
|
||||||
|
using MediaBrowser.Common.Configuration;
|
||||||
|
|
||||||
|
namespace Jellyfin.Networking.Configuration
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the <see cref="NetworkConfigurationExtensions" />.
|
||||||
|
/// </summary>
|
||||||
|
public static class NetworkConfigurationExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the network configuration.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="config">The <see cref="IConfigurationManager"/>.</param>
|
||||||
|
/// <returns>The <see cref="NetworkConfiguration"/>.</returns>
|
||||||
|
public static NetworkConfiguration GetNetworkConfiguration(this IConfigurationManager config)
|
||||||
|
{
|
||||||
|
return config.GetConfiguration<NetworkConfiguration>("network");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using MediaBrowser.Common.Configuration;
|
||||||
|
|
||||||
|
namespace Jellyfin.Networking.Configuration
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the <see cref="NetworkConfigurationFactory" />.
|
||||||
|
/// </summary>
|
||||||
|
public class NetworkConfigurationFactory : IConfigurationFactory
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The GetConfigurations.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The <see cref="IEnumerable{ConfigurationStore}"/>.</returns>
|
||||||
|
public IEnumerable<ConfigurationStore> GetConfigurations()
|
||||||
|
{
|
||||||
|
return new[]
|
||||||
|
{
|
||||||
|
new ConfigurationStore
|
||||||
|
{
|
||||||
|
Key = "network",
|
||||||
|
ConfigurationType = typeof(NetworkConfiguration)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
30
Jellyfin.Networking/Jellyfin.Networking.csproj
Normal file
30
Jellyfin.Networking/Jellyfin.Networking.csproj
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="..\SharedVersion.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Code Analyzers-->
|
||||||
|
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
|
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8" PrivateAssets="All" />
|
||||||
|
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
|
||||||
|
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
|
||||||
|
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||||
|
<CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\MediaBrowser.Common\MediaBrowser.Common.csproj" />
|
||||||
|
<ProjectReference Include="..\MediaBrowser.Controller\MediaBrowser.Controller.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
234
Jellyfin.Networking/Manager/INetworkManager.cs
Normal file
234
Jellyfin.Networking/Manager/INetworkManager.cs
Normal file
|
@ -0,0 +1,234 @@
|
||||||
|
#nullable enable
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.NetworkInformation;
|
||||||
|
using Jellyfin.Networking.Configuration;
|
||||||
|
using MediaBrowser.Common.Net;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
|
namespace Jellyfin.Networking.Manager
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interface for the NetworkManager class.
|
||||||
|
/// </summary>
|
||||||
|
public interface INetworkManager
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Event triggered on network changes.
|
||||||
|
/// </summary>
|
||||||
|
event EventHandler NetworkChanged;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the published server urls list.
|
||||||
|
/// </summary>
|
||||||
|
Dictionary<IPNetAddress, string> PublishedServerUrls { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether is all IPv6 interfaces are trusted as internal.
|
||||||
|
/// </summary>
|
||||||
|
bool TrustAllIP6Interfaces { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the remote address filter.
|
||||||
|
/// </summary>
|
||||||
|
Collection<IPObject> RemoteAddressFilter { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether iP6 is enabled.
|
||||||
|
/// </summary>
|
||||||
|
bool IsIP6Enabled { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether iP4 is enabled.
|
||||||
|
/// </summary>
|
||||||
|
bool IsIP4Enabled { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Calculates the list of interfaces to use for Kestrel.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A Collection{IPObject} object containing all the interfaces to bind.
|
||||||
|
/// If all the interfaces are specified, and none are excluded, it returns zero items
|
||||||
|
/// to represent any address.</returns>
|
||||||
|
/// <param name="individualInterfaces">When false, return <see cref="IPAddress.Any"/> or <see cref="IPAddress.IPv6Any"/> for all interfaces.</param>
|
||||||
|
Collection<IPObject> GetAllBindInterfaces(bool individualInterfaces = false);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a collection containing the loopback interfaces.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Collection{IPObject}.</returns>
|
||||||
|
Collection<IPObject> GetLoopbacks();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the bind address to use in system url's. (Server Discovery, PlayTo, LiveTV, SystemInfo)
|
||||||
|
/// If no bind addresses are specified, an internal interface address is selected.
|
||||||
|
/// The priority of selection is as follows:-
|
||||||
|
///
|
||||||
|
/// The value contained in the startup parameter --published-server-url.
|
||||||
|
///
|
||||||
|
/// If the user specified custom subnet overrides, the correct subnet for the source address.
|
||||||
|
///
|
||||||
|
/// If the user specified bind interfaces to use:-
|
||||||
|
/// The bind interface that contains the source subnet.
|
||||||
|
/// The first bind interface specified that suits best first the source's endpoint. eg. external or internal.
|
||||||
|
///
|
||||||
|
/// If the source is from a public subnet address range and the user hasn't specified any bind addresses:-
|
||||||
|
/// The first public interface that isn't a loopback and contains the source subnet.
|
||||||
|
/// The first public interface that isn't a loopback. Priority is given to interfaces with gateways.
|
||||||
|
/// An internal interface if there are no public ip addresses.
|
||||||
|
///
|
||||||
|
/// If the source is from a private subnet address range and the user hasn't specified any bind addresses:-
|
||||||
|
/// The first private interface that contains the source subnet.
|
||||||
|
/// The first private interface that isn't a loopback. Priority is given to interfaces with gateways.
|
||||||
|
///
|
||||||
|
/// If no interfaces meet any of these criteria, then a loopback address is returned.
|
||||||
|
///
|
||||||
|
/// Interface that have been specifically excluded from binding are not used in any of the calculations.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source">Source of the request.</param>
|
||||||
|
/// <param name="port">Optional port returned, if it's part of an override.</param>
|
||||||
|
/// <returns>IP Address to use, or loopback address if all else fails.</returns>
|
||||||
|
string GetBindInterface(IPObject source, out int? port);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the bind address to use in system url's. (Server Discovery, PlayTo, LiveTV, SystemInfo)
|
||||||
|
/// If no bind addresses are specified, an internal interface address is selected.
|
||||||
|
/// (See <see cref="GetBindInterface(IPObject, out int?)"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source">Source of the request.</param>
|
||||||
|
/// <param name="port">Optional port returned, if it's part of an override.</param>
|
||||||
|
/// <returns>IP Address to use, or loopback address if all else fails.</returns>
|
||||||
|
string GetBindInterface(HttpRequest source, out int? port);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the bind address to use in system url's. (Server Discovery, PlayTo, LiveTV, SystemInfo)
|
||||||
|
/// If no bind addresses are specified, an internal interface address is selected.
|
||||||
|
/// (See <see cref="GetBindInterface(IPObject, out int?)"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source">IP address of the request.</param>
|
||||||
|
/// <param name="port">Optional port returned, if it's part of an override.</param>
|
||||||
|
/// <returns>IP Address to use, or loopback address if all else fails.</returns>
|
||||||
|
string GetBindInterface(IPAddress source, out int? port);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the bind address to use in system url's. (Server Discovery, PlayTo, LiveTV, SystemInfo)
|
||||||
|
/// If no bind addresses are specified, an internal interface address is selected.
|
||||||
|
/// (See <see cref="GetBindInterface(IPObject, out int?)"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source">Source of the request.</param>
|
||||||
|
/// <param name="port">Optional port returned, if it's part of an override.</param>
|
||||||
|
/// <returns>IP Address to use, or loopback address if all else fails.</returns>
|
||||||
|
string GetBindInterface(string source, out int? port);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks to see if the ip address is specifically excluded in LocalNetworkAddresses.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="address">IP address to check.</param>
|
||||||
|
/// <returns>True if it is.</returns>
|
||||||
|
bool IsExcludedInterface(IPAddress address);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get a list of all the MAC addresses associated with active interfaces.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>List of MAC addresses.</returns>
|
||||||
|
IReadOnlyCollection<PhysicalAddress> GetMacAddresses();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks to see if the IP Address provided matches an interface that has a gateway.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="addressObj">IP to check. Can be an IPAddress or an IPObject.</param>
|
||||||
|
/// <returns>Result of the check.</returns>
|
||||||
|
bool IsGatewayInterface(IPObject? addressObj);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks to see if the IP Address provided matches an interface that has a gateway.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="addressObj">IP to check. Can be an IPAddress or an IPObject.</param>
|
||||||
|
/// <returns>Result of the check.</returns>
|
||||||
|
bool IsGatewayInterface(IPAddress? addressObj);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the address is a private address.
|
||||||
|
/// The config option TrustIP6Interfaces overrides this functions behaviour.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="address">Address to check.</param>
|
||||||
|
/// <returns>True or False.</returns>
|
||||||
|
bool IsPrivateAddressRange(IPObject address);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the address is part of the user defined LAN.
|
||||||
|
/// The config option TrustIP6Interfaces overrides this functions behaviour.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="address">IP to check.</param>
|
||||||
|
/// <returns>True if endpoint is within the LAN range.</returns>
|
||||||
|
bool IsInLocalNetwork(string address);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the address is part of the user defined LAN.
|
||||||
|
/// The config option TrustIP6Interfaces overrides this functions behaviour.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="address">IP to check.</param>
|
||||||
|
/// <returns>True if endpoint is within the LAN range.</returns>
|
||||||
|
bool IsInLocalNetwork(IPObject address);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the address is part of the user defined LAN.
|
||||||
|
/// The config option TrustIP6Interfaces overrides this functions behaviour.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="address">IP to check.</param>
|
||||||
|
/// <returns>True if endpoint is within the LAN range.</returns>
|
||||||
|
bool IsInLocalNetwork(IPAddress address);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to convert the token to an IP address, permitting for interface descriptions and indexes.
|
||||||
|
/// eg. "eth1", or "TP-LINK Wireless USB Adapter".
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="token">Token to parse.</param>
|
||||||
|
/// <param name="result">Resultant object's ip addresses, if successful.</param>
|
||||||
|
/// <returns>Success of the operation.</returns>
|
||||||
|
bool TryParseInterface(string token, out Collection<IPObject>? result);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parses an array of strings into a Collection{IPObject}.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="values">Values to parse.</param>
|
||||||
|
/// <param name="bracketed">When true, only include values in []. When false, ignore bracketed values.</param>
|
||||||
|
/// <returns>IPCollection object containing the value strings.</returns>
|
||||||
|
Collection<IPObject> CreateIPCollection(string[] values, bool bracketed = false);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns all the internal Bind interface addresses.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>An internal list of interfaces addresses.</returns>
|
||||||
|
Collection<IPObject> GetInternalBindAddresses();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks to see if an IP address is still a valid interface address.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="address">IP address to check.</param>
|
||||||
|
/// <returns>True if it is.</returns>
|
||||||
|
bool IsValidInterfaceAddress(IPAddress address);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the IP address is in the excluded list.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ip">IP to check.</param>
|
||||||
|
/// <returns>True if excluded.</returns>
|
||||||
|
bool IsExcluded(IPAddress ip);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the IP address is in the excluded list.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ip">IP to check.</param>
|
||||||
|
/// <returns>True if excluded.</returns>
|
||||||
|
bool IsExcluded(EndPoint ip);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the filtered LAN ip addresses.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filter">Optional filter for the list.</param>
|
||||||
|
/// <returns>Returns a filtered list of LAN addresses.</returns>
|
||||||
|
Collection<IPObject> GetFilteredLANSubnets(Collection<IPObject>? filter = null);
|
||||||
|
}
|
||||||
|
}
|
1319
Jellyfin.Networking/Manager/NetworkManager.cs
Normal file
1319
Jellyfin.Networking/Manager/NetworkManager.cs
Normal file
File diff suppressed because it is too large
Load Diff
445
MediaBrowser.Common/Net/IPHost.cs
Normal file
445
MediaBrowser.Common/Net/IPHost.cs
Normal file
|
@ -0,0 +1,445 @@
|
||||||
|
#nullable enable
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Common.Net
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Object that holds a host name.
|
||||||
|
/// </summary>
|
||||||
|
public class IPHost : IPObject
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets timeout value before resolve required, in minutes.
|
||||||
|
/// </summary>
|
||||||
|
public const int Timeout = 30;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents an IPHost that has no value.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly IPHost None = new IPHost(string.Empty, IPAddress.None);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Time when last resolved in ticks.
|
||||||
|
/// </summary>
|
||||||
|
private DateTime? _lastResolved = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the IP Addresses, attempting to resolve the name, if there are none.
|
||||||
|
/// </summary>
|
||||||
|
private IPAddress[] _addresses;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="IPHost"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Host name to assign.</param>
|
||||||
|
public IPHost(string name)
|
||||||
|
{
|
||||||
|
HostName = name ?? throw new ArgumentNullException(nameof(name));
|
||||||
|
_addresses = Array.Empty<IPAddress>();
|
||||||
|
Resolved = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="IPHost"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="name">Host name to assign.</param>
|
||||||
|
/// <param name="address">Address to assign.</param>
|
||||||
|
private IPHost(string name, IPAddress address)
|
||||||
|
{
|
||||||
|
HostName = name ?? throw new ArgumentNullException(nameof(name));
|
||||||
|
_addresses = new IPAddress[] { address ?? throw new ArgumentNullException(nameof(address)) };
|
||||||
|
Resolved = !address.Equals(IPAddress.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the object's first IP address.
|
||||||
|
/// </summary>
|
||||||
|
public override IPAddress Address
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ResolveHost() ? this[0] : IPAddress.None;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
// Not implemented, as a host's address is determined by DNS.
|
||||||
|
throw new NotImplementedException("The address of a host is determined by DNS.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the object's first IP's subnet prefix.
|
||||||
|
/// The setter does nothing, but shouldn't raise an exception.
|
||||||
|
/// </summary>
|
||||||
|
public override byte PrefixLength
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (byte)(ResolveHost() ? 128 : 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
// Not implemented, as a host object can only have a prefix length of 128 (IPv6) or 32 (IPv4) prefix length,
|
||||||
|
// which is automatically determined by it's IP type. Anything else is meaningless.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether the address has a value.
|
||||||
|
/// </summary>
|
||||||
|
public bool HasAddress => _addresses.Length != 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the host name of this object.
|
||||||
|
/// </summary>
|
||||||
|
public string HostName { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether this host has attempted to be resolved.
|
||||||
|
/// </summary>
|
||||||
|
public bool Resolved { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the IP Addresses associated with this object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="index">Index of address.</param>
|
||||||
|
public IPAddress this[int index]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
ResolveHost();
|
||||||
|
return index >= 0 && index < _addresses.Length ? _addresses[index] : IPAddress.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to parse the host string.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="host">Host name to parse.</param>
|
||||||
|
/// <param name="hostObj">Object representing the string, if it has successfully been parsed.</param>
|
||||||
|
/// <returns><c>true</c> if the parsing is successful, <c>false</c> if not.</returns>
|
||||||
|
public static bool TryParse(string host, out IPHost hostObj)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(host))
|
||||||
|
{
|
||||||
|
// See if it's an IPv6 with port address e.g. [::1]:120.
|
||||||
|
int i = host.IndexOf("]:", StringComparison.OrdinalIgnoreCase);
|
||||||
|
if (i != -1)
|
||||||
|
{
|
||||||
|
return TryParse(host.Remove(i - 1).TrimStart(' ', '['), out hostObj);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// See if it's an IPv6 in [] with no port.
|
||||||
|
i = host.IndexOf(']', StringComparison.OrdinalIgnoreCase);
|
||||||
|
if (i != -1)
|
||||||
|
{
|
||||||
|
return TryParse(host.Remove(i - 1).TrimStart(' ', '['), out hostObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Is it a host or IPv4 with port?
|
||||||
|
string[] hosts = host.Split(':');
|
||||||
|
|
||||||
|
if (hosts.Length > 2)
|
||||||
|
{
|
||||||
|
hostObj = new IPHost(string.Empty, IPAddress.None);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove port from IPv4 if it exists.
|
||||||
|
host = hosts[0];
|
||||||
|
|
||||||
|
if (string.Equals("localhost", host, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
hostObj = new IPHost(host, new IPAddress(Ipv4Loopback));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IPNetAddress.TryParse(host, out IPNetAddress netIP))
|
||||||
|
{
|
||||||
|
// Host name is an ip address, so fake resolve.
|
||||||
|
hostObj = new IPHost(host, netIP.Address);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only thing left is to see if it's a host string.
|
||||||
|
if (!string.IsNullOrEmpty(host))
|
||||||
|
{
|
||||||
|
// Use regular expression as CheckHostName isn't RFC5892 compliant.
|
||||||
|
// Modified from gSkinner's expression at https://stackoverflow.com/questions/11809631/fully-qualified-domain-name-validation
|
||||||
|
Regex re = new Regex(@"^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){0,127}(?![0-9]*$)[a-z0-9-]+\.?)$", RegexOptions.IgnoreCase | RegexOptions.Multiline);
|
||||||
|
if (re.Match(host).Success)
|
||||||
|
{
|
||||||
|
hostObj = new IPHost(host);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hostObj = IPHost.None;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to parse the host string.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="host">Host name to parse.</param>
|
||||||
|
/// <returns>Object representing the string, if it has successfully been parsed.</returns>
|
||||||
|
public static IPHost Parse(string host)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(host) && IPHost.TryParse(host, out IPHost res))
|
||||||
|
{
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new InvalidCastException("Host does not contain a valid value. {host}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to parse the host string, ensuring that it resolves only to a specific IP type.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="host">Host name to parse.</param>
|
||||||
|
/// <param name="family">Addressfamily filter.</param>
|
||||||
|
/// <returns>Object representing the string, if it has successfully been parsed.</returns>
|
||||||
|
public static IPHost Parse(string host, AddressFamily family)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(host) && IPHost.TryParse(host, out IPHost res))
|
||||||
|
{
|
||||||
|
if (family == AddressFamily.InterNetwork)
|
||||||
|
{
|
||||||
|
res.Remove(AddressFamily.InterNetworkV6);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
res.Remove(AddressFamily.InterNetwork);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new InvalidCastException("Host does not contain a valid value. {host}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the Addresses that this item resolved to.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>IPAddress Array.</returns>
|
||||||
|
public IPAddress[] GetAddresses()
|
||||||
|
{
|
||||||
|
ResolveHost();
|
||||||
|
return _addresses;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override bool Contains(IPAddress address)
|
||||||
|
{
|
||||||
|
if (address != null && !Address.Equals(IPAddress.None))
|
||||||
|
{
|
||||||
|
if (address.IsIPv4MappedToIPv6)
|
||||||
|
{
|
||||||
|
address = address.MapToIPv4();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var addr in GetAddresses())
|
||||||
|
{
|
||||||
|
if (address.Equals(addr))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override bool Equals(IPObject? other)
|
||||||
|
{
|
||||||
|
if (other is IPHost otherObj)
|
||||||
|
{
|
||||||
|
// Do we have the name Hostname?
|
||||||
|
if (string.Equals(otherObj.HostName, HostName, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ResolveHost() || !otherObj.ResolveHost())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do any of our IP addresses match?
|
||||||
|
foreach (IPAddress addr in _addresses)
|
||||||
|
{
|
||||||
|
foreach (IPAddress otherAddress in otherObj._addresses)
|
||||||
|
{
|
||||||
|
if (addr.Equals(otherAddress))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override bool IsIP6()
|
||||||
|
{
|
||||||
|
// Returns true if interfaces are only IP6.
|
||||||
|
if (ResolveHost())
|
||||||
|
{
|
||||||
|
foreach (IPAddress i in _addresses)
|
||||||
|
{
|
||||||
|
if (i.AddressFamily != AddressFamily.InterNetworkV6)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
// StringBuilder not optimum here.
|
||||||
|
string output = string.Empty;
|
||||||
|
if (_addresses.Length > 0)
|
||||||
|
{
|
||||||
|
bool moreThanOne = _addresses.Length > 1;
|
||||||
|
if (moreThanOne)
|
||||||
|
{
|
||||||
|
output = "[";
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var i in _addresses)
|
||||||
|
{
|
||||||
|
if (Address.Equals(IPAddress.None) && Address.AddressFamily == AddressFamily.Unspecified)
|
||||||
|
{
|
||||||
|
output += HostName + ",";
|
||||||
|
}
|
||||||
|
else if (i.Equals(IPAddress.Any))
|
||||||
|
{
|
||||||
|
output += "Any IP4 Address,";
|
||||||
|
}
|
||||||
|
else if (Address.Equals(IPAddress.IPv6Any))
|
||||||
|
{
|
||||||
|
output += "Any IP6 Address,";
|
||||||
|
}
|
||||||
|
else if (i.Equals(IPAddress.Broadcast))
|
||||||
|
{
|
||||||
|
output += "Any Address,";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
output += $"{i}/32,";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
output = output[0..^1];
|
||||||
|
|
||||||
|
if (moreThanOne)
|
||||||
|
{
|
||||||
|
output += "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
output = HostName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override void Remove(AddressFamily family)
|
||||||
|
{
|
||||||
|
if (ResolveHost())
|
||||||
|
{
|
||||||
|
_addresses = _addresses.Where(p => p.AddressFamily != family).ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override bool Contains(IPObject address)
|
||||||
|
{
|
||||||
|
// An IPHost cannot contain another IPObject, it can only be equal.
|
||||||
|
return Equals(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
protected override IPObject CalculateNetworkAddress()
|
||||||
|
{
|
||||||
|
var netAddr = NetworkAddressOf(this[0], PrefixLength);
|
||||||
|
return new IPNetAddress(netAddr.Address, netAddr.PrefixLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attempt to resolve the ip address of a host.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns><c>true</c> if any addresses have been resolved, otherwise <c>false</c>.</returns>
|
||||||
|
private bool ResolveHost()
|
||||||
|
{
|
||||||
|
// When was the last time we resolved?
|
||||||
|
if (_lastResolved == null)
|
||||||
|
{
|
||||||
|
_lastResolved = DateTime.UtcNow;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we haven't resolved before, or our timer has run out...
|
||||||
|
if ((_addresses.Length == 0 && !Resolved) || (DateTime.UtcNow > _lastResolved?.AddMinutes(Timeout)))
|
||||||
|
{
|
||||||
|
_lastResolved = DateTime.UtcNow;
|
||||||
|
ResolveHostInternal().GetAwaiter().GetResult();
|
||||||
|
Resolved = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _addresses.Length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Task that looks up a Host name and returns its IP addresses.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
|
||||||
|
private async Task ResolveHostInternal()
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(HostName))
|
||||||
|
{
|
||||||
|
// Resolves the host name - so save a DNS lookup.
|
||||||
|
if (string.Equals(HostName, "localhost", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
_addresses = new IPAddress[] { new IPAddress(Ipv4Loopback), new IPAddress(Ipv6Loopback) };
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Uri.CheckHostName(HostName).Equals(UriHostNameType.Dns))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IPHostEntry ip = await Dns.GetHostEntryAsync(HostName).ConfigureAwait(false);
|
||||||
|
_addresses = ip.AddressList;
|
||||||
|
}
|
||||||
|
catch (SocketException ex)
|
||||||
|
{
|
||||||
|
// Log and then ignore socket errors, as the result value will just be an empty array.
|
||||||
|
Debug.WriteLine("GetHostEntryAsync failed with {Message}.", ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
277
MediaBrowser.Common/Net/IPNetAddress.cs
Normal file
277
MediaBrowser.Common/Net/IPNetAddress.cs
Normal file
|
@ -0,0 +1,277 @@
|
||||||
|
#nullable enable
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Common.Net
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An object that holds and IP address and subnet mask.
|
||||||
|
/// </summary>
|
||||||
|
public class IPNetAddress : IPObject
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents an IPNetAddress that has no value.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly IPNetAddress None = new IPNetAddress(IPAddress.None);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// IPv4 multicast address.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly IPAddress SSDPMulticastIPv4 = IPAddress.Parse("239.255.255.250");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// IPv6 local link multicast address.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly IPAddress SSDPMulticastIPv6LinkLocal = IPAddress.Parse("ff02::C");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// IPv6 site local multicast address.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly IPAddress SSDPMulticastIPv6SiteLocal = IPAddress.Parse("ff05::C");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// IP4Loopback address host.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly IPNetAddress IP4Loopback = IPNetAddress.Parse("127.0.0.1/32");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// IP6Loopback address host.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly IPNetAddress IP6Loopback = IPNetAddress.Parse("::1");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Object's IP address.
|
||||||
|
/// </summary>
|
||||||
|
private IPAddress _address;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="IPNetAddress"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="address">Address to assign.</param>
|
||||||
|
public IPNetAddress(IPAddress address)
|
||||||
|
{
|
||||||
|
_address = address ?? throw new ArgumentNullException(nameof(address));
|
||||||
|
PrefixLength = (byte)(address.AddressFamily == AddressFamily.InterNetwork ? 32 : 128);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="IPNetAddress"/> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="address">IP Address.</param>
|
||||||
|
/// <param name="prefixLength">Mask as a CIDR.</param>
|
||||||
|
public IPNetAddress(IPAddress address, byte prefixLength)
|
||||||
|
{
|
||||||
|
if (address?.IsIPv4MappedToIPv6 ?? throw new ArgumentNullException(nameof(address)))
|
||||||
|
{
|
||||||
|
_address = address.MapToIPv4();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_address = address;
|
||||||
|
}
|
||||||
|
|
||||||
|
PrefixLength = prefixLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the object's IP address.
|
||||||
|
/// </summary>
|
||||||
|
public override IPAddress Address
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _address;
|
||||||
|
}
|
||||||
|
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_address = value ?? IPAddress.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override byte PrefixLength { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Try to parse the address and subnet strings into an IPNetAddress object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="addr">IP address to parse. Can be CIDR or X.X.X.X notation.</param>
|
||||||
|
/// <param name="ip">Resultant object.</param>
|
||||||
|
/// <returns>True if the values parsed successfully. False if not, resulting in the IP being null.</returns>
|
||||||
|
public static bool TryParse(string addr, out IPNetAddress ip)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(addr))
|
||||||
|
{
|
||||||
|
addr = addr.Trim();
|
||||||
|
|
||||||
|
// Try to parse it as is.
|
||||||
|
if (IPAddress.TryParse(addr, out IPAddress? res))
|
||||||
|
{
|
||||||
|
ip = new IPNetAddress(res);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Is it a network?
|
||||||
|
string[] tokens = addr.Split("/");
|
||||||
|
|
||||||
|
if (tokens.Length == 2)
|
||||||
|
{
|
||||||
|
tokens[0] = tokens[0].TrimEnd();
|
||||||
|
tokens[1] = tokens[1].TrimStart();
|
||||||
|
|
||||||
|
if (IPAddress.TryParse(tokens[0], out res))
|
||||||
|
{
|
||||||
|
// Is the subnet part a cidr?
|
||||||
|
if (byte.TryParse(tokens[1], out byte cidr))
|
||||||
|
{
|
||||||
|
ip = new IPNetAddress(res, cidr);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Is the subnet in x.y.a.b form?
|
||||||
|
if (IPAddress.TryParse(tokens[1], out IPAddress? mask))
|
||||||
|
{
|
||||||
|
ip = new IPNetAddress(res, MaskToCidr(mask));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ip = None;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parses the string provided, throwing an exception if it is badly formed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="addr">String to parse.</param>
|
||||||
|
/// <returns>IPNetAddress object.</returns>
|
||||||
|
public static IPNetAddress Parse(string addr)
|
||||||
|
{
|
||||||
|
if (TryParse(addr, out IPNetAddress o))
|
||||||
|
{
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new ArgumentException("Unable to recognise object :" + addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override bool Contains(IPAddress address)
|
||||||
|
{
|
||||||
|
if (address == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(address));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (address.IsIPv4MappedToIPv6)
|
||||||
|
{
|
||||||
|
address = address.MapToIPv4();
|
||||||
|
}
|
||||||
|
|
||||||
|
var altAddress = NetworkAddressOf(address, PrefixLength);
|
||||||
|
return NetworkAddress.Address.Equals(altAddress.Address) && NetworkAddress.PrefixLength >= altAddress.PrefixLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override bool Contains(IPObject address)
|
||||||
|
{
|
||||||
|
if (address is IPHost addressObj && addressObj.HasAddress)
|
||||||
|
{
|
||||||
|
foreach (IPAddress addr in addressObj.GetAddresses())
|
||||||
|
{
|
||||||
|
if (Contains(addr))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (address is IPNetAddress netaddrObj)
|
||||||
|
{
|
||||||
|
// Have the same network address, but different subnets?
|
||||||
|
if (NetworkAddress.Address.Equals(netaddrObj.NetworkAddress.Address))
|
||||||
|
{
|
||||||
|
return NetworkAddress.PrefixLength <= netaddrObj.PrefixLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
var altAddress = NetworkAddressOf(netaddrObj.Address, PrefixLength);
|
||||||
|
return NetworkAddress.Address.Equals(altAddress.Address);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override bool Equals(IPObject? other)
|
||||||
|
{
|
||||||
|
if (other is IPNetAddress otherObj && !Address.Equals(IPAddress.None) && !otherObj.Address.Equals(IPAddress.None))
|
||||||
|
{
|
||||||
|
return Address.Equals(otherObj.Address) &&
|
||||||
|
PrefixLength == otherObj.PrefixLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override bool Equals(IPAddress address)
|
||||||
|
{
|
||||||
|
if (address != null && !address.Equals(IPAddress.None) && !Address.Equals(IPAddress.None))
|
||||||
|
{
|
||||||
|
return address.Equals(Address);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return ToString(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a textual representation of this object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="shortVersion">Set to true, if the subnet is to be excluded as part of the address.</param>
|
||||||
|
/// <returns>String representation of this object.</returns>
|
||||||
|
public string ToString(bool shortVersion)
|
||||||
|
{
|
||||||
|
if (!Address.Equals(IPAddress.None))
|
||||||
|
{
|
||||||
|
if (Address.Equals(IPAddress.Any))
|
||||||
|
{
|
||||||
|
return "Any IP4 Address";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Address.Equals(IPAddress.IPv6Any))
|
||||||
|
{
|
||||||
|
return "Any IP6 Address";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Address.Equals(IPAddress.Broadcast))
|
||||||
|
{
|
||||||
|
return "Any Address";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shortVersion)
|
||||||
|
{
|
||||||
|
return Address.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $"{Address}/{PrefixLength}";
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
protected override IPObject CalculateNetworkAddress()
|
||||||
|
{
|
||||||
|
var value = NetworkAddressOf(_address, PrefixLength);
|
||||||
|
return new IPNetAddress(value.Address, value.PrefixLength);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
406
MediaBrowser.Common/Net/IPObject.cs
Normal file
406
MediaBrowser.Common/Net/IPObject.cs
Normal file
|
@ -0,0 +1,406 @@
|
||||||
|
#nullable enable
|
||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Common.Net
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Base network object class.
|
||||||
|
/// </summary>
|
||||||
|
public abstract class IPObject : IEquatable<IPObject>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// IPv6 Loopback address.
|
||||||
|
/// </summary>
|
||||||
|
protected static readonly byte[] Ipv6Loopback = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// IPv4 Loopback address.
|
||||||
|
/// </summary>
|
||||||
|
protected static readonly byte[] Ipv4Loopback = { 127, 0, 0, 1 };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The network address of this object.
|
||||||
|
/// </summary>
|
||||||
|
private IPObject? _networkAddress;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a user defined value that is associated with this object.
|
||||||
|
/// </summary>
|
||||||
|
public int Tag { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the object's IP address.
|
||||||
|
/// </summary>
|
||||||
|
public abstract IPAddress Address { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the object's network address.
|
||||||
|
/// </summary>
|
||||||
|
public IPObject NetworkAddress => _networkAddress ??= CalculateNetworkAddress();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the object's IP address.
|
||||||
|
/// </summary>
|
||||||
|
public abstract byte PrefixLength { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the AddressFamily of this object.
|
||||||
|
/// </summary>
|
||||||
|
public AddressFamily AddressFamily
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
// Keep terms separate as Address performs other functions in inherited objects.
|
||||||
|
IPAddress address = Address;
|
||||||
|
return address.Equals(IPAddress.None) ? AddressFamily.Unspecified : address.AddressFamily;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the network address of an object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="address">IP Address to convert.</param>
|
||||||
|
/// <param name="prefixLength">Subnet prefix.</param>
|
||||||
|
/// <returns>IPAddress.</returns>
|
||||||
|
public static (IPAddress Address, byte PrefixLength) NetworkAddressOf(IPAddress address, byte prefixLength)
|
||||||
|
{
|
||||||
|
if (address == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(address));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (address.IsIPv4MappedToIPv6)
|
||||||
|
{
|
||||||
|
address = address.MapToIPv4();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsLoopback(address))
|
||||||
|
{
|
||||||
|
return (Address: address, PrefixLength: prefixLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
// An ip address is just a list of bytes, each one representing a segment on the network.
|
||||||
|
// This separates the IP address into octets and calculates how many octets will need to be altered or set to zero dependant upon the
|
||||||
|
// prefix length value. eg. /16 on a 4 octet ip4 address (192.168.2.240) will result in the 2 and the 240 being zeroed out.
|
||||||
|
// Where there is not an exact boundary (eg /23), mod is used to calculate how many bits of this value are to be kept.
|
||||||
|
|
||||||
|
// GetAddressBytes
|
||||||
|
Span<byte> addressBytes = stackalloc byte[address.AddressFamily == AddressFamily.InterNetwork ? 4 : 16];
|
||||||
|
address.TryWriteBytes(addressBytes, out _);
|
||||||
|
|
||||||
|
int div = prefixLength / 8;
|
||||||
|
int mod = prefixLength % 8;
|
||||||
|
if (mod != 0)
|
||||||
|
{
|
||||||
|
// Prefix length is counted right to left, so subtract 8 so we know how many bits to clear.
|
||||||
|
mod = 8 - mod;
|
||||||
|
|
||||||
|
// Shift out the bits from the octet that we don't want, by moving right then back left.
|
||||||
|
addressBytes[div] = (byte)((int)addressBytes[div] >> mod << mod);
|
||||||
|
// Move on the next byte.
|
||||||
|
div++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Blank out the remaining octets from mod + 1 to the end of the byte array. (192.168.2.240/16 becomes 192.168.0.0)
|
||||||
|
for (int octet = div; octet < addressBytes.Length; octet++)
|
||||||
|
{
|
||||||
|
addressBytes[octet] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the network address for the prefix.
|
||||||
|
return (Address: new IPAddress(addressBytes), PrefixLength: prefixLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests to see if the ip address is a Loopback address.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="address">Value to test.</param>
|
||||||
|
/// <returns>True if it is.</returns>
|
||||||
|
public static bool IsLoopback(IPAddress address)
|
||||||
|
{
|
||||||
|
if (address == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(address));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!address.Equals(IPAddress.None))
|
||||||
|
{
|
||||||
|
if (address.IsIPv4MappedToIPv6)
|
||||||
|
{
|
||||||
|
address = address.MapToIPv4();
|
||||||
|
}
|
||||||
|
|
||||||
|
return address.Equals(IPAddress.Loopback) || address.Equals(IPAddress.IPv6Loopback);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests to see if the ip address is an IP6 address.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="address">Value to test.</param>
|
||||||
|
/// <returns>True if it is.</returns>
|
||||||
|
public static bool IsIP6(IPAddress address)
|
||||||
|
{
|
||||||
|
if (address == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(address));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (address.IsIPv4MappedToIPv6)
|
||||||
|
{
|
||||||
|
address = address.MapToIPv4();
|
||||||
|
}
|
||||||
|
|
||||||
|
return !address.Equals(IPAddress.None) && (address.AddressFamily == AddressFamily.InterNetworkV6);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests to see if the address in the private address range.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="address">Object to test.</param>
|
||||||
|
/// <returns>True if it contains a private address.</returns>
|
||||||
|
public static bool IsPrivateAddressRange(IPAddress address)
|
||||||
|
{
|
||||||
|
if (address == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(address));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!address.Equals(IPAddress.None))
|
||||||
|
{
|
||||||
|
if (address.IsIPv4MappedToIPv6)
|
||||||
|
{
|
||||||
|
address = address.MapToIPv4();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (address.AddressFamily == AddressFamily.InterNetwork)
|
||||||
|
{
|
||||||
|
// GetAddressBytes
|
||||||
|
Span<byte> octet = stackalloc byte[4];
|
||||||
|
address.TryWriteBytes(octet, out _);
|
||||||
|
|
||||||
|
return (octet[0] == 10)
|
||||||
|
|| (octet[0] == 172 && octet[1] >= 16 && octet[1] <= 31) // RFC1918
|
||||||
|
|| (octet[0] == 192 && octet[1] == 168) // RFC1918
|
||||||
|
|| (octet[0] == 127); // RFC1122
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// GetAddressBytes
|
||||||
|
Span<byte> octet = stackalloc byte[16];
|
||||||
|
address.TryWriteBytes(octet, out _);
|
||||||
|
|
||||||
|
uint word = (uint)(octet[0] << 8) + octet[1];
|
||||||
|
|
||||||
|
return (word >= 0xfe80 && word <= 0xfebf) // fe80::/10 :Local link.
|
||||||
|
|| (word >= 0xfc00 && word <= 0xfdff); // fc00::/7 :Unique local address.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the IPAddress contains an IP6 Local link address.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="address">IPAddress object to check.</param>
|
||||||
|
/// <returns>True if it is a local link address.</returns>
|
||||||
|
/// <remarks>
|
||||||
|
/// See https://stackoverflow.com/questions/6459928/explain-the-instance-properties-of-system-net-ipaddress
|
||||||
|
/// it appears that the IPAddress.IsIPv6LinkLocal is out of date.
|
||||||
|
/// </remarks>
|
||||||
|
public static bool IsIPv6LinkLocal(IPAddress address)
|
||||||
|
{
|
||||||
|
if (address == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(address));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (address.IsIPv4MappedToIPv6)
|
||||||
|
{
|
||||||
|
address = address.MapToIPv4();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (address.AddressFamily != AddressFamily.InterNetworkV6)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAddressBytes
|
||||||
|
Span<byte> octet = stackalloc byte[16];
|
||||||
|
address.TryWriteBytes(octet, out _);
|
||||||
|
uint word = (uint)(octet[0] << 8) + octet[1];
|
||||||
|
|
||||||
|
return word >= 0xfe80 && word <= 0xfebf; // fe80::/10 :Local link.
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Convert a subnet mask in CIDR notation to a dotted decimal string value. IPv4 only.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cidr">Subnet mask in CIDR notation.</param>
|
||||||
|
/// <param name="family">IPv4 or IPv6 family.</param>
|
||||||
|
/// <returns>String value of the subnet mask in dotted decimal notation.</returns>
|
||||||
|
public static IPAddress CidrToMask(byte cidr, AddressFamily family)
|
||||||
|
{
|
||||||
|
uint addr = 0xFFFFFFFF << (family == AddressFamily.InterNetwork ? 32 : 128 - cidr);
|
||||||
|
addr = ((addr & 0xff000000) >> 24)
|
||||||
|
| ((addr & 0x00ff0000) >> 8)
|
||||||
|
| ((addr & 0x0000ff00) << 8)
|
||||||
|
| ((addr & 0x000000ff) << 24);
|
||||||
|
return new IPAddress(addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Convert a mask to a CIDR. IPv4 only.
|
||||||
|
/// https://stackoverflow.com/questions/36954345/get-cidr-from-netmask.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mask">Subnet mask.</param>
|
||||||
|
/// <returns>Byte CIDR representing the mask.</returns>
|
||||||
|
public static byte MaskToCidr(IPAddress mask)
|
||||||
|
{
|
||||||
|
if (mask == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(mask));
|
||||||
|
}
|
||||||
|
|
||||||
|
byte cidrnet = 0;
|
||||||
|
if (!mask.Equals(IPAddress.Any))
|
||||||
|
{
|
||||||
|
// GetAddressBytes
|
||||||
|
Span<byte> bytes = stackalloc byte[mask.AddressFamily == AddressFamily.InterNetwork ? 4 : 16];
|
||||||
|
mask.TryWriteBytes(bytes, out _);
|
||||||
|
|
||||||
|
var zeroed = false;
|
||||||
|
for (var i = 0; i < bytes.Length; i++)
|
||||||
|
{
|
||||||
|
for (int v = bytes[i]; (v & 0xFF) != 0; v <<= 1)
|
||||||
|
{
|
||||||
|
if (zeroed)
|
||||||
|
{
|
||||||
|
// Invalid netmask.
|
||||||
|
return (byte)~cidrnet;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((v & 0x80) == 0)
|
||||||
|
{
|
||||||
|
zeroed = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cidrnet++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cidrnet;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests to see if this object is a Loopback address.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>True if it is.</returns>
|
||||||
|
public virtual bool IsLoopback()
|
||||||
|
{
|
||||||
|
return IsLoopback(Address);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes all addresses of a specific type from this object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="family">Type of address to remove.</param>
|
||||||
|
public virtual void Remove(AddressFamily family)
|
||||||
|
{
|
||||||
|
// This method only performs a function in the IPHost implementation of IPObject.
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests to see if this object is an IPv6 address.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>True if it is.</returns>
|
||||||
|
public virtual bool IsIP6()
|
||||||
|
{
|
||||||
|
return IsIP6(Address);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if this IP address is in the RFC private address range.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>True this object has a private address.</returns>
|
||||||
|
public virtual bool IsPrivateAddressRange()
|
||||||
|
{
|
||||||
|
return IsPrivateAddressRange(Address);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Compares this to the object passed as a parameter.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ip">Object to compare to.</param>
|
||||||
|
/// <returns>Equality result.</returns>
|
||||||
|
public virtual bool Equals(IPAddress ip)
|
||||||
|
{
|
||||||
|
if (ip != null)
|
||||||
|
{
|
||||||
|
if (ip.IsIPv4MappedToIPv6)
|
||||||
|
{
|
||||||
|
ip = ip.MapToIPv4();
|
||||||
|
}
|
||||||
|
|
||||||
|
return !Address.Equals(IPAddress.None) && Address.Equals(ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Compares this to the object passed as a parameter.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="other">Object to compare to.</param>
|
||||||
|
/// <returns>Equality result.</returns>
|
||||||
|
public virtual bool Equals(IPObject? other)
|
||||||
|
{
|
||||||
|
if (other != null)
|
||||||
|
{
|
||||||
|
return !Address.Equals(IPAddress.None) && Address.Equals(other.Address);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Compares the address in this object and the address in the object passed as a parameter.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="address">Object's IP address to compare to.</param>
|
||||||
|
/// <returns>Comparison result.</returns>
|
||||||
|
public abstract bool Contains(IPObject address);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Compares the address in this object and the address in the object passed as a parameter.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="address">Object's IP address to compare to.</param>
|
||||||
|
/// <returns>Comparison result.</returns>
|
||||||
|
public abstract bool Contains(IPAddress address);
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
return Address.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override bool Equals(object? obj)
|
||||||
|
{
|
||||||
|
return Equals(obj as IPObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Calculates the network address of this object.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Returns the network address of this object.</returns>
|
||||||
|
protected abstract IPObject CalculateNetworkAddress();
|
||||||
|
}
|
||||||
|
}
|
262
MediaBrowser.Common/Net/NetworkExtensions.cs
Normal file
262
MediaBrowser.Common/Net/NetworkExtensions.cs
Normal file
|
@ -0,0 +1,262 @@
|
||||||
|
#pragma warning disable CA1062 // Validate arguments of public methods
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Net;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Common.Net
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the <see cref="NetworkExtensions" />.
|
||||||
|
/// </summary>
|
||||||
|
public static class NetworkExtensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Add an address to the collection.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source">The <see cref="Collection{IPObject}"/>.</param>
|
||||||
|
/// <param name="ip">Item to add.</param>
|
||||||
|
public static void AddItem(this Collection<IPObject> source, IPAddress ip)
|
||||||
|
{
|
||||||
|
if (!source.ContainsAddress(ip))
|
||||||
|
{
|
||||||
|
source.Add(new IPNetAddress(ip, 32));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a network to the collection.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source">The <see cref="Collection{IPObject}"/>.</param>
|
||||||
|
/// <param name="item">Item to add.</param>
|
||||||
|
public static void AddItem(this Collection<IPObject> source, IPObject item)
|
||||||
|
{
|
||||||
|
if (!source.ContainsAddress(item))
|
||||||
|
{
|
||||||
|
source.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts this object to a string.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source">The <see cref="Collection{IPObject}"/>.</param>
|
||||||
|
/// <returns>Returns a string representation of this object.</returns>
|
||||||
|
public static string AsString(this Collection<IPObject> source)
|
||||||
|
{
|
||||||
|
return $"[{string.Join(',', source)}]";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the collection contains an item with the ip address,
|
||||||
|
/// or the ip address falls within any of the collection's network ranges.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source">The <see cref="Collection{IPObject}"/>.</param>
|
||||||
|
/// <param name="item">The item to look for.</param>
|
||||||
|
/// <returns>True if the collection contains the item.</returns>
|
||||||
|
public static bool ContainsAddress(this Collection<IPObject> source, IPAddress item)
|
||||||
|
{
|
||||||
|
if (source.Count == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.IsIPv4MappedToIPv6)
|
||||||
|
{
|
||||||
|
item = item.MapToIPv4();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var i in source)
|
||||||
|
{
|
||||||
|
if (i.Contains(item))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the collection contains an item with the ip address,
|
||||||
|
/// or the ip address falls within any of the collection's network ranges.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source">The <see cref="Collection{IPObject}"/>.</param>
|
||||||
|
/// <param name="item">The item to look for.</param>
|
||||||
|
/// <returns>True if the collection contains the item.</returns>
|
||||||
|
public static bool ContainsAddress(this Collection<IPObject> source, IPObject item)
|
||||||
|
{
|
||||||
|
if (source.Count == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var i in source)
|
||||||
|
{
|
||||||
|
if (i.Contains(item))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Compares two Collection{IPObject} objects. The order is ignored.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source">The <see cref="Collection{IPObject}"/>.</param>
|
||||||
|
/// <param name="dest">Item to compare to.</param>
|
||||||
|
/// <returns>True if both are equal.</returns>
|
||||||
|
public static bool Compare(this Collection<IPObject> source, Collection<IPObject> dest)
|
||||||
|
{
|
||||||
|
if (dest == null || source.Count != dest.Count)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var sourceItem in source)
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
foreach (var destItem in dest)
|
||||||
|
{
|
||||||
|
if (sourceItem.Equals(destItem))
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a collection containing the subnets of this collection given.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source">The <see cref="Collection{IPObject}"/>.</param>
|
||||||
|
/// <returns>Collection{IPObject} object containing the subnets.</returns>
|
||||||
|
public static Collection<IPObject> AsNetworks(this Collection<IPObject> source)
|
||||||
|
{
|
||||||
|
if (source == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(source));
|
||||||
|
}
|
||||||
|
|
||||||
|
Collection<IPObject> res = new Collection<IPObject>();
|
||||||
|
|
||||||
|
foreach (IPObject i in source)
|
||||||
|
{
|
||||||
|
if (i is IPNetAddress nw)
|
||||||
|
{
|
||||||
|
// Add the subnet calculated from the interface address/mask.
|
||||||
|
var na = nw.NetworkAddress;
|
||||||
|
na.Tag = i.Tag;
|
||||||
|
res.AddItem(na);
|
||||||
|
}
|
||||||
|
else if (i is IPHost ipHost)
|
||||||
|
{
|
||||||
|
// Flatten out IPHost and add all its ip addresses.
|
||||||
|
foreach (var addr in ipHost.GetAddresses())
|
||||||
|
{
|
||||||
|
IPNetAddress host = new IPNetAddress(addr)
|
||||||
|
{
|
||||||
|
Tag = i.Tag
|
||||||
|
};
|
||||||
|
|
||||||
|
res.AddItem(host);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Excludes all the items from this list that are found in excludeList.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source">The <see cref="Collection{IPObject}"/>.</param>
|
||||||
|
/// <param name="excludeList">Items to exclude.</param>
|
||||||
|
/// <returns>A new collection, with the items excluded.</returns>
|
||||||
|
public static Collection<IPObject> Exclude(this Collection<IPObject> source, Collection<IPObject> excludeList)
|
||||||
|
{
|
||||||
|
if (source.Count == 0 || excludeList == null)
|
||||||
|
{
|
||||||
|
return new Collection<IPObject>(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
Collection<IPObject> results = new Collection<IPObject>();
|
||||||
|
|
||||||
|
bool found;
|
||||||
|
foreach (var outer in source)
|
||||||
|
{
|
||||||
|
found = false;
|
||||||
|
|
||||||
|
foreach (var inner in excludeList)
|
||||||
|
{
|
||||||
|
if (outer.Equals(inner))
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
|
results.AddItem(outer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns all items that co-exist in this object and target.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="source">The <see cref="Collection{IPObject}"/>.</param>
|
||||||
|
/// <param name="target">Collection to compare with.</param>
|
||||||
|
/// <returns>A collection containing all the matches.</returns>
|
||||||
|
public static Collection<IPObject> Union(this Collection<IPObject> source, Collection<IPObject> target)
|
||||||
|
{
|
||||||
|
if (source.Count == 0)
|
||||||
|
{
|
||||||
|
return new Collection<IPObject>();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(target));
|
||||||
|
}
|
||||||
|
|
||||||
|
Collection<IPObject> nc = new Collection<IPObject>();
|
||||||
|
|
||||||
|
foreach (IPObject i in source)
|
||||||
|
{
|
||||||
|
if (target.ContainsAddress(i))
|
||||||
|
{
|
||||||
|
nc.AddItem(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
20
MediaBrowser.Model/Configuration/PathSubstitution.cs
Normal file
20
MediaBrowser.Model/Configuration/PathSubstitution.cs
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
|
namespace MediaBrowser.Model.Configuration
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines the <see cref="PathSubstitution" />.
|
||||||
|
/// </summary>
|
||||||
|
public class PathSubstitution
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the value to substitute.
|
||||||
|
/// </summary>
|
||||||
|
public string From { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the value to substitution with.
|
||||||
|
/// </summary>
|
||||||
|
public string To { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
#nullable disable
|
|
||||||
#pragma warning disable CS1591
|
#pragma warning disable CS1591
|
||||||
|
#pragma warning disable CA1819
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -13,326 +13,23 @@ namespace MediaBrowser.Model.Configuration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ServerConfiguration : BaseApplicationConfiguration
|
public class ServerConfiguration : BaseApplicationConfiguration
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The default value for <see cref="HttpServerPortNumber"/>.
|
||||||
|
/// </summary>
|
||||||
public const int DefaultHttpPort = 8096;
|
public const int DefaultHttpPort = 8096;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The default value for <see cref="PublicHttpsPort"/> and <see cref="HttpsPortNumber"/>.
|
||||||
|
/// </summary>
|
||||||
public const int DefaultHttpsPort = 8920;
|
public const int DefaultHttpsPort = 8920;
|
||||||
private string _baseUrl;
|
|
||||||
|
|
||||||
/// <summary>
|
private string _baseUrl = string.Empty;
|
||||||
/// Gets or sets a value indicating whether to enable automatic port forwarding.
|
|
||||||
/// </summary>
|
|
||||||
public bool EnableUPnP { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether to enable prometheus metrics exporting.
|
|
||||||
/// </summary>
|
|
||||||
public bool EnableMetrics { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the public mapped port.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The public mapped port.</value>
|
|
||||||
public int PublicPort { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the public HTTPS port.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The public HTTPS port.</value>
|
|
||||||
public int PublicHttpsPort { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the HTTP server port number.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The HTTP server port number.</value>
|
|
||||||
public int HttpServerPortNumber { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the HTTPS server port number.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The HTTPS server port number.</value>
|
|
||||||
public int HttpsPortNumber { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether to use HTTPS.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// In order for HTTPS to be used, in addition to setting this to true, valid values must also be
|
|
||||||
/// provided for <see cref="CertificatePath"/> and <see cref="CertificatePassword"/>.
|
|
||||||
/// </remarks>
|
|
||||||
public bool EnableHttps { get; set; }
|
|
||||||
|
|
||||||
public bool EnableNormalizedItemByNameIds { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the filesystem path of an X.509 certificate to use for SSL.
|
|
||||||
/// </summary>
|
|
||||||
public string CertificatePath { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the password required to access the X.509 certificate data in the file specified by <see cref="CertificatePath"/>.
|
|
||||||
/// </summary>
|
|
||||||
public string CertificatePassword { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether this instance is port authorized.
|
|
||||||
/// </summary>
|
|
||||||
/// <value><c>true</c> if this instance is port authorized; otherwise, <c>false</c>.</value>
|
|
||||||
public bool IsPortAuthorized { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets if quick connect is available for use on this server.
|
|
||||||
/// </summary>
|
|
||||||
public bool QuickConnectAvailable { get; set; }
|
|
||||||
|
|
||||||
public bool EnableRemoteAccess { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether [enable case sensitive item ids].
|
|
||||||
/// </summary>
|
|
||||||
/// <value><c>true</c> if [enable case sensitive item ids]; otherwise, <c>false</c>.</value>
|
|
||||||
public bool EnableCaseSensitiveItemIds { get; set; }
|
|
||||||
|
|
||||||
public bool DisableLiveTvChannelUserDataName { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the metadata path.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The metadata path.</value>
|
|
||||||
public string MetadataPath { get; set; }
|
|
||||||
|
|
||||||
public string MetadataNetworkPath { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the preferred metadata language.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The preferred metadata language.</value>
|
|
||||||
public string PreferredMetadataLanguage { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the metadata country code.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The metadata country code.</value>
|
|
||||||
public string MetadataCountryCode { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Characters to be replaced with a ' ' in strings to create a sort name.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The sort replace characters.</value>
|
|
||||||
public string[] SortReplaceCharacters { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Characters to be removed from strings to create a sort name.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The sort remove characters.</value>
|
|
||||||
public string[] SortRemoveCharacters { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Words to be removed from strings to create a sort name.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The sort remove words.</value>
|
|
||||||
public string[] SortRemoveWords { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the minimum percentage of an item that must be played in order for playstate to be updated.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The min resume PCT.</value>
|
|
||||||
public int MinResumePct { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the maximum percentage of an item that can be played while still saving playstate. If this percentage is crossed playstate will be reset to the beginning and the item will be marked watched.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The max resume PCT.</value>
|
|
||||||
public int MaxResumePct { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the minimum duration that an item must have in order to be eligible for playstate updates..
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The min resume duration seconds.</value>
|
|
||||||
public int MinResumeDurationSeconds { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The delay in seconds that we will wait after a file system change to try and discover what has been added/removed
|
|
||||||
/// Some delay is necessary with some items because their creation is not atomic. It involves the creation of several
|
|
||||||
/// different directories and files.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The file watcher delay.</value>
|
|
||||||
public int LibraryMonitorDelay { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether [enable dashboard response caching].
|
|
||||||
/// Allows potential contributors without visual studio to modify production dashboard code and test changes.
|
|
||||||
/// </summary>
|
|
||||||
/// <value><c>true</c> if [enable dashboard response caching]; otherwise, <c>false</c>.</value>
|
|
||||||
public bool EnableDashboardResponseCaching { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the image saving convention.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The image saving convention.</value>
|
|
||||||
public ImageSavingConvention ImageSavingConvention { get; set; }
|
|
||||||
|
|
||||||
public MetadataOptions[] MetadataOptions { get; set; }
|
|
||||||
|
|
||||||
public bool SkipDeserializationForBasicTypes { get; set; }
|
|
||||||
|
|
||||||
public string ServerName { get; set; }
|
|
||||||
|
|
||||||
public string BaseUrl
|
|
||||||
{
|
|
||||||
get => _baseUrl;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
// Normalize the start of the string
|
|
||||||
if (string.IsNullOrWhiteSpace(value))
|
|
||||||
{
|
|
||||||
// If baseUrl is empty, set an empty prefix string
|
|
||||||
_baseUrl = string.Empty;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value[0] != '/')
|
|
||||||
{
|
|
||||||
// If baseUrl was not configured with a leading slash, append one for consistency
|
|
||||||
value = "/" + value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Normalize the end of the string
|
|
||||||
if (value[value.Length - 1] == '/')
|
|
||||||
{
|
|
||||||
// If baseUrl was configured with a trailing slash, remove it for consistency
|
|
||||||
value = value.Remove(value.Length - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
_baseUrl = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string UICulture { get; set; }
|
|
||||||
|
|
||||||
public bool SaveMetadataHidden { get; set; }
|
|
||||||
|
|
||||||
public NameValuePair[] ContentTypes { get; set; }
|
|
||||||
|
|
||||||
public int RemoteClientBitrateLimit { get; set; }
|
|
||||||
|
|
||||||
public bool EnableFolderView { get; set; }
|
|
||||||
|
|
||||||
public bool EnableGroupingIntoCollections { get; set; }
|
|
||||||
|
|
||||||
public bool DisplaySpecialsWithinSeasons { get; set; }
|
|
||||||
|
|
||||||
public string[] LocalNetworkSubnets { get; set; }
|
|
||||||
|
|
||||||
public string[] LocalNetworkAddresses { get; set; }
|
|
||||||
|
|
||||||
public string[] CodecsUsed { get; set; }
|
|
||||||
|
|
||||||
public List<RepositoryInfo> PluginRepositories { get; set; }
|
|
||||||
|
|
||||||
public bool IgnoreVirtualInterfaces { get; set; }
|
|
||||||
|
|
||||||
public bool EnableExternalContentInSuggestions { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether the server should force connections over HTTPS.
|
|
||||||
/// </summary>
|
|
||||||
public bool RequireHttps { get; set; }
|
|
||||||
|
|
||||||
public bool EnableNewOmdbSupport { get; set; }
|
|
||||||
|
|
||||||
public string[] RemoteIPFilter { get; set; }
|
|
||||||
|
|
||||||
public bool IsRemoteIPFilterBlacklist { get; set; }
|
|
||||||
|
|
||||||
public int ImageExtractionTimeoutMs { get; set; }
|
|
||||||
|
|
||||||
public PathSubstitution[] PathSubstitutions { get; set; }
|
|
||||||
|
|
||||||
public bool EnableSimpleArtistDetection { get; set; }
|
|
||||||
|
|
||||||
public string[] UninstalledPlugins { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether slow server responses should be logged as a warning.
|
|
||||||
/// </summary>
|
|
||||||
public bool EnableSlowResponseWarning { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the threshold for the slow response time warning in ms.
|
|
||||||
/// </summary>
|
|
||||||
public long SlowResponseThresholdMs { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the cors hosts.
|
|
||||||
/// </summary>
|
|
||||||
public string[] CorsHosts { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the known proxies.
|
|
||||||
/// </summary>
|
|
||||||
public string[] KnownProxies { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the number of days we should retain activity logs.
|
|
||||||
/// </summary>
|
|
||||||
public int? ActivityLogRetentionDays { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
|
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ServerConfiguration()
|
public ServerConfiguration()
|
||||||
{
|
{
|
||||||
UninstalledPlugins = Array.Empty<string>();
|
|
||||||
RemoteIPFilter = Array.Empty<string>();
|
|
||||||
LocalNetworkSubnets = Array.Empty<string>();
|
|
||||||
LocalNetworkAddresses = Array.Empty<string>();
|
|
||||||
CodecsUsed = Array.Empty<string>();
|
|
||||||
PathSubstitutions = Array.Empty<PathSubstitution>();
|
|
||||||
IgnoreVirtualInterfaces = false;
|
|
||||||
EnableSimpleArtistDetection = false;
|
|
||||||
SkipDeserializationForBasicTypes = true;
|
|
||||||
|
|
||||||
PluginRepositories = new List<RepositoryInfo>();
|
|
||||||
|
|
||||||
DisplaySpecialsWithinSeasons = true;
|
|
||||||
EnableExternalContentInSuggestions = true;
|
|
||||||
|
|
||||||
ImageSavingConvention = ImageSavingConvention.Compatible;
|
|
||||||
PublicPort = DefaultHttpPort;
|
|
||||||
PublicHttpsPort = DefaultHttpsPort;
|
|
||||||
HttpServerPortNumber = DefaultHttpPort;
|
|
||||||
HttpsPortNumber = DefaultHttpsPort;
|
|
||||||
EnableMetrics = false;
|
|
||||||
EnableHttps = false;
|
|
||||||
EnableDashboardResponseCaching = true;
|
|
||||||
EnableCaseSensitiveItemIds = true;
|
|
||||||
EnableNormalizedItemByNameIds = true;
|
|
||||||
DisableLiveTvChannelUserDataName = true;
|
|
||||||
EnableNewOmdbSupport = true;
|
|
||||||
|
|
||||||
EnableRemoteAccess = true;
|
|
||||||
QuickConnectAvailable = false;
|
|
||||||
|
|
||||||
EnableUPnP = false;
|
|
||||||
MinResumePct = 5;
|
|
||||||
MaxResumePct = 90;
|
|
||||||
|
|
||||||
// 5 minutes
|
|
||||||
MinResumeDurationSeconds = 300;
|
|
||||||
|
|
||||||
LibraryMonitorDelay = 60;
|
|
||||||
|
|
||||||
ContentTypes = Array.Empty<NameValuePair>();
|
|
||||||
|
|
||||||
PreferredMetadataLanguage = "en";
|
|
||||||
MetadataCountryCode = "US";
|
|
||||||
|
|
||||||
SortReplaceCharacters = new[] { ".", "+", "%" };
|
|
||||||
SortRemoveCharacters = new[] { ",", "&", "-", "{", "}", "'" };
|
|
||||||
SortRemoveWords = new[] { "the", "a", "an" };
|
|
||||||
|
|
||||||
BaseUrl = string.Empty;
|
|
||||||
UICulture = "en-US";
|
|
||||||
|
|
||||||
MetadataOptions = new[]
|
MetadataOptions = new[]
|
||||||
{
|
{
|
||||||
new MetadataOptions()
|
new MetadataOptions()
|
||||||
|
@ -381,19 +78,366 @@ namespace MediaBrowser.Model.Configuration
|
||||||
DisabledImageFetchers = new[] { "The Open Movie Database", "TheMovieDb" }
|
DisabledImageFetchers = new[] { "The Open Movie Database", "TheMovieDb" }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EnableSlowResponseWarning = true;
|
|
||||||
SlowResponseThresholdMs = 500;
|
|
||||||
CorsHosts = new[] { "*" };
|
|
||||||
KnownProxies = Array.Empty<string>();
|
|
||||||
ActivityLogRetentionDays = 30;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class PathSubstitution
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether to enable automatic port forwarding.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableUPnP { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether to enable prometheus metrics exporting.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableMetrics { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the public mapped port.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The public mapped port.</value>
|
||||||
|
public int PublicPort { get; set; } = DefaultHttpPort;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether the http port should be mapped as part of UPnP automatic port forwarding.
|
||||||
|
/// </summary>
|
||||||
|
public bool UPnPCreateHttpPortMap { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets client udp port range.
|
||||||
|
/// </summary>
|
||||||
|
public string UDPPortRange { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether IPV6 capability is enabled.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableIPV6 { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether IPV4 capability is enabled.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableIPV4 { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether detailed ssdp logs are sent to the console/log.
|
||||||
|
/// "Emby.Dlna": "Debug" must be set in logging.default.json for this property to work.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableSSDPTracing { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether an IP address is to be used to filter the detailed ssdp logs that are being sent to the console/log.
|
||||||
|
/// If the setting "Emby.Dlna": "Debug" msut be set in logging.default.json for this property to work.
|
||||||
|
/// </summary>
|
||||||
|
public string SSDPTracingFilter { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the number of times SSDP UDP messages are sent.
|
||||||
|
/// </summary>
|
||||||
|
public int UDPSendCount { get; set; } = 2;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the delay between each groups of SSDP messages (in ms).
|
||||||
|
/// </summary>
|
||||||
|
public int UDPSendDelay { get; set; } = 100;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether address names that match <see cref="VirtualInterfaceNames"/> should be Ignore for the purposes of binding.
|
||||||
|
/// </summary>
|
||||||
|
public bool IgnoreVirtualInterfaces { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating the interfaces that should be ignored. The list can be comma separated. <seealso cref="IgnoreVirtualInterfaces"/>.
|
||||||
|
/// </summary>
|
||||||
|
public string VirtualInterfaceNames { get; set; } = "vEthernet*";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the time (in seconds) between the pings of SSDP gateway monitor.
|
||||||
|
/// </summary>
|
||||||
|
public int GatewayMonitorPeriod { get; set; } = 60;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether multi-socket binding is available.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableMultiSocketBinding { get; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether all IPv6 interfaces should be treated as on the internal network.
|
||||||
|
/// Depending on the address range implemented ULA ranges might not be used.
|
||||||
|
/// </summary>
|
||||||
|
public bool TrustAllIP6Interfaces { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the ports that HDHomerun uses.
|
||||||
|
/// </summary>
|
||||||
|
public string HDHomerunPortRange { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets PublishedServerUri to advertise for specific subnets.
|
||||||
|
/// </summary>
|
||||||
|
public string[] PublishedServerUriBySubnet { get; set; } = Array.Empty<string>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether Autodiscovery tracing is enabled.
|
||||||
|
/// </summary>
|
||||||
|
public bool AutoDiscoveryTracing { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether Autodiscovery is enabled.
|
||||||
|
/// </summary>
|
||||||
|
public bool AutoDiscovery { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the public HTTPS port.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The public HTTPS port.</value>
|
||||||
|
public int PublicHttpsPort { get; set; } = DefaultHttpsPort;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the HTTP server port number.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The HTTP server port number.</value>
|
||||||
|
public int HttpServerPortNumber { get; set; } = DefaultHttpPort;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the HTTPS server port number.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The HTTPS server port number.</value>
|
||||||
|
public int HttpsPortNumber { get; set; } = DefaultHttpsPort;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether to use HTTPS.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// In order for HTTPS to be used, in addition to setting this to true, valid values must also be
|
||||||
|
/// provided for <see cref="CertificatePath"/> and <see cref="CertificatePassword"/>.
|
||||||
|
/// </remarks>
|
||||||
|
public bool EnableHttps { get; set; } = false;
|
||||||
|
|
||||||
|
public bool EnableNormalizedItemByNameIds { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the filesystem path of an X.509 certificate to use for SSL.
|
||||||
|
/// </summary>
|
||||||
|
public string CertificatePath { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the password required to access the X.509 certificate data in the file specified by <see cref="CertificatePath"/>.
|
||||||
|
/// </summary>
|
||||||
|
public string CertificatePassword { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether this instance is port authorized.
|
||||||
|
/// </summary>
|
||||||
|
/// <value><c>true</c> if this instance is port authorized; otherwise, <c>false</c>.</value>
|
||||||
|
public bool IsPortAuthorized { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether quick connect is available for use on this server.
|
||||||
|
/// </summary>
|
||||||
|
public bool QuickConnectAvailable { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether access outside of the LAN is permitted.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableRemoteAccess { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether [enable case sensitive item ids].
|
||||||
|
/// </summary>
|
||||||
|
/// <value><c>true</c> if [enable case sensitive item ids]; otherwise, <c>false</c>.</value>
|
||||||
|
public bool EnableCaseSensitiveItemIds { get; set; } = true;
|
||||||
|
|
||||||
|
public bool DisableLiveTvChannelUserDataName { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the metadata path.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The metadata path.</value>
|
||||||
|
public string MetadataPath { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string MetadataNetworkPath { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the preferred metadata language.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The preferred metadata language.</value>
|
||||||
|
public string PreferredMetadataLanguage { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the metadata country code.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The metadata country code.</value>
|
||||||
|
public string MetadataCountryCode { get; set; } = "US";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets characters to be replaced with a ' ' in strings to create a sort name.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The sort replace characters.</value>
|
||||||
|
public string[] SortReplaceCharacters { get; set; } = new[] { ".", "+", "%" };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets characters to be removed from strings to create a sort name.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The sort remove characters.</value>
|
||||||
|
public string[] SortRemoveCharacters { get; set; } = new[] { ",", "&", "-", "{", "}", "'" };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets words to be removed from strings to create a sort name.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The sort remove words.</value>
|
||||||
|
public string[] SortRemoveWords { get; set; } = new[] { "the", "a", "an" };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the minimum percentage of an item that must be played in order for playstate to be updated.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The min resume PCT.</value>
|
||||||
|
public int MinResumePct { get; set; } = 5;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the maximum percentage of an item that can be played while still saving playstate. If this percentage is crossed playstate will be reset to the beginning and the item will be marked watched.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The max resume PCT.</value>
|
||||||
|
public int MaxResumePct { get; set; } = 90;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the minimum duration that an item must have in order to be eligible for playstate updates..
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The min resume duration seconds.</value>
|
||||||
|
public int MinResumeDurationSeconds { get; set; } = 300;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the delay in seconds that we will wait after a file system change to try and discover what has been added/removed
|
||||||
|
/// Some delay is necessary with some items because their creation is not atomic. It involves the creation of several
|
||||||
|
/// different directories and files.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The file watcher delay.</value>
|
||||||
|
public int LibraryMonitorDelay { get; set; } = 60;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether [enable dashboard response caching].
|
||||||
|
/// Allows potential contributors without visual studio to modify production dashboard code and test changes.
|
||||||
|
/// </summary>
|
||||||
|
/// <value><c>true</c> if [enable dashboard response caching]; otherwise, <c>false</c>.</value>
|
||||||
|
public bool EnableDashboardResponseCaching { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the image saving convention.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The image saving convention.</value>
|
||||||
|
public ImageSavingConvention ImageSavingConvention { get; set; }
|
||||||
|
|
||||||
|
public MetadataOptions[] MetadataOptions { get; set; }
|
||||||
|
|
||||||
|
public bool SkipDeserializationForBasicTypes { get; set; } = true;
|
||||||
|
|
||||||
|
public string ServerName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string BaseUrl
|
||||||
{
|
{
|
||||||
public string From { get; set; }
|
get => _baseUrl;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
// Normalize the start of the string
|
||||||
|
if (string.IsNullOrWhiteSpace(value))
|
||||||
|
{
|
||||||
|
// If baseUrl is empty, set an empty prefix string
|
||||||
|
_baseUrl = string.Empty;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
public string To { get; set; }
|
if (value[0] != '/')
|
||||||
|
{
|
||||||
|
// If baseUrl was not configured with a leading slash, append one for consistency
|
||||||
|
value = "/" + value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normalize the end of the string
|
||||||
|
if (value[value.Length - 1] == '/')
|
||||||
|
{
|
||||||
|
// If baseUrl was configured with a trailing slash, remove it for consistency
|
||||||
|
value = value.Remove(value.Length - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
_baseUrl = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string UICulture { get; set; } = "en-US";
|
||||||
|
|
||||||
|
public bool SaveMetadataHidden { get; set; } = false;
|
||||||
|
|
||||||
|
public NameValuePair[] ContentTypes { get; set; } = Array.Empty<NameValuePair>();
|
||||||
|
|
||||||
|
public int RemoteClientBitrateLimit { get; set; } = 0;
|
||||||
|
|
||||||
|
public bool EnableFolderView { get; set; } = false;
|
||||||
|
|
||||||
|
public bool EnableGroupingIntoCollections { get; set; } = false;
|
||||||
|
|
||||||
|
public bool DisplaySpecialsWithinSeasons { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the subnets that are deemed to make up the LAN.
|
||||||
|
/// </summary>
|
||||||
|
public string[] LocalNetworkSubnets { get; set; } = Array.Empty<string>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the interface addresses which Jellyfin will bind to. If empty, all interfaces will be used.
|
||||||
|
/// </summary>
|
||||||
|
public string[] LocalNetworkAddresses { get; set; } = Array.Empty<string>();
|
||||||
|
|
||||||
|
public string[] CodecsUsed { get; set; } = Array.Empty<string>();
|
||||||
|
|
||||||
|
public List<RepositoryInfo> PluginRepositories { get; set; } = new List<RepositoryInfo>();
|
||||||
|
|
||||||
|
public bool EnableExternalContentInSuggestions { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether the server should force connections over HTTPS.
|
||||||
|
/// </summary>
|
||||||
|
public bool RequireHttps { get; set; } = false;
|
||||||
|
|
||||||
|
public bool EnableNewOmdbSupport { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the filter for remote IP connectivity. Used in conjuntion with <seealso cref="IsRemoteIPFilterBlacklist"/>.
|
||||||
|
/// </summary>
|
||||||
|
public string[] RemoteIPFilter { get; set; } = Array.Empty<string>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether <seealso cref="RemoteIPFilter"/> contains a blacklist or a whitelist. Default is a whitelist.
|
||||||
|
/// </summary>
|
||||||
|
public bool IsRemoteIPFilterBlacklist { get; set; } = false;
|
||||||
|
|
||||||
|
public int ImageExtractionTimeoutMs { get; set; } = 0;
|
||||||
|
|
||||||
|
public PathSubstitution[] PathSubstitutions { get; set; } = Array.Empty<PathSubstitution>();
|
||||||
|
|
||||||
|
public bool EnableSimpleArtistDetection { get; set; } = false;
|
||||||
|
|
||||||
|
public string[] UninstalledPlugins { get; set; } = Array.Empty<string>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether slow server responses should be logged as a warning.
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableSlowResponseWarning { get; set; } = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the threshold for the slow response time warning in ms.
|
||||||
|
/// </summary>
|
||||||
|
public long SlowResponseThresholdMs { get; set; } = 500;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the cors hosts.
|
||||||
|
/// </summary>
|
||||||
|
public string[] CorsHosts { get; set; } = new[] { "*" };
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the known proxies.
|
||||||
|
/// </summary>
|
||||||
|
public string[] KnownProxies { get; set; } = Array.Empty<string>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the number of days we should retain activity logs.
|
||||||
|
/// </summary>
|
||||||
|
public int? ActivityLogRetentionDays { get; set; } = 30;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 15
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 15.0.26730.3
|
VisualStudioVersion = 16.0.30503.244
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jellyfin.Server", "Jellyfin.Server\Jellyfin.Server.csproj", "{07E39F42-A2C6-4B32-AF8C-725F957A73FF}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jellyfin.Server", "Jellyfin.Server\Jellyfin.Server.csproj", "{07E39F42-A2C6-4B32-AF8C-725F957A73FF}"
|
||||||
EndProject
|
EndProject
|
||||||
|
@ -66,12 +66,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jellyfin.Data", "Jellyfin.D
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jellyfin.Server.Implementations", "Jellyfin.Server.Implementations\Jellyfin.Server.Implementations.csproj", "{DAE48069-6D86-4BA6-B148-D1D49B6DDA52}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jellyfin.Server.Implementations", "Jellyfin.Server.Implementations\Jellyfin.Server.Implementations.csproj", "{DAE48069-6D86-4BA6-B148-D1D49B6DDA52}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jellyfin.Networking", "Jellyfin.Networking\Jellyfin.Networking.csproj", "{0A3FCC4D-C714-4072-B90F-E374A15F9FF9}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{07E39F42-A2C6-4B32-AF8C-725F957A73FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{07E39F42-A2C6-4B32-AF8C-725F957A73FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{07E39F42-A2C6-4B32-AF8C-725F957A73FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{07E39F42-A2C6-4B32-AF8C-725F957A73FF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{17E1F4E6-8ABD-4FE5-9ECF-43D4B6087BA2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
@ -132,10 +138,6 @@ Global
|
||||||
{960295EE-4AF4-4440-A525-B4C295B01A61}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{960295EE-4AF4-4440-A525-B4C295B01A61}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{960295EE-4AF4-4440-A525-B4C295B01A61}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{960295EE-4AF4-4440-A525-B4C295B01A61}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{960295EE-4AF4-4440-A525-B4C295B01A61}.Release|Any CPU.Build.0 = Release|Any CPU
|
{960295EE-4AF4-4440-A525-B4C295B01A61}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{07E39F42-A2C6-4B32-AF8C-725F957A73FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{07E39F42-A2C6-4B32-AF8C-725F957A73FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{07E39F42-A2C6-4B32-AF8C-725F957A73FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{07E39F42-A2C6-4B32-AF8C-725F957A73FF}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{154872D9-6C12-4007-96E3-8F70A58386CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{154872D9-6C12-4007-96E3-8F70A58386CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{154872D9-6C12-4007-96E3-8F70A58386CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{154872D9-6C12-4007-96E3-8F70A58386CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{154872D9-6C12-4007-96E3-8F70A58386CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{154872D9-6C12-4007-96E3-8F70A58386CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
@ -176,10 +178,22 @@ Global
|
||||||
{DAE48069-6D86-4BA6-B148-D1D49B6DDA52}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{DAE48069-6D86-4BA6-B148-D1D49B6DDA52}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{DAE48069-6D86-4BA6-B148-D1D49B6DDA52}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{DAE48069-6D86-4BA6-B148-D1D49B6DDA52}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{DAE48069-6D86-4BA6-B148-D1D49B6DDA52}.Release|Any CPU.Build.0 = Release|Any CPU
|
{DAE48069-6D86-4BA6-B148-D1D49B6DDA52}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{0A3FCC4D-C714-4072-B90F-E374A15F9FF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{0A3FCC4D-C714-4072-B90F-E374A15F9FF9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{0A3FCC4D-C714-4072-B90F-E374A15F9FF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{0A3FCC4D-C714-4072-B90F-E374A15F9FF9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
GlobalSection(NestedProjects) = preSolution
|
||||||
|
{DF194677-DFD3-42AF-9F75-D44D5A416478} = {FBBB5129-006E-4AD7-BAD5-8B7CA1D10ED6}
|
||||||
|
{28464062-0939-4AA7-9F7B-24DDDA61A7C0} = {FBBB5129-006E-4AD7-BAD5-8B7CA1D10ED6}
|
||||||
|
{3998657B-1CCC-49DD-A19F-275DC8495F57} = {FBBB5129-006E-4AD7-BAD5-8B7CA1D10ED6}
|
||||||
|
{A2FD0A10-8F62-4F9D-B171-FFDF9F0AFA9D} = {FBBB5129-006E-4AD7-BAD5-8B7CA1D10ED6}
|
||||||
|
{2E3A1B4B-4225-4AAA-8B29-0181A84E7AEE} = {FBBB5129-006E-4AD7-BAD5-8B7CA1D10ED6}
|
||||||
|
{462584F7-5023-4019-9EAC-B98CA458C0A0} = {FBBB5129-006E-4AD7-BAD5-8B7CA1D10ED6}
|
||||||
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {3448830C-EBDC-426C-85CD-7BBB9651A7FE}
|
SolutionGuid = {3448830C-EBDC-426C-85CD-7BBB9651A7FE}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
@ -201,12 +215,4 @@ Global
|
||||||
$0.DotNetNamingPolicy = $2
|
$0.DotNetNamingPolicy = $2
|
||||||
$2.DirectoryNamespaceAssociation = PrefixedHierarchical
|
$2.DirectoryNamespaceAssociation = PrefixedHierarchical
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(NestedProjects) = preSolution
|
|
||||||
{DF194677-DFD3-42AF-9F75-D44D5A416478} = {FBBB5129-006E-4AD7-BAD5-8B7CA1D10ED6}
|
|
||||||
{28464062-0939-4AA7-9F7B-24DDDA61A7C0} = {FBBB5129-006E-4AD7-BAD5-8B7CA1D10ED6}
|
|
||||||
{3998657B-1CCC-49DD-A19F-275DC8495F57} = {FBBB5129-006E-4AD7-BAD5-8B7CA1D10ED6}
|
|
||||||
{A2FD0A10-8F62-4F9D-B171-FFDF9F0AFA9D} = {FBBB5129-006E-4AD7-BAD5-8B7CA1D10ED6}
|
|
||||||
{2E3A1B4B-4225-4AAA-8B29-0181A84E7AEE} = {FBBB5129-006E-4AD7-BAD5-8B7CA1D10ED6}
|
|
||||||
{462584F7-5023-4019-9EAC-B98CA458C0A0} = {FBBB5129-006E-4AD7-BAD5-8B7CA1D10ED6}
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
Loading…
Reference in New Issue
Block a user