mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 22:11:36 -05:00
feat(s3): virtual-hosted style addressing support (#805)
*.s3.localhost.floci.io, *.localhost.localstack.cloud, and
*.s3.localhost.localstack.cloud as virtual-hosted style regardless of
FLOCI_HOSTNAME — fixes 405 when SDK uses endpointOverride("http://localhost:4566")
without forcePathStyle (closes #801)
- EmbeddedDnsServer ships localhost.localstack.cloud and localhost.floci.io
as built-in suffixes so spawned containers resolve these domains to Floci's
IP without extra config
- Compatibility test S3VirtualHostStyleTest covers the full virtual-host path
end-to-end; TestFixtures.s3VirtualHostClient() prefers s3.localhost.floci.io,
falls back to s3.localhost.localstack.cloud, or uses FLOCI_S3_VHOST_ENDPOINT
in Docker
- run-docker-tests.sh and compatibility.yml inject --dns <floci-ip> and
FLOCI_S3_VHOST_ENDPOINT=http://floci:4566 into test containers
- S3 and migrate-from-localstack docs updated with virtual-hosted style details
This commit is contained in:
1 parent
ec9631e8c5
commit
c8c77c9e6e
11 files changed
+462
-15
No files matched your search
@@ -43,12 +43,21 @@ public class EmbeddedDnsServer {
|
||||
private static final int TTL = 60;
|
||||
private static final String FALLBACK_UPSTREAM = "127.0.0.11";
|
||||
public static final String DEFAULT_SUFFIX = "localhost.floci.io";
|
||||
public static final String LOCALSTACK_SUFFIX = "localhost.localstack.cloud";
|
||||
|
||||
// Well-known emulator wildcard DNS domains that always resolve to Floci's IP.
|
||||
// The suffix "localhost.X" covers "localhost.X" itself and "*.localhost.X" — it does
|
||||
// NOT cover "*.X" (e.g. "localhost.floci.io" does NOT resolve bare "*.floci.io").
|
||||
// localhost.localstack.cloud → localhost.localstack.cloud, *.localhost.localstack.cloud
|
||||
// localhost.floci.io → localhost.floci.io, *.localhost.floci.io
|
||||
static final List<String> BUILTIN_SUFFIXES = List.of(DEFAULT_SUFFIX, LOCALSTACK_SUFFIX);
|
||||
|
||||
private volatile String serverIp;
|
||||
private final List<String> suffixes = new ArrayList<>();
|
||||
private String upstreamDns;
|
||||
|
||||
EmbeddedDnsServer(List<String> suffixes) {
|
||||
this.suffixes.addAll(BUILTIN_SUFFIXES);
|
||||
this.suffixes.addAll(suffixes);
|
||||
}
|
||||
|
||||
@@ -61,7 +70,8 @@ public class EmbeddedDnsServer {
|
||||
String myIp = InetAddress.getLocalHost().getHostAddress();
|
||||
upstreamDns = readUpstreamDns();
|
||||
|
||||
suffixes.add(config.hostname().orElse(DEFAULT_SUFFIX));
|
||||
suffixes.addAll(BUILTIN_SUFFIXES);
|
||||
config.hostname().ifPresent(suffixes::add);
|
||||
config.dns().extraSuffixes().ifPresent(suffixes::addAll);
|
||||
|
||||
DatagramSocket socket = vertx.createDatagramSocket(new DatagramSocketOptions().setIpV6(false));
|
||||
|
||||
@@ -171,10 +171,19 @@ public class S3VirtualHostFilter implements ContainerRequestFilter {
|
||||
if (remainder.startsWith("s3.") && remainder.endsWith(".amazonaws.com")) {
|
||||
return true;
|
||||
}
|
||||
// Support localstack.cloud subdomains (used by cdklocal and other tools)
|
||||
// Example: bucket.s3.localhost.localstack.cloud
|
||||
// localhost always resolves to 127.0.0.1 — accept regardless of FLOCI_HOSTNAME config.
|
||||
// Fixes: SDK with endpointOverride("http://localhost:4566") without forcePathStyle sends
|
||||
// Host: my-bucket.localhost:4566, which must be recognized even when baseHostname=floci.
|
||||
if ("localhost".equals(remainder)) {
|
||||
return true;
|
||||
}
|
||||
// LocalStack public wildcard DNS: bucket.s3.localhost.localstack.cloud and bucket.localhost.localstack.cloud
|
||||
if (remainder.endsWith(".localstack.cloud")) {
|
||||
return remainder.startsWith("s3.");
|
||||
return remainder.startsWith("s3.") || "localhost.localstack.cloud".equals(remainder);
|
||||
}
|
||||
// Floci public wildcard DNS: bucket.s3.localhost.floci.io and bucket.localhost.floci.io → 127.0.0.1
|
||||
if (remainder.endsWith(".localhost.floci.io") || "localhost.floci.io".equals(remainder)) {
|
||||
return remainder.startsWith("s3.") || "localhost.floci.io".equals(remainder);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user