mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-19 04:34:18 +01:00
rework hosting options
This commit is contained in:
@@ -78,7 +78,7 @@ namespace MediaBrowser.Server.Implementations.Connect
|
||||
if (!ip.StartsWith("http://", StringComparison.OrdinalIgnoreCase) &&
|
||||
!ip.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
ip = (_config.Configuration.UseHttps ? "https://" : "http://") + ip;
|
||||
ip = (_appHost.EnableHttps ? "https://" : "http://") + ip;
|
||||
}
|
||||
|
||||
return ip + ":" + _config.Configuration.PublicPort.ToString(CultureInfo.InvariantCulture);
|
||||
@@ -90,7 +90,7 @@ namespace MediaBrowser.Server.Implementations.Connect
|
||||
|
||||
private string XApplicationValue
|
||||
{
|
||||
get { return "Media Browser Server/" + _appHost.ApplicationVersion; }
|
||||
get { return _appHost.Name + "/" + _appHost.ApplicationVersion; }
|
||||
}
|
||||
|
||||
public ConnectManager(ILogger logger,
|
||||
@@ -112,6 +112,7 @@ namespace MediaBrowser.Server.Implementations.Connect
|
||||
_providerManager = providerManager;
|
||||
|
||||
_userManager.UserConfigurationUpdated += _userManager_UserConfigurationUpdated;
|
||||
_config.ConfigurationUpdated += _config_ConfigurationUpdated;
|
||||
|
||||
LoadCachedData();
|
||||
}
|
||||
@@ -164,8 +165,7 @@ namespace MediaBrowser.Server.Implementations.Connect
|
||||
}
|
||||
catch (HttpException ex)
|
||||
{
|
||||
if (!ex.StatusCode.HasValue ||
|
||||
!new[] { HttpStatusCode.NotFound, HttpStatusCode.Unauthorized }.Contains(ex.StatusCode.Value))
|
||||
if (!ex.StatusCode.HasValue || !new[] { HttpStatusCode.NotFound, HttpStatusCode.Unauthorized }.Contains(ex.StatusCode.Value))
|
||||
{
|
||||
throw;
|
||||
}
|
||||
@@ -179,6 +179,8 @@ namespace MediaBrowser.Server.Implementations.Connect
|
||||
await CreateServerRegistration(wanApiAddress, localAddress).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
_lastReportedIdentifier = GetConnectReportingIdentifier(localAddress, wanApiAddress);
|
||||
|
||||
await RefreshAuthorizationsInternal(true, CancellationToken.None).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -187,6 +189,27 @@ namespace MediaBrowser.Server.Implementations.Connect
|
||||
}
|
||||
}
|
||||
|
||||
private string _lastReportedIdentifier;
|
||||
private string GetConnectReportingIdentifier()
|
||||
{
|
||||
return GetConnectReportingIdentifier(_appHost.GetSystemInfo().LocalAddress, WanApiAddress);
|
||||
}
|
||||
private string GetConnectReportingIdentifier(string localAddress, string remoteAddress)
|
||||
{
|
||||
return (remoteAddress ?? string.Empty) + (localAddress ?? string.Empty);
|
||||
}
|
||||
|
||||
void _config_ConfigurationUpdated(object sender, EventArgs e)
|
||||
{
|
||||
// If info hasn't changed, don't report anything
|
||||
if (string.Equals(_lastReportedIdentifier, GetConnectReportingIdentifier(), StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateConnectInfo();
|
||||
}
|
||||
|
||||
private async Task CreateServerRegistration(string wanApiAddress, string localAddress)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(wanApiAddress))
|
||||
|
||||
Reference in New Issue
Block a user