added code to attempt to resolve DNS issues on connection failure and implemented DNSName method in WebDav backend handler

This commit is contained in:
Rune Henriksen
2018-02-18 01:30:05 +01:00
parent 7a58851224
commit ecc586c0f8
2 changed files with 21 additions and 1 deletions
+8 -1
View File
@@ -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()
{
+13
View File
@@ -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;