in foundations/foundation-common/src/main/java/org/apache/servicecomb/foundation/common/net/NetUtils.java [137:164]
private static void doGetAddressFromNetworkInterface() throws SocketException {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
NetworkInterface network = networkInterfaces.nextElement();
if (!network.isUp() || network.isLoopback() || network.isVirtual()) {
continue;
}
Enumeration<InetAddress> addresses = network.getInetAddresses();
while (addresses.hasMoreElements()) {
InetAddress address = addresses.nextElement();
if (isLocalAddress(address)) {
continue;
}
if (address instanceof Inet4Address) {
LOGGER.info("add ipv4 network interface:" + network.getName() + ",host address:" + address.getHostAddress());
allInterfaceAddresses.put(network.getName() + IPV4_KEY, address);
} else if (address instanceof Inet6Address) {
LOGGER.info("add ipv6 network interface:" + network.getName() + ",host address:" + address.getHostAddress());
allInterfaceAddresses.put(network.getName() + IPV6_KEY, address);
}
}
}
}