List of utility methods to do Local Address Check
boolean | isLocal(String brokerAddress) return Whether the specified host:port corresponds to the local machine String otherIP = getHost(getIPPort(brokerAddress)); InetAddress localHost; try { localHost = InetAddress.getLocalHost(); InetAddress inetAddresses[] = InetAddress.getAllByName(localHost.getHostName()); for (int i = 0; i < inetAddresses.length; i++) { InetAddress thisInetAddr = inetAddresses[i]; String thisIP = thisInetAddr.getHostAddress(); ... |
boolean | isLocalAddress(final String addr) is Local Address try { return isLocalAddress(InetAddress.getByName(addr)); } catch (final Exception e) { return false; |
boolean | isLocalAddress(final String address) is Local Address final InetAddress inetAddress = InetAddress.getByName(address); return inetAddress.isLinkLocalAddress() || inetAddress.isAnyLocalAddress() || inetAddress.isLoopbackAddress(); |
boolean | isLocalAddress(String address) Checks if the specified address is a private or loopback address try { InetAddress inetAddress = InetAddress.getByName(address); return isLoopbackAddress(address) || inetAddress.isSiteLocalAddress() || inetAddress.isLinkLocalAddress() || isIPv6UniqueSiteLocal(inetAddress); } catch (UnknownHostException e) { return false; ... |
boolean | isLocalAddress(String address) Figure out if the address is local. InetAddress targetAddress = InetAddress.getByName(address);
return getLocalAddresses().contains(targetAddress);
|
boolean | isLocalAddress(String address) is Local Address if (address == null) return false; return isLocalAddress(getByName(address)); |
boolean | isLocalAddress(String host) is Local Address try { InetAddress ia = InetAddress.getByName(host); if (ia.isAnyLocalAddress() || ia.isLoopbackAddress()) { return true; return NetworkInterface.getByInetAddress(ia) != null; } catch (UnknownHostException | SocketException ex) { return false; ... |
boolean | isLocalOrLoopback(String address) This will check if a url or address is a loopback or local address try { try { URL url = new URL(address); address = url.getHost(); } catch (MalformedURLException ignored) { InetAddress inetAddress = InetAddress.getByName(address); return inetAddress.isAnyLocalAddress() || inetAddress.isLinkLocalAddress() ... |
boolean | isLoopbackAddress(String address) Checks if the specified address is a loopback address. try { InetAddress inetAddress = InetAddress.getByName(address); return inetAddress.isLoopbackAddress(); } catch (UnknownHostException e) { return false; |
boolean | isMyAddress(String host) Determine whether the host name (or ip address) identifies the current machine. if ("localhost".equals(host)) return true; boolean result = false; try { final InetAddress addr = InetAddress.getByName(host); result = addr.isAnyLocalAddress() || addr.isLoopbackAddress(); if (!result) { result = NetworkInterface.getByInetAddress(addr) != null; ... |