rich7420 opened a new pull request, #10809:
URL: https://github.com/apache/ozone/pull/10809
## What changes were proposed in this pull request?
`VirtualHostStyleFilter.checkHostWithoutPort()` stripped the port from the
`Host` header with `host.lastIndexOf(':')`. That mangles IPv6 literals,
because
their address segments also contain colons:
- `[::1]:9878` / `[2001:db8::1]:9878` — the address itself gets truncated
- a bare `2001:db8::1` — the last address segment is mistaken for a port
As a result an S3 Gateway reachable on an IPv6 address rejects otherwise
valid
requests when a domain is configured.
This change parses the host with Guava
`HostAndPort.fromString(host).getHost()`,
which is bracket-aware: `[::1]:9878` and `[::1]` both yield `::1`, and a bare
`2001:db8::1` is returned unchanged. This matches how `HddsUtils` already
parses
host/port elsewhere. A malformed `Host` value (for example an unbalanced
bracket) falls back to the raw value, so it is rejected with the existing
"no matching domain" error rather than failing with an internal error.
Part of the IPv6 support epic HDDS-15763.
## What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-15776
## How was this patch tested?
Extended `TestVirtualHostStyleFilter`:
- a parameterized `testCheckHostWithoutPort` covering hostname / IPv4 /
bracketed-IPv6 / bare-IPv6 `Host` headers with and without a port, plus the
malformed-host fallback
- `testVirtualHostStyleWithoutPort`, which drives the full filter with a
port-less `Host` header
`mvn -pl :ozone-s3gateway test -Dtest=TestVirtualHostStyleFilter` — 20 tests
pass. Full CI was also run on the fork.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]