Skip to content

Commit

Permalink
Update arbiter bundle for S3's dnsSuffix configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
connormanning committed Mar 9, 2017
1 parent c2cf2d6 commit 605446a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions vendor/arbiter/arbiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1693,6 +1693,8 @@ std::string S3::Config::extractBaseUrl(
endpointsPath = json["endpointsFile"].asString();
}

std::string dnsSuffix("amazonaws.com");

drivers::Fs fsDriver;
if (std::unique_ptr<std::string> e = fsDriver.tryGet(endpointsPath))
{
Expand All @@ -1702,6 +1704,11 @@ std::string S3::Config::extractBaseUrl(

for (const auto& partition : ep["partitions"])
{
if (partition.isMember("dnsSuffix"))
{
dnsSuffix = partition["dnsSuffix"].asString();
}

const auto& endpoints(partition["services"]["s3"]["endpoints"]);
const auto regions(endpoints.getMemberNames());
for (const auto& r : regions)
Expand All @@ -1714,9 +1721,11 @@ std::string S3::Config::extractBaseUrl(
}
}

if (dnsSuffix.size() && dnsSuffix.back() != '/') dnsSuffix += '/';

// https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
if (region == "us-east-1") return "s3.amazonaws.com/";
else return "s3-" + region + ".amazonaws.com/";
if (region == "us-east-1") return "s3." + dnsSuffix;
else return "s3-" + region + "." + dnsSuffix;
}

S3::AuthFields S3::Auth::fields() const
Expand Down
2 changes: 1 addition & 1 deletion vendor/arbiter/arbiter.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// Arbiter amalgamated header (https://github.com/connormanning/arbiter).
/// It is intended to be used with #include "arbiter.hpp"

// Git SHA: 353e2ca0d38a7157e3eebce40d4a60ef2a94d6dc
// Git SHA: 570eb73b14c2a0fbe9ee2927a3d79f48909c374e

// //////////////////////////////////////////////////////////////////////
// Beginning of content of file: LICENSE
Expand Down

0 comments on commit 605446a

Please sign in to comment.