Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do ribbon support ipv6? #484

Open
czlovewyw opened this issue Jun 18, 2021 · 0 comments
Open

do ribbon support ipv6? #484

czlovewyw opened this issue Jun 18, 2021 · 0 comments

Comments

@czlovewyw
Copy link

czlovewyw commented Jun 18, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant