mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-08 23:00:51 +02:00
Replace EnableHttps and SupportsHttps with ListenWithHttps and CanConnectWithHttps
This commit is contained in:
parent
5a816f0b22
commit
ca71ac72ab
|
@ -1408,7 +1408,7 @@ namespace Emby.Server.Implementations
|
||||||
InternalMetadataPath = ApplicationPaths.InternalMetadataPath,
|
InternalMetadataPath = ApplicationPaths.InternalMetadataPath,
|
||||||
CachePath = ApplicationPaths.CachePath,
|
CachePath = ApplicationPaths.CachePath,
|
||||||
HttpServerPortNumber = HttpPort,
|
HttpServerPortNumber = HttpPort,
|
||||||
SupportsHttps = SupportsHttps,
|
SupportsHttps = CanConnectWithHttps,
|
||||||
HttpsPortNumber = HttpsPort,
|
HttpsPortNumber = HttpsPort,
|
||||||
OperatingSystem = OperatingSystem.Id.ToString(),
|
OperatingSystem = OperatingSystem.Id.ToString(),
|
||||||
OperatingSystemDisplayName = OperatingSystem.Name,
|
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)
|
public async Task<string> GetLocalApiUrl(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
@ -1509,10 +1514,10 @@ namespace Emby.Server.Implementations
|
||||||
public string GetLocalApiUrl(ReadOnlySpan<char> host)
|
public string GetLocalApiUrl(ReadOnlySpan<char> host)
|
||||||
{
|
{
|
||||||
var url = new StringBuilder(64);
|
var url = new StringBuilder(64);
|
||||||
url.Append(EnableHttps ? "https://" : "http://")
|
url.Append(ListenWithHttps ? "https://" : "http://")
|
||||||
.Append(host)
|
.Append(host)
|
||||||
.Append(':')
|
.Append(':')
|
||||||
.Append(EnableHttps ? HttpsPort : HttpPort);
|
.Append(ListenWithHttps ? HttpsPort : HttpPort);
|
||||||
|
|
||||||
string baseUrl = ServerConfigurationManager.Configuration.BaseUrl;
|
string baseUrl = ServerConfigurationManager.Configuration.BaseUrl;
|
||||||
if (baseUrl.Length != 0)
|
if (baseUrl.Length != 0)
|
||||||
|
|
|
@ -62,7 +62,7 @@ namespace Emby.Server.Implementations.EntryPoints
|
||||||
.Append(config.PublicPort).Append(Separator)
|
.Append(config.PublicPort).Append(Separator)
|
||||||
.Append(_appHost.HttpPort).Append(Separator)
|
.Append(_appHost.HttpPort).Append(Separator)
|
||||||
.Append(_appHost.HttpsPort).Append(Separator)
|
.Append(_appHost.HttpsPort).Append(Separator)
|
||||||
.Append(_appHost.EnableHttps).Append(Separator)
|
.Append(_appHost.ListenWithHttps).Append(Separator)
|
||||||
.Append(config.EnableRemoteAccess).Append(Separator)
|
.Append(config.EnableRemoteAccess).Append(Separator)
|
||||||
.ToString();
|
.ToString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -422,7 +422,7 @@ namespace Emby.Server.Implementations.HttpServer
|
||||||
|
|
||||||
private bool ValidateSsl(string remoteIp, string urlString)
|
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)
|
if (urlString.IndexOf("https://", StringComparison.OrdinalIgnoreCase) == -1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -274,7 +274,7 @@ namespace Jellyfin.Server
|
||||||
_logger.LogInformation("Kestrel listening on {IpAddress}", address);
|
_logger.LogInformation("Kestrel listening on {IpAddress}", address);
|
||||||
options.Listen(address, appHost.HttpPort);
|
options.Listen(address, appHost.HttpPort);
|
||||||
|
|
||||||
if (appHost.EnableHttps && appHost.Certificate != null)
|
if (appHost.ListenWithHttps)
|
||||||
{
|
{
|
||||||
options.Listen(address, appHost.HttpsPort, listenOptions =>
|
options.Listen(address, appHost.HttpsPort, listenOptions =>
|
||||||
{
|
{
|
||||||
|
@ -289,7 +289,7 @@ namespace Jellyfin.Server
|
||||||
_logger.LogInformation("Kestrel listening on all interfaces");
|
_logger.LogInformation("Kestrel listening on all interfaces");
|
||||||
options.ListenAnyIP(appHost.HttpPort);
|
options.ListenAnyIP(appHost.HttpPort);
|
||||||
|
|
||||||
if (appHost.EnableHttps && appHost.Certificate != null)
|
if (appHost.ListenWithHttps)
|
||||||
{
|
{
|
||||||
options.ListenAnyIP(appHost.HttpsPort, listenOptions =>
|
options.ListenAnyIP(appHost.HttpsPort, listenOptions =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,10 +39,9 @@ namespace MediaBrowser.Controller
|
||||||
int HttpsPort { get; }
|
int HttpsPort { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether [supports HTTPS].
|
/// Gets a value indicating whether the server should listen on an HTTPS port.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value><c>true</c> if [supports HTTPS]; otherwise, <c>false</c>.</value>
|
bool ListenWithHttps { get; }
|
||||||
bool EnableHttps { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether this instance has update available.
|
/// Gets a value indicating whether this instance has update available.
|
||||||
|
|
|
@ -124,9 +124,9 @@ namespace MediaBrowser.Model.System
|
||||||
public int HttpServerPortNumber { get; set; }
|
public int HttpServerPortNumber { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
/// <value><c>true</c> if [enable HTTPS]; otherwise, <c>false</c>.</value>
|
|
||||||
public bool SupportsHttps { get; set; }
|
public bool SupportsHttps { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in a new issue