do ribbon support ipv6?
czlovewyw opened this issue · 0 comments
czlovewyw commented
when use ribbon,it use reconstructURIWithServer() to build url in class LoadBalancerContext,as below:
public URI reconstructURIWithServer(Server server, URI original) {
String host = server.getHost();
int port = server.getPort();
String scheme = server.getScheme();
if (host.equals(original.getHost())
&& port == original.getPort()
&& scheme == original.getScheme()) {
return original;
}
if (scheme == null) {
scheme = original.getScheme();
}
if (scheme == null) {
scheme = deriveSchemeAndPortFromPartialUri(original).first();
}
try {
StringBuilder sb = new StringBuilder();
sb.append(scheme).append("://");
if (!Strings.isNullOrEmpty(original.getRawUserInfo())) {
sb.append(original.getRawUserInfo()).append("@");
}
sb.append(host);
if (port >= 0) {
sb.append(":").append(port);
}
sb.append(original.getRawPath());
if (!Strings.isNullOrEmpty(original.getRawQuery())) {
sb.append("?").append(original.getRawQuery());
}
if (!Strings.isNullOrEmpty(original.getRawFragment())) {
sb.append("#").append(original.getRawFragment());
}
URI newURI = new URI(sb.toString());
return newURI;
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
we can see the codes support ipv4 but not suppot ipv6. When we switch to use ipv6,we should add"[""]"in url.
For example,now the ip is "fe80::dc8c:162:7b:e957",then,we should use url like "http://[fe80::dc8c:162:7b:e957]/test" to do request,if we use "http://fe80::dc8c:162:7b:e957/test" ,we will fail.
So,can ribbon do something to support ipv6?