The method parseForwardedFor in UriComponentsBuilder is using, for both Forwarded headers's extracted IPv4 Addresses, the method InetSocketAddress.createUnresolved(host, port)
to generate an InetSocketAddress.
Maybe what should be used is the constructor InetSocketAddress(InetAddress addr, int port)
The current behaviour creates problems given that ForwardedHeaderTransformer will use this method to recreate ServerHttpRequest's remoteAddress (while removing X-Forwarded-For
header from the request) and, for instance, Spring Cloud Gateway (see XForwardedHeadersFilter in that project) will try to rebuild this header from this recreated remoteAddress using request.getRemoteAddress().getAddress().getHostAddress()
Comment From: rstoyanchev
Can you point to the code in Spring Cloud Gateway, and what version is that in? I don't quite see why it shouldn't be able to get what it needs.
Comment From: jlimamob
https://github.com/spring-cloud/spring-cloud-gateway/blob/main/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/filter/headers/XForwardedHeadersFilter.java Line 210
Comment From: rstoyanchev
Apologies for dropping this, but it's unclear what difference exactly it would make to attempt to resolve the address.
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: spring-projects-issues
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.