Revision: 63553
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 16, 2013 04:56 by laurenceosx
Initial Code
public static boolean isInetAddressLocal(InetAddress addr) { // http://stackoverflow.com/questions/2406341/how-to-check-if-an-ip-address-is-the-local-host-on-a-multi-homed-system if (addr.isAnyLocalAddress() || addr.isLoopbackAddress()) { return true; } // Check if the address is defined on any interface try { return NetworkInterface.getByInetAddress(addr) != null; } catch (SocketException e) { return false;} } public static boolean isIpStringAddressLocal(String strIpAddress) { def addr = InetAddress.getByName( strIpAddress ); // http://stackoverflow.com/questions/2406341/how-to-check-if-an-ip-address-is-the-local-host-on-a-multi-homed-system if (addr.isAnyLocalAddress() || addr.isLoopbackAddress()) { return true; } // Check if the address is defined on any interface try { return NetworkInterface.getByInetAddress(addr) != null; } catch (SocketException e) { return false;} }
Initial URL
http://stackoverflow.com/questions/2406341/how-to-check-if-an-ip-address-is-the-local-host-on-a-multi-homed-system
Initial Description
See: // http://stackoverflow.com/questions/2406341/how-to-check-if-an-ip-address-is-the-local-host-on-a-multi-homed-system
Initial Title
Groovy IsIpAddressLocal
Initial Tags
groovy
Initial Language
Groovy