DNLA over HTTP only

This commit is contained in:
Greenback 2020-12-07 22:06:28 +00:00
parent f2c2beca0f
commit d69f2d7d7f
4 changed files with 28 additions and 9 deletions

View File

@ -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.Main
private 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.Main
httpClientFactory,
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",

View File

@ -496,7 +496,7 @@ namespace Emby.Server.Implementations
{
var networkConfiguration = ServerConfigurationManager.GetNetworkConfiguration();
HttpPort = networkConfiguration.HttpServerPortNumber;
HttpsPort = networkConfiguration.HttpsPortNumber;
HttpsPort = networkConfiguration.HttpsServerPortNumber;
// Safeguard against invalid configuration
if (HttpPort == HttpsPort)
@ -714,7 +714,7 @@ namespace Emby.Server.Implementations
// Don't use an empty string password
var 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.Implementations
var networkConfiguration = ServerConfigurationManager.GetNetworkConfiguration();
// Need to restart if ports have changed
if (networkConfiguration.HttpServerPortNumber != HttpPort ||
networkConfiguration.HttpsPortNumber != HttpsPort)
networkConfiguration.HttpsServerPortNumber != HttpsPort)
{
if (ServerConfigurationManager.Configuration.IsPortAuthorized)
{

View File

@ -16,7 +16,7 @@ namespace Jellyfin.Networking.Configuration
public 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.Configuration
public 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;

View File

@ -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);
}
}