From c4e684fbd3cc84c7ef3d58a9b0c28ba91103eb7c Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Thu, 4 Dec 2014 17:54:37 -0800 Subject: [PATCH 1/4] update usages of nzbdrone.com to sonarr.tv --- CONTRIBUTING.md | 4 ++-- setup/nzbdrone.iss | 4 ++-- src/NzbDrone.Common/Cloud/CloudClient.cs | 2 +- src/NzbDrone.Common/NzbDrone.Common.csproj | 1 - .../Properties/SharedAssemblyInfo.cs | 2 +- .../Security/IgnoreCertErrorPolicy.cs | 6 ++--- src/NzbDrone.Common/Services.cs | 15 ------------- src/NzbDrone.Core.Test/FluentTest.cs | 22 +++++++++---------- .../Configuration/ConfigFileProvider.cs | 2 +- 9 files changed, 21 insertions(+), 37 deletions(-) delete mode 100644 src/NzbDrone.Common/Services.cs diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6b59ba19f..430fee47e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,7 +8,7 @@ Setup guides, FAQ, the more information we have on the wiki the better. ## Development ## ### Tools required ### -- Visual Studio 2012 +- Visual Studio 2013 - HTML/Javascript editor of choice (Sublime Text/Webstorm/etc) - npm (node package manager) - git @@ -22,7 +22,7 @@ Setup guides, FAQ, the more information we have on the wiki the better. 5. Compile in Visual Studio ### Contributing Code ### -- If you're adding a new, already requested feature, please comment on [Trello](http://trello.nzbdrone.com "Trello") so work is not duplicated (If you want to add something not already on there, please talk to us first) +- If you're adding a new, already requested feature, please comment on [Trello](https://trello.sonarr.tv "Trello") so work is not duplicated (If you want to add something not already on there, please talk to us first) - Rebase from NzbDrone's develop branch, don't merge - Make meaningful commits, or squash them - Feel free to make a pull request before work is complete, this will let us see where its at and make comments/suggest improvements diff --git a/setup/nzbdrone.iss b/setup/nzbdrone.iss index 49864bd4f..4d411c297 100644 --- a/setup/nzbdrone.iss +++ b/setup/nzbdrone.iss @@ -3,8 +3,8 @@ #define AppName "NzbDrone" #define AppPublisher "NzbDrone" -#define AppURL "http://www.nzbdrone.com/" -#define ForumsURL "http://forums.nzbdrone.com/" +#define AppURL "https://sonarr.tv/" +#define ForumsURL "https://forums.sonarr.tv/" #define AppExeName "NzbDrone.exe" #define BuildNumber "2.0" #define BuildNumber GetEnv('BUILD_NUMBER') diff --git a/src/NzbDrone.Common/Cloud/CloudClient.cs b/src/NzbDrone.Common/Cloud/CloudClient.cs index 928041f7e..b375ec2c1 100644 --- a/src/NzbDrone.Common/Cloud/CloudClient.cs +++ b/src/NzbDrone.Common/Cloud/CloudClient.cs @@ -9,7 +9,7 @@ namespace NzbDrone.Common.Cloud public class DroneServicesHttpRequestBuilder : HttpRequestBuilder, IDroneServicesRequestBuilder { - private const string ROOT_URL = "http://services.nzbdrone.com/v1/"; + private const string ROOT_URL = "https://services.sonarr.tv/v1/"; public DroneServicesHttpRequestBuilder() : base(ROOT_URL) diff --git a/src/NzbDrone.Common/NzbDrone.Common.csproj b/src/NzbDrone.Common/NzbDrone.Common.csproj index 08ff0968f..684bc5e29 100644 --- a/src/NzbDrone.Common/NzbDrone.Common.csproj +++ b/src/NzbDrone.Common/NzbDrone.Common.csproj @@ -180,7 +180,6 @@ - diff --git a/src/NzbDrone.Common/Properties/SharedAssemblyInfo.cs b/src/NzbDrone.Common/Properties/SharedAssemblyInfo.cs index bb74b7b20..9c8e66406 100644 --- a/src/NzbDrone.Common/Properties/SharedAssemblyInfo.cs +++ b/src/NzbDrone.Common/Properties/SharedAssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("www.nzbdrone.com")] +[assembly: AssemblyCompany("sonarr.tv")] [assembly: AssemblyProduct("NzbDrone")] [assembly: AssemblyCopyright("GNU General Public v3")] [assembly: AssemblyTrademark("")] diff --git a/src/NzbDrone.Common/Security/IgnoreCertErrorPolicy.cs b/src/NzbDrone.Common/Security/IgnoreCertErrorPolicy.cs index da68633b4..435ae0300 100644 --- a/src/NzbDrone.Common/Security/IgnoreCertErrorPolicy.cs +++ b/src/NzbDrone.Common/Security/IgnoreCertErrorPolicy.cs @@ -16,9 +16,9 @@ namespace NzbDrone.Common.Security { var request = sender as HttpWebRequest; - if (request != null && - request.Address.OriginalString.ContainsIgnoreCase("nzbdrone.com") && - sslpolicyerrors != SslPolicyErrors.None) + if (request != null && sslpolicyerrors != SslPolicyErrors.None && + (request.Address.OriginalString.ContainsIgnoreCase("nzbdrone.com") || request.Address.OriginalString.ContainsIgnoreCase("sonarr.tv")) + ) { return false; } diff --git a/src/NzbDrone.Common/Services.cs b/src/NzbDrone.Common/Services.cs deleted file mode 100644 index 0824c4735..000000000 --- a/src/NzbDrone.Common/Services.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace NzbDrone.Common -{ - public class Services - { - public static String RootUrl - { - get - { - return "http://services.nzbdrone.com"; - } - } - } -} diff --git a/src/NzbDrone.Core.Test/FluentTest.cs b/src/NzbDrone.Core.Test/FluentTest.cs index 66addf0c7..b418d2b3a 100644 --- a/src/NzbDrone.Core.Test/FluentTest.cs +++ b/src/NzbDrone.Core.Test/FluentTest.cs @@ -88,7 +88,7 @@ namespace NzbDrone.Core.Test public void ParentUriString_should_return_self_if_already_parent() { - var url = "http://www.nzbdrone.com"; + var url = "http://www.sonarr.tv"; var uri = new Uri(url); @@ -102,70 +102,70 @@ namespace NzbDrone.Core.Test public void ParentUriString_should_return_parent_url_when_path_is_passed() { - var url = "http://www.nzbdrone.com/test/"; + var url = "http://www.sonarr.tv/test/"; var uri = new Uri(url); var result = uri.ParentUriString(); //Resolve - result.Should().Be("http://www.nzbdrone.com"); + result.Should().Be("http://www.sonarr.tv"); } [Test] public void ParentUriString_should_return_parent_url_when_multiple_paths_are_passed() { - var url = "http://www.nzbdrone.com/test/test2"; + var url = "http://www.sonarr.tv/test/test2"; var uri = new Uri(url); var result = uri.ParentUriString(); //Resolve - result.Should().Be("http://www.nzbdrone.com"); + result.Should().Be("http://www.sonarr.tv"); } [Test] public void ParentUriString_should_return_parent_url_when_url_with_query_string_is_passed() { - var url = "http://www.nzbdrone.com/test.aspx?test=10"; + var url = "http://www.sonarr.tv/test.aspx?test=10"; var uri = new Uri(url); var result = uri.ParentUriString(); //Resolve - result.Should().Be("http://www.nzbdrone.com"); + result.Should().Be("http://www.sonarr.tv"); } [Test] public void ParentUriString_should_return_parent_url_when_url_with_path_and_query_strings_is_passed() { - var url = "http://www.nzbdrone.com/tester/test.aspx?test=10"; + var url = "http://www.sonarr.tv/tester/test.aspx?test=10"; var uri = new Uri(url); var result = uri.ParentUriString(); //Resolve - result.Should().Be("http://www.nzbdrone.com"); + result.Should().Be("http://www.sonarr.tv"); } [Test] public void ParentUriString_should_return_parent_url_when_url_with_query_strings_is_passed() { - var url = "http://www.nzbdrone.com/test.aspx?test=10&test2=5"; + var url = "http://www.sonarr.tv/test.aspx?test=10&test2=5"; var uri = new Uri(url); var result = uri.ParentUriString(); //Resolve - result.Should().Be("http://www.nzbdrone.com"); + result.Should().Be("http://www.sonarr.tv"); } [Test] diff --git a/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs index 0968d3fc1..925ae719e 100644 --- a/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs +++ b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs @@ -332,7 +332,7 @@ namespace NzbDrone.Core.Configuration catch (XmlException ex) { - throw new InvalidConfigFileException(_configFile + " is invalid, please see the http://wiki.nzbdrone.com for steps to resolve this issue.", ex); + throw new InvalidConfigFileException(_configFile + " is invalid, please see the http://wiki.sonarr.tv for steps to resolve this issue.", ex); } } From 664ec45360ca097253d9cf5ea9ef0e9e14dc99c7 Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Thu, 4 Dec 2014 22:28:46 -0800 Subject: [PATCH 2/4] log cert errors --- .../Security/IgnoreCertErrorPolicy.cs | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/NzbDrone.Common/Security/IgnoreCertErrorPolicy.cs b/src/NzbDrone.Common/Security/IgnoreCertErrorPolicy.cs index 435ae0300..e46221e24 100644 --- a/src/NzbDrone.Common/Security/IgnoreCertErrorPolicy.cs +++ b/src/NzbDrone.Common/Security/IgnoreCertErrorPolicy.cs @@ -1,24 +1,45 @@ using System.Net; using System.Net.Security; using System.Security.Cryptography.X509Certificates; -using NzbDrone.Common.Extensions; +using NLog; +using NzbDrone.Common.EnvironmentInfo; +using NzbDrone.Common.Instrumentation; namespace NzbDrone.Common.Security { public static class IgnoreCertErrorPolicy { + private static Logger _logger = NzbDroneLogger.GetLogger("IgnoreCertErrorPolicy"); + public static void Register() { - ServicePointManager.ServerCertificateValidationCallback = ValidationCallback; + ServicePointManager.ServerCertificateValidationCallback = ShouldByPassValidationError; } - private static bool ValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslpolicyerrors) + private static bool ShouldByPassValidationError(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslpolicyerrors) { var request = sender as HttpWebRequest; - if (request != null && sslpolicyerrors != SslPolicyErrors.None && - (request.Address.OriginalString.ContainsIgnoreCase("nzbdrone.com") || request.Address.OriginalString.ContainsIgnoreCase("sonarr.tv")) - ) + if (request == null) + { + return true; + } + + if (sslpolicyerrors == SslPolicyErrors.None) + { + return true; + } + + _logger.Warn("Request for {0} failed certificated validation. {1}", request.Address, sslpolicyerrors); + + if (OsInfo.IsMono) + { + return true; + } + + var host = request.Address.Host.ToLower(); + + if (host.EndsWith("nzbdrone.com") || host.EndsWith("sonarr.tv")) { return false; } From 3ce65eec08554437c61dbf67288072e4fd99eb95 Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Fri, 5 Dec 2014 14:05:30 -0800 Subject: [PATCH 3/4] Log HTTPS cert errors --- .../Security/IgnoreCertErrorPolicy.cs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/NzbDrone.Common/Security/IgnoreCertErrorPolicy.cs b/src/NzbDrone.Common/Security/IgnoreCertErrorPolicy.cs index e46221e24..537cf430b 100644 --- a/src/NzbDrone.Common/Security/IgnoreCertErrorPolicy.cs +++ b/src/NzbDrone.Common/Security/IgnoreCertErrorPolicy.cs @@ -2,14 +2,13 @@ using System.Net.Security; using System.Security.Cryptography.X509Certificates; using NLog; -using NzbDrone.Common.EnvironmentInfo; using NzbDrone.Common.Instrumentation; namespace NzbDrone.Common.Security { public static class IgnoreCertErrorPolicy { - private static Logger _logger = NzbDroneLogger.GetLogger("IgnoreCertErrorPolicy"); + private static readonly Logger Logger = NzbDroneLogger.GetLogger("IgnoreCertErrorPolicy"); public static void Register() { @@ -30,19 +29,7 @@ namespace NzbDrone.Common.Security return true; } - _logger.Warn("Request for {0} failed certificated validation. {1}", request.Address, sslpolicyerrors); - - if (OsInfo.IsMono) - { - return true; - } - - var host = request.Address.Host.ToLower(); - - if (host.EndsWith("nzbdrone.com") || host.EndsWith("sonarr.tv")) - { - return false; - } + Logger.Error("Request for {0} failed certificated validation. {1}", request.Address, sslpolicyerrors); return true; } From 71638ec77e7fcd0a36949fa380538ccc182c586c Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Fri, 5 Dec 2014 14:23:30 -0800 Subject: [PATCH 4/4] switched services to http --- src/NzbDrone.Common/Cloud/CloudClient.cs | 2 +- src/NzbDrone.Common/NzbDrone.Common.csproj | 2 +- ...eCertErrorPolicy.cs => X509CertificateValidationPolicy.cs} | 4 ++-- src/NzbDrone.Host/Bootstrap.cs | 2 +- src/NzbDrone.Host/Owin/OwinHostController.cs | 2 +- src/NzbDrone.Update/UpdateApp.cs | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) rename src/NzbDrone.Common/Security/{IgnoreCertErrorPolicy.cs => X509CertificateValidationPolicy.cs} (92%) diff --git a/src/NzbDrone.Common/Cloud/CloudClient.cs b/src/NzbDrone.Common/Cloud/CloudClient.cs index b375ec2c1..04c3b7b8a 100644 --- a/src/NzbDrone.Common/Cloud/CloudClient.cs +++ b/src/NzbDrone.Common/Cloud/CloudClient.cs @@ -9,7 +9,7 @@ namespace NzbDrone.Common.Cloud public class DroneServicesHttpRequestBuilder : HttpRequestBuilder, IDroneServicesRequestBuilder { - private const string ROOT_URL = "https://services.sonarr.tv/v1/"; + private const string ROOT_URL = "http://services.sonarr.tv/v1/"; public DroneServicesHttpRequestBuilder() : base(ROOT_URL) diff --git a/src/NzbDrone.Common/NzbDrone.Common.csproj b/src/NzbDrone.Common/NzbDrone.Common.csproj index 684bc5e29..4a5b2de4b 100644 --- a/src/NzbDrone.Common/NzbDrone.Common.csproj +++ b/src/NzbDrone.Common/NzbDrone.Common.csproj @@ -175,7 +175,7 @@ - + diff --git a/src/NzbDrone.Common/Security/IgnoreCertErrorPolicy.cs b/src/NzbDrone.Common/Security/X509CertificateValidationPolicy.cs similarity index 92% rename from src/NzbDrone.Common/Security/IgnoreCertErrorPolicy.cs rename to src/NzbDrone.Common/Security/X509CertificateValidationPolicy.cs index 537cf430b..606782101 100644 --- a/src/NzbDrone.Common/Security/IgnoreCertErrorPolicy.cs +++ b/src/NzbDrone.Common/Security/X509CertificateValidationPolicy.cs @@ -6,9 +6,9 @@ using NzbDrone.Common.Instrumentation; namespace NzbDrone.Common.Security { - public static class IgnoreCertErrorPolicy + public static class X509CertificateValidationPolicy { - private static readonly Logger Logger = NzbDroneLogger.GetLogger("IgnoreCertErrorPolicy"); + private static readonly Logger Logger = NzbDroneLogger.GetLogger(); public static void Register() { diff --git a/src/NzbDrone.Host/Bootstrap.cs b/src/NzbDrone.Host/Bootstrap.cs index 1f736d1f3..53331baa5 100644 --- a/src/NzbDrone.Host/Bootstrap.cs +++ b/src/NzbDrone.Host/Bootstrap.cs @@ -23,7 +23,7 @@ namespace NzbDrone.Host try { GlobalExceptionHandlers.Register(); - IgnoreCertErrorPolicy.Register(); + X509CertificateValidationPolicy.Register(); Logger.Info("Starting NzbDrone - {0} - Version {1}", Assembly.GetCallingAssembly().Location, Assembly.GetExecutingAssembly().GetName().Version); diff --git a/src/NzbDrone.Host/Owin/OwinHostController.cs b/src/NzbDrone.Host/Owin/OwinHostController.cs index bfa1e26d2..6db1a2477 100644 --- a/src/NzbDrone.Host/Owin/OwinHostController.cs +++ b/src/NzbDrone.Host/Owin/OwinHostController.cs @@ -34,7 +34,7 @@ namespace NzbDrone.Host.Owin public void StartServer() { - IgnoreCertErrorPolicy.Register(); + X509CertificateValidationPolicy.Register(); if (OsInfo.IsWindows) { diff --git a/src/NzbDrone.Update/UpdateApp.cs b/src/NzbDrone.Update/UpdateApp.cs index 7589ab53b..177e16517 100644 --- a/src/NzbDrone.Update/UpdateApp.cs +++ b/src/NzbDrone.Update/UpdateApp.cs @@ -36,7 +36,7 @@ namespace NzbDrone.Update Console.WriteLine("Starting NzbDrone Update Client"); - IgnoreCertErrorPolicy.Register(); + X509CertificateValidationPolicy.Register(); GlobalExceptionHandlers.Register();