From 8bbeb54e480b1dca8253024934dcd5f727f7d952 Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Tue, 29 Aug 2017 10:35:07 +0200 Subject: [PATCH 1/2] Fixed a missing case-insensitive compare --- Duplicati/Library/Backend/S3/S3Wrapper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Duplicati/Library/Backend/S3/S3Wrapper.cs b/Duplicati/Library/Backend/S3/S3Wrapper.cs index 36cec0ab7..52d88352f 100644 --- a/Duplicati/Library/Backend/S3/S3Wrapper.cs +++ b/Duplicati/Library/Backend/S3/S3Wrapper.cs @@ -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) From e39ec4ddf5d642a78ffa93ec4737993d7e15065d Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Tue, 29 Aug 2017 10:35:41 +0200 Subject: [PATCH 2/2] Added fix to auto-set `--s3-ext-forcepathstyle` if the target is not an Amazon S3 provider --- Duplicati/Library/Backend/S3/S3Backend.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Duplicati/Library/Backend/S3/S3Backend.cs b/Duplicati/Library/Backend/S3/S3Backend.cs index 814c5249f..27f145f97 100644 --- a/Duplicati/Library/Backend/S3/S3Backend.cs +++ b/Duplicati/Library/Backend/S3/S3Backend.cs @@ -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)