diff options
Diffstat (limited to 'MediaBrowser.Common.Implementations/Security')
3 files changed, 25 insertions, 6 deletions
diff --git a/MediaBrowser.Common.Implementations/Security/MBLicenseFile.cs b/MediaBrowser.Common.Implementations/Security/MBLicenseFile.cs index 8f3225f4e..63381efcd 100644 --- a/MediaBrowser.Common.Implementations/Security/MBLicenseFile.cs +++ b/MediaBrowser.Common.Implementations/Security/MBLicenseFile.cs @@ -101,6 +101,10 @@ namespace MediaBrowser.Common.Implementations.Security { contents = File.ReadAllLines(licenseFile); } + catch (DirectoryNotFoundException) + { + (File.Create(licenseFile)).Close(); + } catch (FileNotFoundException) { (File.Create(licenseFile)).Close(); diff --git a/MediaBrowser.Common.Implementations/Security/MbAdmin.cs b/MediaBrowser.Common.Implementations/Security/MbAdmin.cs new file mode 100644 index 000000000..ab4a83257 --- /dev/null +++ b/MediaBrowser.Common.Implementations/Security/MbAdmin.cs @@ -0,0 +1,13 @@ + +namespace MediaBrowser.Common.Implementations.Security +{ + public class MbAdmin + { + public const string HttpUrl = "http://www.mb3admin.com/admin/"; + + /// <summary> + /// Leaving as http for now until we get it squared away + /// </summary> + public const string HttpsUrl = "http://www.mb3admin.com/admin/"; + } +} diff --git a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs index 4d693e40c..3e81e839f 100644 --- a/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs +++ b/MediaBrowser.Common.Implementations/Security/PluginSecurityManager.cs @@ -17,7 +17,7 @@ namespace MediaBrowser.Common.Implementations.Security /// </summary> public class PluginSecurityManager : ISecurityManager { - private const string MBValidateUrl = Constants.Constants.MbAdminUrl + "service/registration/validate"; + private const string MBValidateUrl = MbAdmin.HttpsUrl + "service/registration/validate"; /// <summary> /// The _is MB supporter @@ -160,13 +160,12 @@ namespace MediaBrowser.Common.Implementations.Security return new SupporterInfo(); } - var url = Constants.Constants.MbAdminUrl + "/service/supporter/retrieve?key=" + key; + var url = MbAdmin.HttpsUrl + "/service/supporter/retrieve?key=" + key; using (var stream = await _httpClient.Get(url, CancellationToken.None).ConfigureAwait(false)) { var response = _jsonSerializer.DeserializeFromStream<SuppporterInfoResponse>(stream); - var info = new SupporterInfo { Email = response.email, @@ -187,15 +186,18 @@ namespace MediaBrowser.Common.Implementations.Security string mb2Equivalent = null, string version = null) { + var lastChecked = LicenseFile.LastChecked(feature); + //check the reg file first to alleviate strain on the MB admin server - must actually check in every 30 days tho var reg = new RegRecord { - registered = LicenseFile.LastChecked(feature) > DateTime.UtcNow.AddDays(-3) + // Cache the result for up to a week + registered = lastChecked > DateTime.UtcNow.AddDays(-7) }; var success = reg.registered; - if (!reg.registered) + if (!(lastChecked > DateTime.UtcNow.AddDays(-1))) { var mac = _networkManager.GetMacAddress(); var data = new Dictionary<string, string> @@ -206,7 +208,7 @@ namespace MediaBrowser.Common.Implementations.Security { "systemid", _appHost.SystemId }, { "mb2equiv", mb2Equivalent }, { "ver", version }, - { "platform", Environment.OSVersion.VersionString }, + { "platform", _appHost.OperatingSystemDisplayName }, { "isservice", _appHost.IsRunningAsService.ToString().ToLower() } }; |
