Replace EnableHttps and SupportsHttps with ListenWithHttps and CanConnectWithHttps

This commit is contained in:
Mark Monteiro 2020-04-02 17:45:04 -04:00
parent 5a816f0b22
commit ca71ac72ab
6 changed files with 18 additions and 14 deletions

View file

@ -1408,7 +1408,7 @@ namespace Emby.Server.Implementations
InternalMetadataPath = ApplicationPaths.InternalMetadataPath,
CachePath = ApplicationPaths.CachePath,
HttpServerPortNumber = HttpPort,
SupportsHttps = SupportsHttps,
SupportsHttps = CanConnectWithHttps,
HttpsPortNumber = HttpsPort,
OperatingSystem = OperatingSystem.Id.ToString(),
OperatingSystemDisplayName = OperatingSystem.Name,
@ -1446,9 +1446,14 @@ namespace Emby.Server.Implementations
};
}
public bool EnableHttps => SupportsHttps && ServerConfigurationManager.Configuration.EnableHttps;
/// <inheritdoc/>
public bool ListenWithHttps => Certificate != null && ServerConfigurationManager.Configuration.EnableHttps;
public bool SupportsHttps => Certificate != null || ServerConfigurationManager.Configuration.IsBehindProxy;
/// <summary>
/// Gets a value indicating whether a client can connect to the server over HTTPS, either directly or via a
/// reverse proxy.
/// </summary>
public bool CanConnectWithHttps => ListenWithHttps || ServerConfigurationManager.Configuration.IsBehindProxy;
public async Task<string> GetLocalApiUrl(CancellationToken cancellationToken)
{
@ -1509,10 +1514,10 @@ namespace Emby.Server.Implementations
public string GetLocalApiUrl(ReadOnlySpan<char> host)
{
var url = new StringBuilder(64);
url.Append(EnableHttps ? "https://" : "http://")
url.Append(ListenWithHttps ? "https://" : "http://")
.Append(host)
.Append(':')
.Append(EnableHttps ? HttpsPort : HttpPort);
.Append(ListenWithHttps ? HttpsPort : HttpPort);
string baseUrl = ServerConfigurationManager.Configuration.BaseUrl;
if (baseUrl.Length != 0)

View file

@ -62,7 +62,7 @@ namespace Emby.Server.Implementations.EntryPoints
.Append(config.PublicPort).Append(Separator)
.Append(_appHost.HttpPort).Append(Separator)
.Append(_appHost.HttpsPort).Append(Separator)
.Append(_appHost.EnableHttps).Append(Separator)
.Append(_appHost.ListenWithHttps).Append(Separator)
.Append(config.EnableRemoteAccess).Append(Separator)
.ToString();
}

View file

@ -422,7 +422,7 @@ namespace Emby.Server.Implementations.HttpServer
private bool ValidateSsl(string remoteIp, string urlString)
{
if (_config.Configuration.RequireHttps && _appHost.EnableHttps && !_config.Configuration.IsBehindProxy)
if (_config.Configuration.RequireHttps && _appHost.ListenWithHttps)
{
if (urlString.IndexOf("https://", StringComparison.OrdinalIgnoreCase) == -1)
{

View file

@ -274,7 +274,7 @@ namespace Jellyfin.Server
_logger.LogInformation("Kestrel listening on {IpAddress}", address);
options.Listen(address, appHost.HttpPort);
if (appHost.EnableHttps && appHost.Certificate != null)
if (appHost.ListenWithHttps)
{
options.Listen(address, appHost.HttpsPort, listenOptions =>
{
@ -289,7 +289,7 @@ namespace Jellyfin.Server
_logger.LogInformation("Kestrel listening on all interfaces");
options.ListenAnyIP(appHost.HttpPort);
if (appHost.EnableHttps && appHost.Certificate != null)
if (appHost.ListenWithHttps)
{
options.ListenAnyIP(appHost.HttpsPort, listenOptions =>
{

View file

@ -39,10 +39,9 @@ namespace MediaBrowser.Controller
int HttpsPort { get; }
/// <summary>
/// Gets a value indicating whether [supports HTTPS].
/// Gets a value indicating whether the server should listen on an HTTPS port.
/// </summary>
/// <value><c>true</c> if [supports HTTPS]; otherwise, <c>false</c>.</value>
bool EnableHttps { get; }
bool ListenWithHttps { get; }
/// <summary>
/// Gets a value indicating whether this instance has update available.

View file

@ -124,9 +124,9 @@ namespace MediaBrowser.Model.System
public int HttpServerPortNumber { get; set; }
/// <summary>
/// Gets or sets a value indicating whether [enable HTTPS].
/// Gets or sets a value indicating whether a client can connect to the server over HTTPS, either directly or
/// via a reverse proxy.
/// </summary>
/// <value><c>true</c> if [enable HTTPS]; otherwise, <c>false</c>.</value>
public bool SupportsHttps { get; set; }
/// <summary>