The Free Software Media System - Server Backend & API
DNLA over HTTP only
Greenbackd69f2d7d7fd4
diff --git a/Emby.Dlna/Main/DlnaEntryPoint.cs b/Emby.Dlna/Main/DlnaEntryPoint.csindex fb4454a343..ced56a7182 100644--- a/Emby.Dlna/Main/DlnaEntryPoint.cs+++ b/Emby.Dlna/Main/DlnaEntryPoint.cs@@ -9,6 +9,7 @@ using System.Threading;using System.Threading.Tasks;using Emby.Dlna.PlayTo;using Emby.Dlna.Ssdp;+using Jellyfin.Networking.Configuration;using Jellyfin.Networking.Manager;using MediaBrowser.Common.Configuration;using MediaBrowser.Common.Extensions;@@ -52,6 +53,8 @@ namespace Emby.Dlna.Mainprivate readonly ISocketFactory _socketFactory;private readonly INetworkManager _networkManager;private readonly object _syncLock = new object();+ private readonly NetworkConfiguration _netConfig;+ private readonly bool _disabled;private PlayToManager _manager;private SsdpDevicePublisher _publisher;@@ -122,6 +125,13 @@ namespace Emby.Dlna.MainhttpClientFactory,config);Current = this;++ _netConfig = config.GetConfiguration<NetworkConfiguration>("network");+ _disabled = appHost.ListenWithHttps && _netConfig.RequireHttps;+ if (_disabled)+ {+ _logger.LogError("The DLNA specification does not support HTTPS.");+ }}public static DlnaEntryPoint Current { get; private set; }@@ -136,6 +146,12 @@ namespace Emby.Dlna.Main{await ((DlnaManager)_dlnaManager).InitProfilesAsync().ConfigureAwait(false);+ if (_disabled)+ {+ // No use starting as dlna won't work, as we're running purely on HTTPS.+ return;+ }+ReloadComponents();_config.NamedConfigurationUpdated += OnNamedConfigurationUpdated;@@ -290,12 +306,15 @@ namespace Emby.Dlna.Main_logger.LogInformation("Registering publisher for {0} on {1}", fullService, address);- var uri = new Uri(_appHost.GetSmartApiUrl(address.Address) + descriptorUri);+ var uri = new UriBuilder(_appHost.GetSmartApiUrl(address.Address) + descriptorUri);+ // DLNA will only work over http, so we must reset to http:// : {port}+ uri.Scheme = "http://";+ uri.Port = _netConfig.PublicPort;var device = new SsdpRootDevice{CacheLifetime = TimeSpan.FromSeconds(1800), // How long SSDP clients can cache this info.- Location = uri, // Must point to the URL that serves your devices UPnP description document.+ Location = uri.Uri, // Must point to the URL that serves your devices UPnP description document.Address = address.Address,PrefixLength = address.PrefixLength,FriendlyName = "Jellyfin",diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.csindex d74ea03520..b6f63e5659 100644--- a/Emby.Server.Implementations/ApplicationHost.cs+++ b/Emby.Server.Implementations/ApplicationHost.cs@@ -496,7 +496,7 @@ namespace Emby.Server.Implementations{var networkConfiguration = ServerConfigurationManager.GetNetworkConfiguration();HttpPort = networkConfiguration.HttpServerPortNumber;- HttpsPort = networkConfiguration.HttpsPortNumber;+ HttpsPort = networkConfiguration.HttpsServerPortNumber;// Safeguard against invalid configurationif (HttpPort == HttpsPort)@@ -714,7 +714,7 @@ namespace Emby.Server.Implementations// Don't use an empty string passwordvar password = string.IsNullOrWhiteSpace(info.Password) ? null : info.Password;- var localCert = new X509Certificate2(certificateLocation, password);+ var localCert = new X509Certificate2(certificateLocation, password, X509KeyStorageFlags.UserKeySet);// localCert.PrivateKey = PrivateKey.CreateFromFile(pvk_file).RSA;if (!localCert.HasPrivateKey){@@ -919,7 +919,7 @@ namespace Emby.Server.Implementationsvar networkConfiguration = ServerConfigurationManager.GetNetworkConfiguration();// Need to restart if ports have changedif (networkConfiguration.HttpServerPortNumber != HttpPort ||- networkConfiguration.HttpsPortNumber != HttpsPort)+ networkConfiguration.HttpsServerPortNumber != HttpsPort){if (ServerConfigurationManager.Configuration.IsPortAuthorized){diff --git a/Jellyfin.Networking/Configuration/NetworkConfiguration.cs b/Jellyfin.Networking/Configuration/NetworkConfiguration.csindex df420f48a2..8db3d3a9c1 100644--- a/Jellyfin.Networking/Configuration/NetworkConfiguration.cs+++ b/Jellyfin.Networking/Configuration/NetworkConfiguration.cs@@ -16,7 +16,7 @@ namespace Jellyfin.Networking.Configurationpublic const int DefaultHttpPort = 8096;/// <summary>- /// The default value for <see cref="PublicHttpsPort"/> and <see cref="HttpsPortNumber"/>.+ /// The default value for <see cref="PublicHttpsPort"/> and <see cref="HttpsServerPortNumber"/>./// </summary>public const int DefaultHttpsPort = 8920;@@ -76,7 +76,7 @@ namespace Jellyfin.Networking.Configuration/// Gets or sets the HTTPS server port number./// </summary>/// <value>The HTTPS server port number.</value>- public int HttpsPortNumber { get; set; } = DefaultHttpsPort;+ public int HttpsServerPortNumber { get; set; } = DefaultHttpsPort;/// <summary>/// Gets or sets a value indicating whether to use HTTPS.@@ -88,7 +88,7 @@ namespace Jellyfin.Networking.Configurationpublic bool EnableHttps { get; set; }/// <summary>- /// Gets or sets the public mapped port.+ /// Gets or sets the Upublic mapped port./// </summary>/// <value>The public mapped port.</value>public int PublicPort { get; set; } = DefaultHttpPort;diff --git a/Jellyfin.Networking/Manager/NetworkManager.cs b/Jellyfin.Networking/Manager/NetworkManager.csindex 85da927fb4..a76ba49b6a 100644--- a/Jellyfin.Networking/Manager/NetworkManager.cs+++ b/Jellyfin.Networking/Manager/NetworkManager.cs@@ -784,7 +784,7 @@ namespace Jellyfin.Networking.Manager}else{- _logger.LogDebug("Invalid or unknown network {Token}.", token);+ _logger.LogDebug("Invalid or unknown object {Token}.", token);}}