From e912ef6a3eaf1d79f88fa921fda25ad56239aebf 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 --- src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs | 6 +++++- .../Download/Clients/Deluge/DelugeProxy.cs | 5 +++++ .../DownloadStation/Proxies/DiskStationProxyBase.cs | 5 +++++ .../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 +++++- .../Clients/QBittorrent/QBittorrentProxyV2.cs | 5 +++++ .../Clients/Transmission/TransmissionBase.cs | 12 +++++++----- .../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, 91 insertions(+), 13 deletions(-) diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs index 02ce7ad0e..638f70302 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs @@ -267,7 +267,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 f7d151c71..21f10b164 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs @@ -266,6 +266,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 4e84666ed..75bf4a82f 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DiskStationProxyBase.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/Proxies/DiskStationProxyBase.cs @@ -85,6 +85,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 998f68ddc..f458973c2 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs @@ -388,7 +388,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 b44469699..67846afa8 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs @@ -286,7 +286,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 d3f1a9b42..75e61654a 100644 --- a/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs +++ b/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs @@ -158,7 +158,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) @@ -167,6 +168,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 75917c8d9..42fcede8f 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 70c02d117..6892258d0 100644 --- a/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs +++ b/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs @@ -163,7 +163,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 a400b58d1..cf09d0c65 100644 --- a/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortexProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortexProxy.cs @@ -165,6 +165,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 219c230de..74ff49841 100644 --- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs @@ -381,7 +381,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 878d2be82..557e7c047 100644 --- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentProxyV2.cs +++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentProxyV2.cs @@ -54,6 +54,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 254c4e2d3..62222dff5 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs @@ -261,15 +261,17 @@ namespace NzbDrone.Core.Download.Clients.Transmission } catch (DownloadClientUnavailableException ex) { - _logger.Error(ex, "Unable to connect to transmission"); - return new NzbDroneValidationFailure("Host", "Unable to connect") - { - DetailedDescription = "Please verify the hostname and port." - }; + _logger.Error(ex, ex.Message); + + 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 945894c6c..6f5c7296b 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionProxy.cs @@ -308,6 +308,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 04b34278d..fb665a035 100644 --- a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs @@ -208,7 +208,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 39f4d2cc2..04380acf2 100644 --- a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentProxy.cs @@ -264,6 +264,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 47d0431aa..4cfdbc810 100644 --- a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs @@ -291,7 +291,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 b50e9b121..166b61cae 100644 --- a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentProxy.cs @@ -231,6 +231,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); }