@Test public void testGetLocalIPs() { List<String> allIps = NetworkExt.getLocalIPs(false).orElse(null); assertThat(allIps).isNotNull(); assertThat(allIps).allSatisfy(address -> assertThat(NetworkExt.isIpV4(address) || NetworkExt.isIPv6(address)).isTrue()); }
public static Optional<List<String>> getLocalIPs(boolean ipv4Only) { if (resolvedLocalIPsRef.get() == null) { try { resolvedLocalIPsRef.set(Optional.of(resolveLocalIPs(ipv4Only))); } catch (Exception e) { logger.error("Cannot resolve local IP addresses"); resolvedLocalIPsRef.set(Optional.empty()); } } return resolvedLocalIPsRef.get(); }
NetworkExt { public static Optional<List<String>> getLocalIPs(boolean ipv4Only) { if (resolvedLocalIPsRef.get() == null) { try { resolvedLocalIPsRef.set(Optional.of(resolveLocalIPs(ipv4Only))); } catch (Exception e) { logger.error("Cannot resolve local IP addresses"); resolvedLocalIPsRef.set(Optional.empty()); } } return resolvedLocalIPsRef.get(); } }
NetworkExt { public static Optional<List<String>> getLocalIPs(boolean ipv4Only) { if (resolvedLocalIPsRef.get() == null) { try { resolvedLocalIPsRef.set(Optional.of(resolveLocalIPs(ipv4Only))); } catch (Exception e) { logger.error("Cannot resolve local IP addresses"); resolvedLocalIPsRef.set(Optional.empty()); } } return resolvedLocalIPsRef.get(); }  }
NetworkExt { public static Optional<List<String>> getLocalIPs(boolean ipv4Only) { if (resolvedLocalIPsRef.get() == null) { try { resolvedLocalIPsRef.set(Optional.of(resolveLocalIPs(ipv4Only))); } catch (Exception e) { logger.error("Cannot resolve local IP addresses"); resolvedLocalIPsRef.set(Optional.empty()); } } return resolvedLocalIPsRef.get(); }  static int findUnusedPort(); static Optional<String> getHostName(); static String resolveHostName(); static boolean isLoopbackIP(String ip); static boolean isIPv6(String ip); static Optional<List<String>> getLocalIPs(boolean ipv4Only); static Optional<List<String>> getLocalIPs(); static List<String> resolveLocalIPs(boolean ipv4Only); static String toIPv4(long addressLong); static String toIpV6AddressName(Inet6Address inet6Address); static long toNetworkBitMask(int maskLength); static boolean matches(String ipAddress, NetworkAddress networkAddress); static boolean matches(long ipAddress, NetworkAddress networkAddress); static Function<String, Boolean> buildNetworkMatchPredicate(List<String> cdirs); static NetworkAddress parseCDIR(String cdir); static boolean isIpV4(String address); static long toBits(String ipv4Address); }
NetworkExt { public static Optional<List<String>> getLocalIPs(boolean ipv4Only) { if (resolvedLocalIPsRef.get() == null) { try { resolvedLocalIPsRef.set(Optional.of(resolveLocalIPs(ipv4Only))); } catch (Exception e) { logger.error("Cannot resolve local IP addresses"); resolvedLocalIPsRef.set(Optional.empty()); } } return resolvedLocalIPsRef.get(); }  static int findUnusedPort(); static Optional<String> getHostName(); static String resolveHostName(); static boolean isLoopbackIP(String ip); static boolean isIPv6(String ip); static Optional<List<String>> getLocalIPs(boolean ipv4Only); static Optional<List<String>> getLocalIPs(); static List<String> resolveLocalIPs(boolean ipv4Only); static String toIPv4(long addressLong); static String toIpV6AddressName(Inet6Address inet6Address); static long toNetworkBitMask(int maskLength); static boolean matches(String ipAddress, NetworkAddress networkAddress); static boolean matches(long ipAddress, NetworkAddress networkAddress); static Function<String, Boolean> buildNetworkMatchPredicate(List<String> cdirs); static NetworkAddress parseCDIR(String cdir); static boolean isIpV4(String address); static long toBits(String ipv4Address); static final String IP4_LOOPBACK; static final String IP6_LOOPBACK; }