Merge remote-tracking branch 'origin/5.7.x' into 5.8.x

Closes gh-12076
This commit is contained in:
Josh Cummings
2022-10-24 16:44:51 -06:00
2 changed files with 24 additions and 2 deletions

View File

@@ -48,7 +48,7 @@ public final class IpAddressServerWebExchangeMatcher implements ServerWebExchang
public Mono<MatchResult> matches(ServerWebExchange exchange) {
// @formatter:off
return Mono.justOrEmpty(exchange.getRequest().getRemoteAddress())
.map((remoteAddress) -> remoteAddress.getAddress().getHostAddress())
.map((remoteAddress) -> remoteAddress.isUnresolved() ? remoteAddress.getHostString() : remoteAddress.getAddress().getHostAddress())
.map(this.ipAddressMatcher::matches)
.flatMap((matches) -> matches ? MatchResult.match() : MatchResult.notMatch())
.switchIfEmpty(MatchResult.notMatch());