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

node: The findInternalIp function returns an incorrect address in an IPv4/IPv6 dual-stack environment. #1023

Open
youzhiliu opened this issue Dec 7, 2022 · 0 comments

Comments

@youzhiliu
Copy link

youzhiliu commented Dec 7, 2022

The findInternalIp function returns IPv4 address in an IPv4/IPv6 dual-stack environment, even if java.net.preferIPv6Address is set to true, so can't be access trino web ui.

We need to add a judgment based on the original logic. If the java.net.preferIPv4Stack parameter is configured and the address is an IPv4 address, the IPv4 address is returned. If the java.net.preferIPv6Addresses parameter is set and the address is an IPv6 address, the IPv4 address is returned.

private static boolean isAddressV4Prefer(InetAddress localAddress)
{
    String property = System.getProperty("java.net.preferIPv4Stack");
    if (property != null) {
        return "true".equalsIgnoreCase(property) && isV4Address(localAddress);
    }
    else {
        return false;
    }
}

private static boolean isAddressV6Prefer(InetAddress localAddress)
{
    String property = System.getProperty("java.net.preferIPv6Addresses");
    if (property != null) {
        return "true".equalsIgnoreCase(property) && isV6Address(localAddress);
    }
    else {
        return false;
    }
}

private static boolean isAddressPrefer(InetAddress localAddress)
{
    return isAddressV4Prefer(localAddress) || isAddressV6Prefer(localAddress);
}

if (isAddressPrefer(localAddress) && getGoodAddresses().contains(localAddress)) {
    return localAddress;
}

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