aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations/Connect/ConnectManager.cs')
-rw-r--r--MediaBrowser.Server.Implementations/Connect/ConnectManager.cs55
1 files changed, 42 insertions, 13 deletions
diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs
index 67d844543..e079aaf61 100644
--- a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs
+++ b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs
@@ -1,5 +1,4 @@
using MediaBrowser.Common.Configuration;
-using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
@@ -79,10 +78,13 @@ namespace MediaBrowser.Server.Implementations.Connect
if (!ip.StartsWith("http://", StringComparison.OrdinalIgnoreCase) &&
!ip.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
{
- ip = "http://" + ip;
+ ip = (_appHost.EnableHttps ? "https://" : "http://") + ip;
}
- return ip + ":" + _config.Configuration.PublicPort.ToString(CultureInfo.InvariantCulture);
+ ip += ":";
+ ip += _appHost.EnableHttps ? _config.Configuration.PublicHttpsPort.ToString(CultureInfo.InvariantCulture) : _config.Configuration.PublicPort.ToString(CultureInfo.InvariantCulture);
+
+ return ip;
}
return null;
@@ -91,7 +93,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,
@@ -113,6 +115,7 @@ namespace MediaBrowser.Server.Implementations.Connect
_providerManager = providerManager;
_userManager.UserConfigurationUpdated += _userManager_UserConfigurationUpdated;
+ _config.ConfigurationUpdated += _config_ConfigurationUpdated;
LoadCachedData();
}
@@ -150,7 +153,7 @@ namespace MediaBrowser.Server.Implementations.Connect
try
{
- var localAddress = _appHost.GetSystemInfo().LocalAddress;
+ var localAddress = _appHost.LocalApiUrl;
var hasExistingRecord = !string.IsNullOrWhiteSpace(ConnectServerId) &&
!string.IsNullOrWhiteSpace(ConnectAccessKey);
@@ -165,8 +168,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;
}
@@ -180,6 +182,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)
@@ -188,6 +192,27 @@ namespace MediaBrowser.Server.Implementations.Connect
}
}
+ private string _lastReportedIdentifier;
+ private string GetConnectReportingIdentifier()
+ {
+ return GetConnectReportingIdentifier(_appHost.LocalApiUrl, 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))
@@ -547,8 +572,8 @@ namespace MediaBrowser.Server.Implementations.Connect
Id = response.Id,
ImageUrl = response.UserImageUrl,
UserName = response.UserName,
- ExcludedLibraries = request.ExcludedLibraries,
- ExcludedChannels = request.ExcludedChannels,
+ EnabledLibraries = request.EnabledLibraries,
+ EnabledChannels = request.EnabledChannels,
EnableLiveTv = request.EnableLiveTv,
AccessToken = accessToken
});
@@ -808,9 +833,13 @@ namespace MediaBrowser.Server.Implementations.Connect
if (currentPendingEntry != null)
{
+ user.Policy.EnabledFolders = currentPendingEntry.EnabledLibraries;
+ user.Policy.EnableAllFolders = false;
+
+ user.Policy.EnabledChannels = currentPendingEntry.EnabledChannels;
+ user.Policy.EnableAllChannels = false;
+
user.Policy.EnableLiveTvAccess = currentPendingEntry.EnableLiveTv;
- user.Policy.BlockedMediaFolders = currentPendingEntry.ExcludedLibraries;
- user.Policy.BlockedChannels = currentPendingEntry.ExcludedChannels;
}
await _userManager.UpdateConfiguration(user.Id.ToString("N"), user.Configuration);
@@ -937,8 +966,8 @@ namespace MediaBrowser.Server.Implementations.Connect
{
ConnectUserId = i.ConnectUserId,
EnableLiveTv = i.EnableLiveTv,
- ExcludedChannels = i.ExcludedChannels,
- ExcludedLibraries = i.ExcludedLibraries,
+ EnabledChannels = i.EnabledChannels,
+ EnabledLibraries = i.EnabledLibraries,
Id = i.Id,
ImageUrl = i.ImageUrl,
UserName = i.UserName