From 91c395d0c6fb3c9cdde160258aeb681ddb82c874 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 25 Oct 2020 15:59:40 -0700 Subject: [PATCH] Fixed: Show TLS errors in UI when testing download clients Closes #4021 --- src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs | 6 +++++- .../Download/Clients/Deluge/DelugeProxy.cs | 5 +++++ .../DownloadStation/Proxies/DiskStationProxyBase.cs | 5 +++++ .../Clients/DownloadStation/TorrentDownloadStation.cs | 6 +++++- .../Clients/DownloadStation/UsenetDownloadStation.cs | 6 +++++- .../Download/Clients/Hadouken/Hadouken.cs | 10 +++++++++- .../Download/Clients/Hadouken/HadoukenProxy.cs | 5 +++++ .../Download/Clients/NzbVortex/NzbVortex.cs | 6 +++++- .../Download/Clients/NzbVortex/NzbVortexProxy.cs | 5 +++++ .../Download/Clients/QBittorrent/QBittorrent.cs | 6 +++++- .../Download/Clients/QBittorrent/QBittorrentProxyV2.cs | 5 +++++ .../Download/Clients/Transmission/TransmissionBase.cs | 9 +++++---- .../Download/Clients/Transmission/TransmissionProxy.cs | 5 +++++ .../Download/Clients/rTorrent/RTorrent.cs | 6 +++++- .../Download/Clients/rTorrent/RTorrentProxy.cs | 5 +++++ .../Download/Clients/uTorrent/UTorrent.cs | 6 +++++- .../Download/Clients/uTorrent/UTorrentProxy.cs | 5 +++++ 17 files changed, 89 insertions(+), 12 deletions(-) diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs index 5907680a2..91d421529 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs @@ -260,7 +260,11 @@ namespace NzbDrone.Core.Download.Clients.Deluge catch (Exception ex) { _logger.Error(ex, "Failed to test connection"); - return new NzbDroneValidationFailure(string.Empty, "Unknown exception: " + ex.Message); + + return new NzbDroneValidationFailure("Host", "Unable to connect to Deluge") + { + DetailedDescription = ex.Message + }; } return null; diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs index c34352fe6..abd6c8ba7 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs @@ -263,6 +263,11 @@ namespace NzbDrone.Core.Download.Clients.Deluge } catch (WebException ex) { + if (ex.Status == WebExceptionStatus.TrustFailure) + { + throw new DownloadClientUnavailableException("Unable to connect to Deluge, certificate validation failed.", ex); + } + throw new DownloadClientUnavailableException("Unable to connect to Deluge, please check your settings", ex); } } diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DiskStationProxyBase.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DiskStationProxyBase.cs index a88b03549..3c48d31d8 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DiskStationProxyBase.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DiskStationProxyBase.cs @@ -84,6 +84,11 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation.Proxies } catch (WebException ex) { + if (ex.Status == WebExceptionStatus.TrustFailure) + { + throw new DownloadClientUnavailableException("Unable to connect to Diskstation, certificate validation failed.", ex); + } + throw new DownloadClientUnavailableException("Unable to connect to Diskstation, please check your settings", ex); } diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs index 5840288bc..07ff72c42 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs @@ -379,7 +379,11 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation catch (Exception ex) { _logger.Error(ex, "Error testing Torrent Download Station"); - return new NzbDroneValidationFailure(string.Empty, $"Unknown exception: {ex.Message}"); + + return new NzbDroneValidationFailure("Host", "Unable to connect to Torrent Download Station") + { + DetailedDescription = ex.Message + }; } } diff --git a/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs b/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs index 14ebc67a4..ea2b4d8b8 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs @@ -278,7 +278,11 @@ namespace NzbDrone.Core.Download.Clients.DownloadStation catch (Exception ex) { _logger.Error(ex, "Error testing Torrent Download Station"); - return new NzbDroneValidationFailure(string.Empty, "Unknown exception: " + ex.Message); + + return new NzbDroneValidationFailure("Host", "Unable to connect to Usenet Download Station") + { + DetailedDescription = ex.Message + }; } } diff --git a/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs b/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs index 1fb789fc9..fa5ee215c 100644 --- a/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs +++ b/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs @@ -155,7 +155,8 @@ namespace NzbDrone.Core.Download.Clients.Hadouken if (version < new Version("5.1")) { - return new ValidationFailure(string.Empty, "Old Hadouken client with unsupported API, need 5.1 or higher"); + return new ValidationFailure(string.Empty, + "Old Hadouken client with unsupported API, need 5.1 or higher"); } } catch (DownloadClientAuthenticationException ex) @@ -164,6 +165,13 @@ namespace NzbDrone.Core.Download.Clients.Hadouken return new NzbDroneValidationFailure("Password", "Authentication failed"); } + catch (Exception ex) + { + return new NzbDroneValidationFailure("Host", "Unable to connect to Hadouken") + { + DetailedDescription = ex.Message + }; + } return null; } diff --git a/src/NzbDrone.Core/Download/Clients/Hadouken/HadoukenProxy.cs b/src/NzbDrone.Core/Download/Clients/Hadouken/HadoukenProxy.cs index faeddd5ee..b51479d10 100644 --- a/src/NzbDrone.Core/Download/Clients/Hadouken/HadoukenProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Hadouken/HadoukenProxy.cs @@ -90,6 +90,11 @@ namespace NzbDrone.Core.Download.Clients.Hadouken } catch (WebException ex) { + if (ex.Status == WebExceptionStatus.TrustFailure) + { + throw new DownloadClientUnavailableException("Unable to connect to Hadouken, certificate validation failed.", ex); + } + throw new DownloadClientUnavailableException("Unable to connect to Hadouken, please check your settings", ex); } diff --git a/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs b/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs index 7faeae119..769dc0e82 100644 --- a/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs +++ b/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs @@ -160,7 +160,11 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex catch (Exception ex) { _logger.Error(ex, "Unable to connect to NZBVortex"); - return new ValidationFailure("Host", "Unable to connect to NZBVortex"); + + return new NzbDroneValidationFailure("Host", "Unable to connect to NZBVortex") + { + DetailedDescription = ex.Message + }; } return null; diff --git a/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortexProxy.cs b/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortexProxy.cs index c5e8ef4c7..299fa7f9d 100644 --- a/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortexProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortexProxy.cs @@ -166,6 +166,11 @@ namespace NzbDrone.Core.Download.Clients.NzbVortex } catch (WebException ex) { + if (ex.Status == WebExceptionStatus.TrustFailure) + { + throw new DownloadClientUnavailableException("Unable to connect to NZBVortex, certificate validation failed.", ex); + } + throw new DownloadClientUnavailableException("Unable to connect to NZBVortex, please check your settings", ex); } } diff --git a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs index 18ad75777..be9d26225 100644 --- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs @@ -307,7 +307,11 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent catch (Exception ex) { _logger.Error(ex, "Unable to test qBittorrent"); - return new NzbDroneValidationFailure(String.Empty, "Unknown exception: " + ex.Message); + + return new NzbDroneValidationFailure("Host", "Unable to connect to qBittorrent") + { + DetailedDescription = ex.Message + }; } return null; diff --git a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentProxyV2.cs b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentProxyV2.cs index b6cb3bc49..cc046475d 100644 --- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentProxyV2.cs +++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentProxyV2.cs @@ -55,6 +55,11 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent } catch (WebException ex) { + if (ex.Status == WebExceptionStatus.TrustFailure) + { + throw new DownloadClientUnavailableException("Unable to connect to qBittorrent, certificate validation failed.", ex); + } + throw new DownloadClientException("Failed to connect to qBittorrent, check your settings.", ex); } } diff --git a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs index d375c6503..945276457 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs @@ -247,14 +247,15 @@ namespace NzbDrone.Core.Download.Clients.Transmission { _logger.Error(ex, ex.Message); - return new NzbDroneValidationFailure("Host", "Unable to connect") - { - DetailedDescription = "Please verify the hostname and port." - }; + return new NzbDroneValidationFailure("Host", "Unable to connect to Transmission") + { + DetailedDescription = ex.Message + }; } catch (Exception ex) { _logger.Error(ex, "Failed to test"); + return new NzbDroneValidationFailure(string.Empty, "Unknown exception: " + ex.Message); } } diff --git a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionProxy.cs b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionProxy.cs index 393ecf914..2d3aaa03a 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionProxy.cs @@ -305,6 +305,11 @@ namespace NzbDrone.Core.Download.Clients.Transmission } catch (WebException ex) { + if (ex.Status == WebExceptionStatus.TrustFailure) + { + throw new DownloadClientUnavailableException("Unable to connect to Transmission, certificate validation failed.", ex); + } + throw new DownloadClientUnavailableException("Unable to connect to Transmission, please check your settings", ex); } } diff --git a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs index d77f9d705..ddd41f435 100644 --- a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs @@ -200,7 +200,11 @@ namespace NzbDrone.Core.Download.Clients.RTorrent catch (Exception ex) { _logger.Error(ex, "Failed to test rTorrent"); - return new NzbDroneValidationFailure(string.Empty, "Unknown exception: " + ex.Message); + + return new NzbDroneValidationFailure("Host", "Unable to connect to rTorrent") + { + DetailedDescription = ex.Message + }; } return null; diff --git a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentProxy.cs b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentProxy.cs index b35063076..00b03ebf5 100644 --- a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentProxy.cs @@ -266,6 +266,11 @@ namespace NzbDrone.Core.Download.Clients.RTorrent } catch (WebException ex) { + if (ex.Status == WebExceptionStatus.TrustFailure) + { + throw new DownloadClientUnavailableException("Unable to connect to rTorrent, certificate validation failed.", ex); + } + throw new DownloadClientUnavailableException("Unable to connect to rTorrent, please check your settings", ex); } } diff --git a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs index 13f6cc6fd..429cec5dd 100644 --- a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs @@ -286,7 +286,11 @@ namespace NzbDrone.Core.Download.Clients.UTorrent catch (Exception ex) { _logger.Error(ex, "Failed to test uTorrent"); - return new NzbDroneValidationFailure(string.Empty, "Unknown exception: " + ex.Message); + + return new NzbDroneValidationFailure("Host", "Unable to connect to uTorrent") + { + DetailedDescription = ex.Message + }; } return null; diff --git a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentProxy.cs b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentProxy.cs index f8a76892b..84f64b8cc 100644 --- a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentProxy.cs @@ -228,6 +228,11 @@ namespace NzbDrone.Core.Download.Clients.UTorrent } catch (WebException ex) { + if (ex.Status == WebExceptionStatus.TrustFailure) + { + throw new DownloadClientUnavailableException("Unable to connect to uTorrent, certificate validation failed.", ex); + } + throw new DownloadClientException("Unable to connect to uTorrent, please check your settings", ex); }