Merge branch 'feature/autofix-s3-forcepathstyle'

This commit is contained in:
Kenneth Skovhede
2017-08-29 12:54:24 +02:00
2 changed files with 7 additions and 2 deletions
+6 -1
View File
@@ -257,7 +257,12 @@ namespace Duplicati.Library.Backend
if (m_prefix.Length != 0 && !m_prefix.EndsWith("/"))
m_prefix += "/";
m_wrapper = new S3Wrapper(awsID, awsKey, locationConstraint, host, storageClass, useSSL, options);
// Auto-disable dns lookup for non AWS configurations
var hasForcePathStyle = options.ContainsKey("s3-ext-forcepathstyle");
if (!hasForcePathStyle && !DEFAULT_S3_LOCATION_BASED_HOSTS.Any(x => string.Equals(x.Value, host, StringComparison.OrdinalIgnoreCase)) && !string.Equals(host, "s3.amazonaws.com", StringComparison.OrdinalIgnoreCase))
options["s3-ext-forcepathstyle"] = "true";
m_wrapper = new S3Wrapper(awsID, awsKey, locationConstraint, host, storageClass, useSSL, options);
}
public static bool IsValidHostname(string bucketname)
+1 -1
View File
@@ -47,7 +47,7 @@ namespace Duplicati.Library.Backend
//cfg.UserAgent = "Duplicati v" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " S3 client with AWS SDK v" + cfg.GetType().Assembly.GetName().Version.ToString();
cfg.BufferSize = (int)Duplicati.Library.Utility.Utility.DEFAULT_BUFFER_SIZE;
foreach(var opt in options.Keys.Where(x => x.StartsWith("s3-ext-")))
foreach(var opt in options.Keys.Where(x => x.StartsWith("s3-ext-", StringComparison.InvariantCultureIgnoreCase)))
{
var prop = cfg.GetType().GetProperties().Where(x => string.Equals(x.Name, opt.Substring("s3-ext-".Length), StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();
if (prop != null && prop.CanWrite)