in computer-core/src/main/java/org/apache/hugegraph/computer/core/network/TransportUtil.java [99:123]
public static List<String> getLocalIPAddress() {
List<String> ips = new ArrayList<>();
try {
Enumeration<NetworkInterface> allNetInterfaces =
NetworkInterface.getNetworkInterfaces();
InetAddress ip;
while (allNetInterfaces.hasMoreElements()) {
NetworkInterface netInterface = allNetInterfaces.nextElement();
if (!netInterface.isLoopback() && !netInterface.isVirtual() &&
netInterface.isUp()) {
Enumeration<InetAddress> addresses =
netInterface.getInetAddresses();
while (addresses.hasMoreElements()) {
ip = addresses.nextElement();
if (ip instanceof Inet4Address) {
ips.add(ip.getHostAddress());
}
}
}
}
return ips;
} catch (Exception e) {
throw new ComputerException("Failed to getLocalIPAddress", e);
}
}