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 687b94f08..02b428a44 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 c1ff35a82..f2aa329f2 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 d0f817df2..41444d256 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 e1165d086..96a31397b 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 b590f665f..646928124 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 dcc14c222..0a2a67316 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 ac44956cc..b78a66df5 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 29c0c9bb5..c62051994 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 4014e6334..3b7187a63 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 9ee51b356..fcd6c8694 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 2e26b1389..02296097b 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 2fb0eed18..2c94d2719 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 de5c1e4e3..b30d14497 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 a1091cacc..22fa1d64b 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 a3a05efd2..c7f72952f 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 f8afa5578..0b12cc535 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 b95a2aeac..1e35c1f33 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); }