From 00292953c327412643d84c6c95ce3f63ff28ed8a Mon Sep 17 00:00:00 2001 From: Rune Henriksen Date: Sun, 18 Feb 2018 00:18:44 +0100 Subject: [PATCH 1/5] added DNSName getter on Backend interface and added NotImplementedException methods on each backend class --- .../Backend/AlternativeFTP/AlternativeFTPBackend.cs | 2 ++ Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs | 2 ++ .../Library/Backend/AzureBlob/AzureBlobBackend.cs | 6 ++++-- Duplicati/Library/Backend/Backblaze/B2.cs | 2 ++ Duplicati/Library/Backend/Box/BoxBackend.cs | 2 ++ Duplicati/Library/Backend/CloudFiles/CloudFiles.cs | 2 ++ Duplicati/Library/Backend/Dropbox/Dropbox.cs | 2 ++ Duplicati/Library/Backend/FTP/FTPBackend.cs | 2 ++ Duplicati/Library/Backend/File/FileBackend.cs | 2 ++ .../Backend/GoogleServices/GoogleCloudStorage.cs | 2 ++ .../Library/Backend/GoogleServices/GoogleDrive.cs | 2 ++ Duplicati/Library/Backend/Jottacloud/Jottacloud.cs | 6 ++++-- Duplicati/Library/Backend/Mega/MegaBackend.cs | 2 ++ Duplicati/Library/Backend/OneDrive/OneDrive.cs | 4 +++- .../Library/Backend/OpenStack/OpenStackStorage.cs | 2 ++ Duplicati/Library/Backend/Rclone/Rclone.cs | 6 ++++-- Duplicati/Library/Backend/S3/S3Backend.cs | 2 ++ Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs | 2 ++ .../Library/Backend/SharePoint/SharePointBackend.cs | 10 ++++++---- Duplicati/Library/Backend/Sia/Sia.cs | 10 ++++++---- Duplicati/Library/Backend/TahoeLAFS/TahoeBackend.cs | 2 ++ Duplicati/Library/Backend/WEBDAV/WEBDAV.cs | 2 ++ Duplicati/Library/Interface/IBackend.cs | 5 +++++ 23 files changed, 64 insertions(+), 15 deletions(-) diff --git a/Duplicati/Library/Backend/AlternativeFTP/AlternativeFTPBackend.cs b/Duplicati/Library/Backend/AlternativeFTP/AlternativeFTPBackend.cs index b6543a6e1..873d69642 100644 --- a/Duplicati/Library/Backend/AlternativeFTP/AlternativeFTPBackend.cs +++ b/Duplicati/Library/Backend/AlternativeFTP/AlternativeFTPBackend.cs @@ -450,6 +450,8 @@ namespace Duplicati.Library.Backend.AlternativeFTP } } + public string DNSName => throw new NotImplementedException(); + private static System.IO.Stream StringToStream(string str) { var stream = new System.IO.MemoryStream(); diff --git a/Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs b/Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs index 520d9a06c..cbb8d6143 100644 --- a/Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs +++ b/Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs @@ -457,6 +457,8 @@ namespace Duplicati.Library.Backend.AmazonCloudDrive return Strings.AmzCD.Description; } } + + public string DNSName => throw new NotImplementedException(); #endregion #region IDisposable implementation public void Dispose() diff --git a/Duplicati/Library/Backend/AzureBlob/AzureBlobBackend.cs b/Duplicati/Library/Backend/AzureBlob/AzureBlobBackend.cs index d55eb17b0..2ec816b49 100644 --- a/Duplicati/Library/Backend/AzureBlob/AzureBlobBackend.cs +++ b/Duplicati/Library/Backend/AzureBlob/AzureBlobBackend.cs @@ -157,8 +157,10 @@ namespace Duplicati.Library.Backend.AzureBlob { return Strings.AzureBlobBackend.Description_v2; } - } - + } + + public string DNSName => throw new NotImplementedException(); + public void Test() { this.TestList(); diff --git a/Duplicati/Library/Backend/Backblaze/B2.cs b/Duplicati/Library/Backend/Backblaze/B2.cs index 35ec87393..046bd5207 100644 --- a/Duplicati/Library/Backend/Backblaze/B2.cs +++ b/Duplicati/Library/Backend/Backblaze/B2.cs @@ -422,6 +422,8 @@ namespace Duplicati.Library.Backend.Backblaze get { return Strings.B2.Description; } } + public string DNSName => throw new NotImplementedException(); + public void Dispose() { } diff --git a/Duplicati/Library/Backend/Box/BoxBackend.cs b/Duplicati/Library/Backend/Box/BoxBackend.cs index b20b259c7..217fdd72a 100644 --- a/Duplicati/Library/Backend/Box/BoxBackend.cs +++ b/Duplicati/Library/Backend/Box/BoxBackend.cs @@ -337,6 +337,8 @@ namespace Duplicati.Library.Backend.Box } } + public string DNSName => throw new NotImplementedException(); + #endregion #region IDisposable implementation diff --git a/Duplicati/Library/Backend/CloudFiles/CloudFiles.cs b/Duplicati/Library/Backend/CloudFiles/CloudFiles.cs index 82793def0..6c0b4c00b 100644 --- a/Duplicati/Library/Backend/CloudFiles/CloudFiles.cs +++ b/Duplicati/Library/Backend/CloudFiles/CloudFiles.cs @@ -290,6 +290,8 @@ namespace Duplicati.Library.Backend get { return true; } } + public string DNSName => throw new NotImplementedException(); + public void Get(string remotename, System.IO.Stream stream) { var req = CreateRequest("/" + remotename, ""); diff --git a/Duplicati/Library/Backend/Dropbox/Dropbox.cs b/Duplicati/Library/Backend/Dropbox/Dropbox.cs index 281395868..f94cb102f 100644 --- a/Duplicati/Library/Backend/Dropbox/Dropbox.cs +++ b/Duplicati/Library/Backend/Dropbox/Dropbox.cs @@ -136,6 +136,8 @@ namespace Duplicati.Library.Backend public string Description { get { return Strings.Dropbox.Description; } } + public string DNSName => throw new NotImplementedException(); + public void Test() { this.TestList(); diff --git a/Duplicati/Library/Backend/FTP/FTPBackend.cs b/Duplicati/Library/Backend/FTP/FTPBackend.cs index e09bd165e..7e4018890 100644 --- a/Duplicati/Library/Backend/FTP/FTPBackend.cs +++ b/Duplicati/Library/Backend/FTP/FTPBackend.cs @@ -355,6 +355,8 @@ namespace Duplicati.Library.Backend } } + public string DNSName => throw new NotImplementedException(); + public void Test() { this.TestList(); diff --git a/Duplicati/Library/Backend/File/FileBackend.cs b/Duplicati/Library/Backend/File/FileBackend.cs index 343234e13..86cc6d553 100644 --- a/Duplicati/Library/Backend/File/FileBackend.cs +++ b/Duplicati/Library/Backend/File/FileBackend.cs @@ -351,6 +351,8 @@ namespace Duplicati.Library.Backend } } + public string DNSName => throw new NotImplementedException(); + public void Rename(string oldname, string newname) { var source = GetRemoteName(oldname); diff --git a/Duplicati/Library/Backend/GoogleServices/GoogleCloudStorage.cs b/Duplicati/Library/Backend/GoogleServices/GoogleCloudStorage.cs index 1d8bc335c..e367d873c 100644 --- a/Duplicati/Library/Backend/GoogleServices/GoogleCloudStorage.cs +++ b/Duplicati/Library/Backend/GoogleServices/GoogleCloudStorage.cs @@ -260,6 +260,8 @@ namespace Duplicati.Library.Backend.GoogleCloudStorage { get { return Strings.GoogleCloudStorage.Description; } } + + public string DNSName => throw new NotImplementedException(); #endregion public void Put(string remotename, System.IO.Stream stream) diff --git a/Duplicati/Library/Backend/GoogleServices/GoogleDrive.cs b/Duplicati/Library/Backend/GoogleServices/GoogleDrive.cs index 29bf82b3e..b95be11a5 100644 --- a/Duplicati/Library/Backend/GoogleServices/GoogleDrive.cs +++ b/Duplicati/Library/Backend/GoogleServices/GoogleDrive.cs @@ -346,6 +346,8 @@ namespace Duplicati.Library.Backend.GoogleDrive } } } + + public string DNSName => throw new NotImplementedException(); #endregion #region IRenameEnabledBackend implementation diff --git a/Duplicati/Library/Backend/Jottacloud/Jottacloud.cs b/Duplicati/Library/Backend/Jottacloud/Jottacloud.cs index 46f797351..39a541ea7 100644 --- a/Duplicati/Library/Backend/Jottacloud/Jottacloud.cs +++ b/Duplicati/Library/Backend/Jottacloud/Jottacloud.cs @@ -316,8 +316,10 @@ namespace Duplicati.Library.Backend public bool SupportsStreaming { get { return true; } - } - + } + + public string DNSName => throw new NotImplementedException(); + public void Get(string remotename, System.IO.Stream stream) { // Downloading from Jottacloud: Will only succeed if the file has a completed revision, diff --git a/Duplicati/Library/Backend/Mega/MegaBackend.cs b/Duplicati/Library/Backend/Mega/MegaBackend.cs index e9261717f..51836e04e 100644 --- a/Duplicati/Library/Backend/Mega/MegaBackend.cs +++ b/Duplicati/Library/Backend/Mega/MegaBackend.cs @@ -260,6 +260,8 @@ namespace Duplicati.Library.Backend.Mega } } + public string DNSName => throw new NotImplementedException(); + #endregion #region IDisposable implementation diff --git a/Duplicati/Library/Backend/OneDrive/OneDrive.cs b/Duplicati/Library/Backend/OneDrive/OneDrive.cs index ff432b6b1..6c0da40a9 100644 --- a/Duplicati/Library/Backend/OneDrive/OneDrive.cs +++ b/Duplicati/Library/Backend/OneDrive/OneDrive.cs @@ -500,7 +500,9 @@ namespace Duplicati.Library.Backend } } - #endregion + public string DNSName => throw new NotImplementedException(); + + #endregion #region IStreamingBackend Members diff --git a/Duplicati/Library/Backend/OpenStack/OpenStackStorage.cs b/Duplicati/Library/Backend/OpenStack/OpenStackStorage.cs index ed4f88cba..4dd8e7f88 100644 --- a/Duplicati/Library/Backend/OpenStack/OpenStackStorage.cs +++ b/Duplicati/Library/Backend/OpenStack/OpenStackStorage.cs @@ -422,6 +422,8 @@ namespace Duplicati.Library.Backend.OpenStack return Strings.OpenStack.Description; } } + + public string DNSName => throw new NotImplementedException(); #endregion #region IDisposable implementation public void Dispose() diff --git a/Duplicati/Library/Backend/Rclone/Rclone.cs b/Duplicati/Library/Backend/Rclone/Rclone.cs index 6d7596948..d78f6df48 100644 --- a/Duplicati/Library/Backend/Rclone/Rclone.cs +++ b/Duplicati/Library/Backend/Rclone/Rclone.cs @@ -282,8 +282,10 @@ namespace Duplicati.Library.Backend { return Strings.Rclone.Description; } - } - + } + + public string DNSName => throw new NotImplementedException(); + public void Test() { this.TestList(); diff --git a/Duplicati/Library/Backend/S3/S3Backend.cs b/Duplicati/Library/Backend/S3/S3Backend.cs index 4d3e9ddf6..60d4632fe 100644 --- a/Duplicati/Library/Backend/S3/S3Backend.cs +++ b/Duplicati/Library/Backend/S3/S3Backend.cs @@ -474,6 +474,8 @@ namespace Duplicati.Library.Backend get { return m_wrapper; } } + public string DNSName => throw new NotImplementedException(); + private string GetFullKey(string name) { //AWS SDK encodes the filenames correctly diff --git a/Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs b/Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs index c91b0d6a5..75a18c700 100644 --- a/Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs +++ b/Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs @@ -368,5 +368,7 @@ namespace Duplicati.Library.Backend return m_con; } } + + public string DNSName => throw new NotImplementedException(); } } diff --git a/Duplicati/Library/Backend/SharePoint/SharePointBackend.cs b/Duplicati/Library/Backend/SharePoint/SharePointBackend.cs index 1b86574ae..2d99ca84d 100644 --- a/Duplicati/Library/Backend/SharePoint/SharePointBackend.cs +++ b/Duplicati/Library/Backend/SharePoint/SharePointBackend.cs @@ -113,12 +113,14 @@ namespace Duplicati.Library.Backend new CommandLineArgument("chunk-size", CommandLineArgument.ArgumentType.Size, Strings.SharePoint.DescriptionChunkSizeShort, Strings.SharePoint.DescriptionChunkSizeLong, "4mb"), }); } - } - + } + + public string DNSName => throw new NotImplementedException(); + #endregion - + #region [Constructors] - + public SharePointBackend() { } diff --git a/Duplicati/Library/Backend/Sia/Sia.cs b/Duplicati/Library/Backend/Sia/Sia.cs index 2839682d4..f00bd94f8 100644 --- a/Duplicati/Library/Backend/Sia/Sia.cs +++ b/Duplicati/Library/Backend/Sia/Sia.cs @@ -438,12 +438,14 @@ namespace Duplicati.Library.Backend.Sia { return Strings.Sia.Description; } - } - + } + + public string DNSName => throw new NotImplementedException(); + #endregion - + #region IDisposable Members - + public void Dispose() { diff --git a/Duplicati/Library/Backend/TahoeLAFS/TahoeBackend.cs b/Duplicati/Library/Backend/TahoeLAFS/TahoeBackend.cs index 274f56ffd..7689268a5 100644 --- a/Duplicati/Library/Backend/TahoeLAFS/TahoeBackend.cs +++ b/Duplicati/Library/Backend/TahoeLAFS/TahoeBackend.cs @@ -254,6 +254,8 @@ namespace Duplicati.Library.Backend get { return Strings.TahoeBackend.Description; } } + public string DNSName => throw new NotImplementedException(); + #endregion #region IDisposable Members diff --git a/Duplicati/Library/Backend/WEBDAV/WEBDAV.cs b/Duplicati/Library/Backend/WEBDAV/WEBDAV.cs index 7e203394b..0a1efd061 100644 --- a/Duplicati/Library/Backend/WEBDAV/WEBDAV.cs +++ b/Duplicati/Library/Backend/WEBDAV/WEBDAV.cs @@ -311,6 +311,8 @@ namespace Duplicati.Library.Backend get { return Strings.WEBDAV.Description; } } + public string DNSName => throw new NotImplementedException(); + public void Test() { this.List(); diff --git a/Duplicati/Library/Interface/IBackend.cs b/Duplicati/Library/Interface/IBackend.cs index 8281a9372..709006e54 100644 --- a/Duplicati/Library/Interface/IBackend.cs +++ b/Duplicati/Library/Interface/IBackend.cs @@ -81,6 +81,11 @@ namespace Duplicati.Library.Interface /// string Description { get; } + /// + /// The DNS name used to resolve the IP address for this backend + /// + string DNSName { get; } + /// /// The purpose of this method is to test the connection to the remote backend. /// If any problem is encountered, this method should throw an exception. From 7a58851224475feee29c74c5b1f665fb89fdba01 Mon Sep 17 00:00:00 2001 From: Rune Henriksen Date: Sun, 18 Feb 2018 00:21:48 +0100 Subject: [PATCH 2/5] Added DNSName method to comply with interface Fixed weird linebreak issues and added DNSName method to comply with Ibackend interface --- .../Library/Backend/HubiC/HubiCBackend.cs | 177 +++++++++++++++++- 1 file changed, 171 insertions(+), 6 deletions(-) diff --git a/Duplicati/Library/Backend/HubiC/HubiCBackend.cs b/Duplicati/Library/Backend/HubiC/HubiCBackend.cs index 1f8fb03c0..cd75a032a 100644 --- a/Duplicati/Library/Backend/HubiC/HubiCBackend.cs +++ b/Duplicati/Library/Backend/HubiC/HubiCBackend.cs @@ -1,4 +1,4 @@ -// Copyright (C) 2015, The Duplicati Team +// Copyright (C) 2015, The Duplicati Team // http://www.duplicati.com, info@duplicati.com // // This library is free software; you can redistribute it and/or modify @@ -14,13 +14,178 @@ // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using System; using Duplicati.Library.Interface; using Duplicati.Library; using Duplicati.Library.Backend.OpenStack; using System.Collections.Generic; +using System; +using Duplicati.Library.Interface; +using Duplicati.Library; +using Duplicati.Library.Backend.OpenStack; +using System.Collections.Generic; namespace Duplicati.Library.Backend.HubiC { public class HubiCBackend : IBackend, IStreamingBackend - { private const string AUTHID_OPTION = "authid"; private const string HUBIC_API_URL = "https://api.hubic.com/1.0/"; private const string HUBIC_API_CREDENTIAL_URL = HUBIC_API_URL + "account/credentials"; private OpenStackStorage m_openstack; private class HubiCAuthResponse { public string token { get; set; } public string endpoint { get; set; } public DateTime? expires { get; set;} } private class OpenStackHelper : OpenStackStorage { private OAuthHelper m_helper; private HubiCAuthResponse m_token; public OpenStackHelper(string authid, string url) : base(url, MockOptions()) { m_helper = new OAuthHelper(authid, "hubic") { AutoAuthHeader = true }; } private static Dictionary MockOptions() { var res = new Dictionary(); res["openstack-authuri"] = "invalid://dont-use"; res["openstack-apikey"] = "invalid"; res["auth-username"] = "invalid"; return res; } private HubiCAuthResponse AuthToken { get { if (m_token == null || (m_token.expires != null && (m_token.expires.Value - DateTime.UtcNow).TotalSeconds < 30)) m_token = m_helper.ReadJSONResponse(HUBIC_API_CREDENTIAL_URL); return m_token; } } protected override string AccessToken { get { return AuthToken.token; } } protected override string SimpleStorageEndPoint { get { return AuthToken.endpoint; } } } public HubiCBackend() - { } - public HubiCBackend(string url, Dictionary options) { string authid = null; if (options.ContainsKey(AUTHID_OPTION)) authid = options[AUTHID_OPTION]; m_openstack = new OpenStackHelper(authid, url); } #region IStreamingBackend implementation public void Put(string remotename, System.IO.Stream stream) { m_openstack.Put(remotename, stream); } public void Get(string remotename, System.IO.Stream stream) { m_openstack.Get(remotename, stream); } #endregion #region IBackend implementation public IEnumerable List() { return m_openstack.List(); } public void Put(string remotename, string filename) { m_openstack.Put(remotename, filename); } public void Get(string remotename, string filename) { m_openstack.Get(remotename, filename); } public void Delete(string remotename) { m_openstack.Delete(remotename); } public void Test() { m_openstack.Test(); } public void CreateFolder() { m_openstack.CreateFolder(); } public string DisplayName { get { return Strings.HubiC.DisplayName; } } public string ProtocolKey { get { return "hubic"; } } public System.Collections.Generic.IList SupportedCommands { get { return new List(new ICommandLineArgument[] { new CommandLineArgument(AUTHID_OPTION, CommandLineArgument.ArgumentType.Password, Strings.HubiC.AuthidShort, Strings.HubiC.AuthidLong(OAuthHelper.OAUTH_LOGIN_URL("hubic"))), }); } } public string Description { get { return Strings.HubiC.Description; } } #endregion #region IDisposable implementation public void Dispose() { if (m_openstack != null) { m_openstack.Dispose(); m_openstack = null; } } #endregion } -} + { + private const string AUTHID_OPTION = "authid"; + private const string HUBIC_API_URL = "https://api.hubic.com/1.0/"; + private const string HUBIC_API_CREDENTIAL_URL = HUBIC_API_URL + "account/credentials"; + private OpenStackStorage m_openstack; + + private class HubiCAuthResponse + { + public string token { get; set; } + public string endpoint { get; set; } + public DateTime? expires { get; set;} + } + + private class OpenStackHelper : OpenStackStorage + { + private OAuthHelper m_helper; + private HubiCAuthResponse m_token; + + public OpenStackHelper(string authid, string url) + : base(url, MockOptions()) + { + m_helper = new OAuthHelper(authid, "hubic") { AutoAuthHeader = true }; + } + + private static Dictionary MockOptions() + { + var res = new Dictionary(); + res["openstack-authuri"] = "invalid://dont-use"; + res["openstack-apikey"] = "invalid"; + res["auth-username"] = "invalid"; + + return res; + } + + private HubiCAuthResponse AuthToken + { + get + { + if (m_token == null || (m_token.expires != null && (m_token.expires.Value - DateTime.UtcNow).TotalSeconds < 30)) + m_token = m_helper.ReadJSONResponse(HUBIC_API_CREDENTIAL_URL); + return m_token; + } + } + + protected override string AccessToken + { + get { return AuthToken.token; } + } + + protected override string SimpleStorageEndPoint + { + get { return AuthToken.endpoint; } + } + } + + public HubiCBackend() + { + } + + public HubiCBackend(string url, Dictionary options) + { + string authid = null; + if (options.ContainsKey(AUTHID_OPTION)) + authid = options[AUTHID_OPTION]; + + m_openstack = new OpenStackHelper(authid, url); + } + + #region IStreamingBackend implementation + + public void Put(string remotename, System.IO.Stream stream) + { + m_openstack.Put(remotename, stream); + } + + public void Get(string remotename, System.IO.Stream stream) + { + m_openstack.Get(remotename, stream); + } + + #endregion + + #region IBackend implementation + + public IEnumerable List() + { + return m_openstack.List(); + } + + public void Put(string remotename, string filename) + { + m_openstack.Put(remotename, filename); + } + + public void Get(string remotename, string filename) + { + m_openstack.Get(remotename, filename); + } + + public void Delete(string remotename) + { + m_openstack.Delete(remotename); + } + + public void Test() + { + m_openstack.Test(); + } + + public void CreateFolder() + { + m_openstack.CreateFolder(); + } + + public string DisplayName + { + get + { + return Strings.HubiC.DisplayName; + } + } + + public string ProtocolKey + { + get + { + return "hubic"; + } + } + + public System.Collections.Generic.IList SupportedCommands + { + get { + return new List(new ICommandLineArgument[] { + new CommandLineArgument(AUTHID_OPTION, CommandLineArgument.ArgumentType.Password, Strings.HubiC.AuthidShort, Strings.HubiC.AuthidLong(OAuthHelper.OAUTH_LOGIN_URL("hubic"))), + }); + } + } + + public string Description + { + get + { + return Strings.HubiC.Description; + } + } + + public string DNSName => throw new NotImplementedException(); + + #endregion + + #region IDisposable implementation + + public void Dispose() + { + if (m_openstack != null) + { + m_openstack.Dispose(); + m_openstack = null; + } + } + + #endregion + } +} From ecc586c0f8b28c8fcfeffd5338a637f482373e57 Mon Sep 17 00:00:00 2001 From: Rune Henriksen Date: Sun, 18 Feb 2018 01:30:05 +0100 Subject: [PATCH 3/5] added code to attempt to resolve DNS issues on connection failure and implemented DNSName method in WebDav backend handler --- Duplicati/Library/Backend/WEBDAV/WEBDAV.cs | 9 ++++++++- Duplicati/Library/Main/BackendManager.cs | 13 +++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Duplicati/Library/Backend/WEBDAV/WEBDAV.cs b/Duplicati/Library/Backend/WEBDAV/WEBDAV.cs index 0a1efd061..2e5c480ad 100644 --- a/Duplicati/Library/Backend/WEBDAV/WEBDAV.cs +++ b/Duplicati/Library/Backend/WEBDAV/WEBDAV.cs @@ -33,6 +33,7 @@ namespace Duplicati.Library.Backend private string m_reverseProtocolUrl; private string m_rawurl; private string m_rawurlPort; + private string m_dnsName; private bool m_useIntegratedAuthentication = false; private bool m_forceDigestAuthentication = false; private bool m_useSSL = false; @@ -61,6 +62,7 @@ namespace Duplicati.Library.Backend { var u = new Utility.Uri(url); u.RequireHost(); + m_dnsName = u.Host; if (!string.IsNullOrEmpty(u.Username)) { @@ -311,7 +313,12 @@ namespace Duplicati.Library.Backend get { return Strings.WEBDAV.Description; } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return m_dnsName; } + } + + //=> throw new NotImplementedException(); public void Test() { diff --git a/Duplicati/Library/Main/BackendManager.cs b/Duplicati/Library/Main/BackendManager.cs index 15969fbcd..159318dc7 100644 --- a/Duplicati/Library/Main/BackendManager.cs +++ b/Duplicati/Library/Main/BackendManager.cs @@ -519,6 +519,19 @@ namespace Duplicati.Library.Main throw; } + // Refresh DNS name if we fail to connect in order to prevent issues with incorrect DNS entries + if (ex is System.Net.WebException) + { + try + { + System.Net.Dns.GetHostEntry(m_backend.DNSName); + } + catch + { + Logging.Log.WriteMessage("Failed to resolve IP for " + m_backend.DNSName, Logging.LogMessageType.Warning); + } + } + m_statwriter.SendEvent(item.BackendActionType, retries < m_numberofretries ? BackendEventType.Retrying : BackendEventType.Failed, item.RemoteFilename, item.Size); bool recovered = false; From 0ba28da948f7176e524e2e4335c342c60be635cd Mon Sep 17 00:00:00 2001 From: Rune Henriksen Date: Tue, 20 Feb 2018 20:34:09 +0100 Subject: [PATCH 4/5] Added if statement to specifically verify that it's a NameResolutionFailure and not just a WebException --- Duplicati/Library/Main/BackendManager.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Duplicati/Library/Main/BackendManager.cs b/Duplicati/Library/Main/BackendManager.cs index 159318dc7..648aeea98 100644 --- a/Duplicati/Library/Main/BackendManager.cs +++ b/Duplicati/Library/Main/BackendManager.cs @@ -519,16 +519,19 @@ namespace Duplicati.Library.Main throw; } - // Refresh DNS name if we fail to connect in order to prevent issues with incorrect DNS entries if (ex is System.Net.WebException) { - try + // Refresh DNS name if we fail to connect in order to prevent issues with incorrect DNS entries + if (((System.Net.WebException)ex).Status == System.Net.WebExceptionStatus.NameResolutionFailure) { - System.Net.Dns.GetHostEntry(m_backend.DNSName); - } - catch - { - Logging.Log.WriteMessage("Failed to resolve IP for " + m_backend.DNSName, Logging.LogMessageType.Warning); + try + { + System.Net.Dns.GetHostEntry(m_backend.DNSName); + } + catch + { + Logging.Log.WriteMessage("Failed to resolve IP for " + m_backend.DNSName, Logging.LogMessageType.Warning); + } } } From fc77b476fc43ff86acac621a794f60141014cae5 Mon Sep 17 00:00:00 2001 From: Rune Henriksen Date: Wed, 21 Feb 2018 22:38:01 +0100 Subject: [PATCH 5/5] changed from NYI to null returns. Added check to skip DNS check if no DNSName is provided --- .../Library/Backend/AlternativeFTP/AlternativeFTPBackend.cs | 5 ++++- Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs | 6 +++++- Duplicati/Library/Backend/AzureBlob/AzureBlobBackend.cs | 5 ++++- Duplicati/Library/Backend/Backblaze/B2.cs | 5 ++++- Duplicati/Library/Backend/Box/BoxBackend.cs | 5 ++++- Duplicati/Library/Backend/CloudFiles/CloudFiles.cs | 5 ++++- Duplicati/Library/Backend/Dropbox/Dropbox.cs | 5 ++++- Duplicati/Library/Backend/FTP/FTPBackend.cs | 5 ++++- Duplicati/Library/Backend/File/FileBackend.cs | 5 ++++- .../Library/Backend/GoogleServices/GoogleCloudStorage.cs | 6 +++++- Duplicati/Library/Backend/GoogleServices/GoogleDrive.cs | 6 +++++- Duplicati/Library/Backend/HubiC/HubiCBackend.cs | 5 ++++- Duplicati/Library/Backend/Jottacloud/Jottacloud.cs | 5 ++++- Duplicati/Library/Backend/Mega/MegaBackend.cs | 5 ++++- Duplicati/Library/Backend/OneDrive/OneDrive.cs | 5 ++++- Duplicati/Library/Backend/OpenStack/OpenStackStorage.cs | 6 +++++- Duplicati/Library/Backend/Rclone/Rclone.cs | 5 ++++- Duplicati/Library/Backend/S3/S3Backend.cs | 5 ++++- Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs | 5 ++++- Duplicati/Library/Backend/SharePoint/SharePointBackend.cs | 5 ++++- Duplicati/Library/Backend/Sia/Sia.cs | 5 ++++- Duplicati/Library/Backend/TahoeLAFS/TahoeBackend.cs | 5 ++++- Duplicati/Library/Backend/WEBDAV/WEBDAV.cs | 2 -- Duplicati/Library/Main/BackendManager.cs | 4 ++-- 24 files changed, 94 insertions(+), 26 deletions(-) diff --git a/Duplicati/Library/Backend/AlternativeFTP/AlternativeFTPBackend.cs b/Duplicati/Library/Backend/AlternativeFTP/AlternativeFTPBackend.cs index 873d69642..588b624be 100644 --- a/Duplicati/Library/Backend/AlternativeFTP/AlternativeFTPBackend.cs +++ b/Duplicati/Library/Backend/AlternativeFTP/AlternativeFTPBackend.cs @@ -450,7 +450,10 @@ namespace Duplicati.Library.Backend.AlternativeFTP } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return null; } + } private static System.IO.Stream StringToStream(string str) { diff --git a/Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs b/Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs index cbb8d6143..099eed1b3 100644 --- a/Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs +++ b/Duplicati/Library/Backend/AmazonCloudDrive/AmzCD.cs @@ -458,7 +458,11 @@ namespace Duplicati.Library.Backend.AmazonCloudDrive } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return null; } + } + #endregion #region IDisposable implementation public void Dispose() diff --git a/Duplicati/Library/Backend/AzureBlob/AzureBlobBackend.cs b/Duplicati/Library/Backend/AzureBlob/AzureBlobBackend.cs index 2ec816b49..a6cb8af56 100644 --- a/Duplicati/Library/Backend/AzureBlob/AzureBlobBackend.cs +++ b/Duplicati/Library/Backend/AzureBlob/AzureBlobBackend.cs @@ -159,7 +159,10 @@ namespace Duplicati.Library.Backend.AzureBlob } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return null; } + } public void Test() { diff --git a/Duplicati/Library/Backend/Backblaze/B2.cs b/Duplicati/Library/Backend/Backblaze/B2.cs index 046bd5207..a93afb06d 100644 --- a/Duplicati/Library/Backend/Backblaze/B2.cs +++ b/Duplicati/Library/Backend/Backblaze/B2.cs @@ -422,7 +422,10 @@ namespace Duplicati.Library.Backend.Backblaze get { return Strings.B2.Description; } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return null; } + } public void Dispose() { diff --git a/Duplicati/Library/Backend/Box/BoxBackend.cs b/Duplicati/Library/Backend/Box/BoxBackend.cs index 217fdd72a..71d67227c 100644 --- a/Duplicati/Library/Backend/Box/BoxBackend.cs +++ b/Duplicati/Library/Backend/Box/BoxBackend.cs @@ -337,7 +337,10 @@ namespace Duplicati.Library.Backend.Box } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return null; } + } #endregion diff --git a/Duplicati/Library/Backend/CloudFiles/CloudFiles.cs b/Duplicati/Library/Backend/CloudFiles/CloudFiles.cs index 6c0b4c00b..62a0cdcc1 100644 --- a/Duplicati/Library/Backend/CloudFiles/CloudFiles.cs +++ b/Duplicati/Library/Backend/CloudFiles/CloudFiles.cs @@ -290,7 +290,10 @@ namespace Duplicati.Library.Backend get { return true; } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return null; } + } public void Get(string remotename, System.IO.Stream stream) { diff --git a/Duplicati/Library/Backend/Dropbox/Dropbox.cs b/Duplicati/Library/Backend/Dropbox/Dropbox.cs index f94cb102f..c98ef226d 100644 --- a/Duplicati/Library/Backend/Dropbox/Dropbox.cs +++ b/Duplicati/Library/Backend/Dropbox/Dropbox.cs @@ -136,7 +136,10 @@ namespace Duplicati.Library.Backend public string Description { get { return Strings.Dropbox.Description; } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return null; } + } public void Test() { diff --git a/Duplicati/Library/Backend/FTP/FTPBackend.cs b/Duplicati/Library/Backend/FTP/FTPBackend.cs index 7e4018890..6f3e8b9dc 100644 --- a/Duplicati/Library/Backend/FTP/FTPBackend.cs +++ b/Duplicati/Library/Backend/FTP/FTPBackend.cs @@ -355,7 +355,10 @@ namespace Duplicati.Library.Backend } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return null; } + } public void Test() { diff --git a/Duplicati/Library/Backend/File/FileBackend.cs b/Duplicati/Library/Backend/File/FileBackend.cs index 86cc6d553..dec47fcf1 100644 --- a/Duplicati/Library/Backend/File/FileBackend.cs +++ b/Duplicati/Library/Backend/File/FileBackend.cs @@ -351,7 +351,10 @@ namespace Duplicati.Library.Backend } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return null; } + } public void Rename(string oldname, string newname) { diff --git a/Duplicati/Library/Backend/GoogleServices/GoogleCloudStorage.cs b/Duplicati/Library/Backend/GoogleServices/GoogleCloudStorage.cs index e367d873c..2bca35acb 100644 --- a/Duplicati/Library/Backend/GoogleServices/GoogleCloudStorage.cs +++ b/Duplicati/Library/Backend/GoogleServices/GoogleCloudStorage.cs @@ -261,7 +261,11 @@ namespace Duplicati.Library.Backend.GoogleCloudStorage get { return Strings.GoogleCloudStorage.Description; } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return null; } + } + #endregion public void Put(string remotename, System.IO.Stream stream) diff --git a/Duplicati/Library/Backend/GoogleServices/GoogleDrive.cs b/Duplicati/Library/Backend/GoogleServices/GoogleDrive.cs index b95be11a5..0c69c2813 100644 --- a/Duplicati/Library/Backend/GoogleServices/GoogleDrive.cs +++ b/Duplicati/Library/Backend/GoogleServices/GoogleDrive.cs @@ -347,7 +347,11 @@ namespace Duplicati.Library.Backend.GoogleDrive } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return null; } + } + #endregion #region IRenameEnabledBackend implementation diff --git a/Duplicati/Library/Backend/HubiC/HubiCBackend.cs b/Duplicati/Library/Backend/HubiC/HubiCBackend.cs index cd75a032a..ea42996ca 100644 --- a/Duplicati/Library/Backend/HubiC/HubiCBackend.cs +++ b/Duplicati/Library/Backend/HubiC/HubiCBackend.cs @@ -171,7 +171,10 @@ namespace Duplicati.Library.Backend.HubiC } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return null; } + } #endregion diff --git a/Duplicati/Library/Backend/Jottacloud/Jottacloud.cs b/Duplicati/Library/Backend/Jottacloud/Jottacloud.cs index 39a541ea7..4f44940be 100644 --- a/Duplicati/Library/Backend/Jottacloud/Jottacloud.cs +++ b/Duplicati/Library/Backend/Jottacloud/Jottacloud.cs @@ -318,7 +318,10 @@ namespace Duplicati.Library.Backend get { return true; } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return null; } + } public void Get(string remotename, System.IO.Stream stream) { diff --git a/Duplicati/Library/Backend/Mega/MegaBackend.cs b/Duplicati/Library/Backend/Mega/MegaBackend.cs index 51836e04e..0e6719db9 100644 --- a/Duplicati/Library/Backend/Mega/MegaBackend.cs +++ b/Duplicati/Library/Backend/Mega/MegaBackend.cs @@ -260,7 +260,10 @@ namespace Duplicati.Library.Backend.Mega } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return null; } + } #endregion diff --git a/Duplicati/Library/Backend/OneDrive/OneDrive.cs b/Duplicati/Library/Backend/OneDrive/OneDrive.cs index 6c0da40a9..4f5a59a98 100644 --- a/Duplicati/Library/Backend/OneDrive/OneDrive.cs +++ b/Duplicati/Library/Backend/OneDrive/OneDrive.cs @@ -500,7 +500,10 @@ namespace Duplicati.Library.Backend } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return null; } + } #endregion diff --git a/Duplicati/Library/Backend/OpenStack/OpenStackStorage.cs b/Duplicati/Library/Backend/OpenStack/OpenStackStorage.cs index 4dd8e7f88..83c6758be 100644 --- a/Duplicati/Library/Backend/OpenStack/OpenStackStorage.cs +++ b/Duplicati/Library/Backend/OpenStack/OpenStackStorage.cs @@ -423,7 +423,11 @@ namespace Duplicati.Library.Backend.OpenStack } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return null; } + } + #endregion #region IDisposable implementation public void Dispose() diff --git a/Duplicati/Library/Backend/Rclone/Rclone.cs b/Duplicati/Library/Backend/Rclone/Rclone.cs index d78f6df48..67771aeba 100644 --- a/Duplicati/Library/Backend/Rclone/Rclone.cs +++ b/Duplicati/Library/Backend/Rclone/Rclone.cs @@ -284,7 +284,10 @@ namespace Duplicati.Library.Backend } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return null; } + } public void Test() { diff --git a/Duplicati/Library/Backend/S3/S3Backend.cs b/Duplicati/Library/Backend/S3/S3Backend.cs index 60d4632fe..08d1eb8e9 100644 --- a/Duplicati/Library/Backend/S3/S3Backend.cs +++ b/Duplicati/Library/Backend/S3/S3Backend.cs @@ -474,7 +474,10 @@ namespace Duplicati.Library.Backend get { return m_wrapper; } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return null; } + } private string GetFullKey(string name) { diff --git a/Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs b/Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs index 75a18c700..45a8ce8f4 100644 --- a/Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs +++ b/Duplicati/Library/Backend/SSHv2/SSHv2Backend.cs @@ -369,6 +369,9 @@ namespace Duplicati.Library.Backend } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return null; } + } } } diff --git a/Duplicati/Library/Backend/SharePoint/SharePointBackend.cs b/Duplicati/Library/Backend/SharePoint/SharePointBackend.cs index 2d99ca84d..d011237cc 100644 --- a/Duplicati/Library/Backend/SharePoint/SharePointBackend.cs +++ b/Duplicati/Library/Backend/SharePoint/SharePointBackend.cs @@ -115,7 +115,10 @@ namespace Duplicati.Library.Backend } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return null; } + } #endregion diff --git a/Duplicati/Library/Backend/Sia/Sia.cs b/Duplicati/Library/Backend/Sia/Sia.cs index f00bd94f8..ae9c33fe7 100644 --- a/Duplicati/Library/Backend/Sia/Sia.cs +++ b/Duplicati/Library/Backend/Sia/Sia.cs @@ -440,7 +440,10 @@ namespace Duplicati.Library.Backend.Sia } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return null; } + } #endregion diff --git a/Duplicati/Library/Backend/TahoeLAFS/TahoeBackend.cs b/Duplicati/Library/Backend/TahoeLAFS/TahoeBackend.cs index 7689268a5..33ab2a91d 100644 --- a/Duplicati/Library/Backend/TahoeLAFS/TahoeBackend.cs +++ b/Duplicati/Library/Backend/TahoeLAFS/TahoeBackend.cs @@ -254,7 +254,10 @@ namespace Duplicati.Library.Backend get { return Strings.TahoeBackend.Description; } } - public string DNSName => throw new NotImplementedException(); + public string DNSName + { + get { return null; } + } #endregion diff --git a/Duplicati/Library/Backend/WEBDAV/WEBDAV.cs b/Duplicati/Library/Backend/WEBDAV/WEBDAV.cs index 2e5c480ad..97a8127f6 100644 --- a/Duplicati/Library/Backend/WEBDAV/WEBDAV.cs +++ b/Duplicati/Library/Backend/WEBDAV/WEBDAV.cs @@ -318,8 +318,6 @@ namespace Duplicati.Library.Backend get { return m_dnsName; } } - //=> throw new NotImplementedException(); - public void Test() { this.List(); diff --git a/Duplicati/Library/Main/BackendManager.cs b/Duplicati/Library/Main/BackendManager.cs index 648aeea98..671769527 100644 --- a/Duplicati/Library/Main/BackendManager.cs +++ b/Duplicati/Library/Main/BackendManager.cs @@ -526,11 +526,11 @@ namespace Duplicati.Library.Main { try { - System.Net.Dns.GetHostEntry(m_backend.DNSName); + if (!string.IsNullOrWhiteSpace(m_backend.DNSName)) + System.Net.Dns.GetHostEntry(m_backend.DNSName); } catch { - Logging.Log.WriteMessage("Failed to resolve IP for " + m_backend.DNSName, Logging.LogMessageType.Warning); } } }