@Test public void showDefaultLocalIp() { System.out.println(IpUtil.getLocalIp()); }
public static String getLocalIp(final String nic, final String manageIp) { List<String> ips = getLocalIps(nic, manageIp); if (ips != null && !ips.isEmpty()) { if (ips.size() == 1) { return ips.get(0); } if (!PREFER_IPV6) { for (String ip : ips) { if (INTRANET.contains(ip)) { return ip; } } } return ips.get(0); } return null; }
IpUtil { public static String getLocalIp(final String nic, final String manageIp) { List<String> ips = getLocalIps(nic, manageIp); if (ips != null && !ips.isEmpty()) { if (ips.size() == 1) { return ips.get(0); } if (!PREFER_IPV6) { for (String ip : ips) { if (INTRANET.contains(ip)) { return ip; } } } return ips.get(0); } return null; } }
IpUtil { public static String getLocalIp(final String nic, final String manageIp) { List<String> ips = getLocalIps(nic, manageIp); if (ips != null && !ips.isEmpty()) { if (ips.size() == 1) { return ips.get(0); } if (!PREFER_IPV6) { for (String ip : ips) { if (INTRANET.contains(ip)) { return ip; } } } return ips.get(0); } return null; }  }
IpUtil { public static String getLocalIp(final String nic, final String manageIp) { List<String> ips = getLocalIps(nic, manageIp); if (ips != null && !ips.isEmpty()) { if (ips.size() == 1) { return ips.get(0); } if (!PREFER_IPV6) { for (String ip : ips) { if (INTRANET.contains(ip)) { return ip; } } } return ips.get(0); } return null; }  static List<String> getLocalIps(); static List<String> getLocalIps(final String nic, final String exclude); static String getLocalIp(final String nic, final String manageIp); static String getLocalIp(final String manageIp); static String getLocalIp(); static String toAddress(final SocketAddress address); static String toIp(final byte[] address); static byte[] toByte(String address); static byte[] toByte(InetSocketAddress socketAddress); static InetSocketAddress toAddress(final byte[] address); static void toAddress(byte[] address, StringBuilder builder); static int[] parseIp(final String ip); static long toLong(final String ip); static String toIp(long ip); static void main(String[] args); static boolean isValidIpV6Address(String ipAddress); static boolean isValidIp4Word(String word); static boolean isValidIpV4Address(String value); }
IpUtil { public static String getLocalIp(final String nic, final String manageIp) { List<String> ips = getLocalIps(nic, manageIp); if (ips != null && !ips.isEmpty()) { if (ips.size() == 1) { return ips.get(0); } if (!PREFER_IPV6) { for (String ip : ips) { if (INTRANET.contains(ip)) { return ip; } } } return ips.get(0); } return null; }  static List<String> getLocalIps(); static List<String> getLocalIps(final String nic, final String exclude); static String getLocalIp(final String nic, final String manageIp); static String getLocalIp(final String manageIp); static String getLocalIp(); static String toAddress(final SocketAddress address); static String toIp(final byte[] address); static byte[] toByte(String address); static byte[] toByte(InetSocketAddress socketAddress); static InetSocketAddress toAddress(final byte[] address); static void toAddress(byte[] address, StringBuilder builder); static int[] parseIp(final String ip); static long toLong(final String ip); static String toIp(long ip); static void main(String[] args); static boolean isValidIpV6Address(String ipAddress); static boolean isValidIp4Word(String word); static boolean isValidIpV4Address(String value); static String IPV4_PORT_SEPARATOR; static String IPV6_PORT_SEPARATOR; static String IPV4_SEPARATOR; static String IPV6_SEPARATOR; static String MANAGE_IP; static String NET_INTERFACE; static final Lan INTRANET; static boolean PREFER_IPV6; static String PREFER_HOSTNAME_OVERIP; }