From bab9b2c0400da00e351f2d759c496c1aeadd30de 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 +++++ .../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 | 8 ++++++-- .../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, 90 insertions(+), 13 deletions(-) diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs index 687b94f08e..02b428a445 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/Deluge.cs @@ -270,7 +270,11 @@ private ValidationFailure TestConnection() 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 c1ff35a825..f2aa329f21 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs @@ -267,6 +267,11 @@ private JsonRpcResponse ExecuteRequest(JsonRpcRequestBuilder r } 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 d0f817df2b..41444d256a 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 @@ private DiskStationResponse ProcessRequest(HttpRequestBuilder requestBuild } 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 e1165d0867..96a31397be 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/TorrentDownloadStation.cs @@ -389,7 +389,11 @@ protected ValidationFailure TestConnection() 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 b590f665fe..6469281246 100644 --- a/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs +++ b/src/NzbDrone.Core/Download/Clients/DownloadStation/UsenetDownloadStation.cs @@ -287,7 +287,11 @@ protected ValidationFailure TestConnection() 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 dcc14c2224..0a2a673162 100644 --- a/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs +++ b/src/NzbDrone.Core/Download/Clients/Hadouken/Hadouken.cs @@ -171,7 +171,8 @@ private ValidationFailure TestConnection() 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) @@ -180,6 +181,13 @@ private ValidationFailure TestConnection() 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 ac44956cc2..b78a66df5b 100644 --- a/src/NzbDrone.Core/Download/Clients/Hadouken/HadoukenProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Hadouken/HadoukenProxy.cs @@ -89,6 +89,11 @@ private T ProcessRequest(HadoukenSettings settings, string method, params obj } 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 29c0c9bb52..c620519945 100644 --- a/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs +++ b/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortex.cs @@ -173,8 +173,12 @@ private ValidationFailure TestConnection() } catch (Exception ex) { - _logger.Error(ex, ex.Message); - return new ValidationFailure("Host", "Unable to connect to NZBVortex"); + _logger.Error(ex, "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 4014e63346..3b7187a631 100644 --- a/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortexProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/NzbVortex/NzbVortexProxy.cs @@ -165,6 +165,11 @@ private T ProcessRequest(HttpRequestBuilder requestBuilder, bool requiresAuth } 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 9ee51b356b..fcd6c86941 100644 --- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs @@ -318,7 +318,11 @@ private ValidationFailure TestConnection() 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 2e26b13893..02296097bd 100644 --- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentProxyV2.cs +++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrentProxyV2.cs @@ -54,6 +54,11 @@ public bool IsApiSupported(QBittorrentSettings settings) } 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 2fb0eed188..2c94d27199 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionBase.cs @@ -273,14 +273,15 @@ protected ValidationFailure TestConnection() { _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 de5c1e4e33..b30d14497a 100644 --- a/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Transmission/TransmissionProxy.cs @@ -308,6 +308,11 @@ public TransmissionResponse ProcessRequest(string action, object arguments, Tran } 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 a1091caccb..22fa1d64b2 100644 --- a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrent.cs @@ -210,7 +210,11 @@ private ValidationFailure TestConnection() 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 a3a05efd20..c7f72952fa 100644 --- a/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/rTorrent/RTorrentProxy.cs @@ -267,6 +267,11 @@ private T ExecuteRequest(Func task) } 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 f8afa55789..0b12cc5351 100644 --- a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrent.cs @@ -293,7 +293,11 @@ private ValidationFailure TestConnection() 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 b95a2aeac1..1e35c1f33f 100644 --- a/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/uTorrent/UTorrentProxy.cs @@ -231,6 +231,11 @@ public UTorrentResponse ProcessRequest(HttpRequestBuilder requestBuilder, UTorre } 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); }