Aias00 opened a new issue, #6442:
URL: https://github.com/apache/shenyu/issues/6442

   ### Current Behavior
   
   Several admin/common runtime paths parse upstream URLs by splitting on `:`. 
This breaks valid IPv6 upstream addresses.
   
   Evidence:
   
   - 
`shenyu-common/src/main/java/org/apache/shenyu/common/utils/UpstreamCheckUtils.java:67-73`
   - 
`shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/LoadServiceDocEntryImpl.java:153-158`
   - 
`shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/DiscoveryTransfer.java:352-361`
   
   Examples:
   
   ```java
   hostPort = StringUtils.split(http[1], Constants.COLONS);
   ...
   String[] upstreamUrlArr = discoveryUpstreamData.getUrl().split(":");
   ...
   .map(url -> url.split(":", 2))
   ```
   
   For valid IPv6 literals such as `[2001:db8::1]:8080` or 
`http://[2001:db8::1]:8080`, colon splitting truncates the host and/or attempts 
to parse part of the IPv6 literal as a port. That can produce a failed health 
check, wrong discovery upstream data, or `NumberFormatException`.
   
   ### Expected Behavior
   
   Valid IPv6 upstream addresses should be parsed with URI/host-port aware 
logic and should work in health checks, discovery conversion, and API document 
loading.
   
   ### Steps To Reproduce
   
   Use an upstream URL such as:
   
   ```text
   [2001:db8::1]:8080
   http://[2001:db8::1]:8080
   ```
   
   Then trigger one of these paths:
   
   - upstream health check via `UpstreamCheckUtils.checkUrl(...)`
   - discovery upstream conversion via 
`DiscoveryTransfer.mapToDiscoveryUpstreamData(...)`
   - API document instance loading via 
`LoadServiceDocEntryImpl.getInstances2(...)`
   
   ### Suggested Fix
   
   Use `java.net.URI` or a host-port parser that supports bracketed IPv6 
literals. Avoid raw `split(":")` for URLs or host:port strings.
   


-- 
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]

Reply via email to