@Test public void isInnewerIP() throws Exception { Assert.assertFalse(IpUtils.isInnerIP("8.8.8.8")); Assert.assertFalse(IpUtils.isInnerIP("114.114.114.114")); Assert.assertTrue(IpUtils.isInnerIP("10.0.0.0")); Assert.assertTrue(IpUtils.isInnerIP("10.0.0.1")); Assert.assertTrue(IpUtils.isInnerIP("10.255.255.255")); Assert.assertTrue(IpUtils.isInnerIP("172.16.0.0")); Assert.assertTrue(IpUtils.isInnerIP("172.16.0.1")); Assert.assertTrue(IpUtils.isInnerIP("172.31.255.255")); Assert.assertTrue(IpUtils.isInnerIP("192.168.0.0")); Assert.assertTrue(IpUtils.isInnerIP("192.168.0.1")); Assert.assertTrue(IpUtils.isInnerIP("192.168.255.255")); Assert.assertTrue(IpUtils.isInnerIP("127.0.0.1")); }
public static boolean isInnerIP(String ipAddress) { boolean isInnerIp = false; long ipNum = getIpNum(ipAddress); long aBegin = getIpNum("10.0.0.0"); long aEnd = getIpNum("10.255.255.255"); long bBegin = getIpNum("172.16.0.0"); long bEnd = getIpNum("172.31.255.255"); long cBegin = getIpNum("192.168.0.0"); long cEnd = getIpNum("192.168.255.255"); isInnerIp = isInner(ipNum, aBegin, aEnd) || isInner(ipNum, bBegin, bEnd) || isInner(ipNum, cBegin, cEnd) || "127.0.0.1".equals(ipAddress); return isInnerIp; }
IpUtils { public static boolean isInnerIP(String ipAddress) { boolean isInnerIp = false; long ipNum = getIpNum(ipAddress); long aBegin = getIpNum("10.0.0.0"); long aEnd = getIpNum("10.255.255.255"); long bBegin = getIpNum("172.16.0.0"); long bEnd = getIpNum("172.31.255.255"); long cBegin = getIpNum("192.168.0.0"); long cEnd = getIpNum("192.168.255.255"); isInnerIp = isInner(ipNum, aBegin, aEnd) || isInner(ipNum, bBegin, bEnd) || isInner(ipNum, cBegin, cEnd) || "127.0.0.1".equals(ipAddress); return isInnerIp; } }
IpUtils { public static boolean isInnerIP(String ipAddress) { boolean isInnerIp = false; long ipNum = getIpNum(ipAddress); long aBegin = getIpNum("10.0.0.0"); long aEnd = getIpNum("10.255.255.255"); long bBegin = getIpNum("172.16.0.0"); long bEnd = getIpNum("172.31.255.255"); long cBegin = getIpNum("192.168.0.0"); long cEnd = getIpNum("192.168.255.255"); isInnerIp = isInner(ipNum, aBegin, aEnd) || isInner(ipNum, bBegin, bEnd) || isInner(ipNum, cBegin, cEnd) || "127.0.0.1".equals(ipAddress); return isInnerIp; }  }
IpUtils { public static boolean isInnerIP(String ipAddress) { boolean isInnerIp = false; long ipNum = getIpNum(ipAddress); long aBegin = getIpNum("10.0.0.0"); long aEnd = getIpNum("10.255.255.255"); long bBegin = getIpNum("172.16.0.0"); long bEnd = getIpNum("172.31.255.255"); long cBegin = getIpNum("192.168.0.0"); long cEnd = getIpNum("192.168.255.255"); isInnerIp = isInner(ipNum, aBegin, aEnd) || isInner(ipNum, bBegin, bEnd) || isInner(ipNum, cBegin, cEnd) || "127.0.0.1".equals(ipAddress); return isInnerIp; }  static String getIP4WithPriority(); static String getLocalHostAddress(); static boolean isValidIPv4(String ip); static boolean isValidPort(String port); static List<InetAddress> getIP4ByNetworkInterface(); static boolean isInnerIP(String ipAddress); static long getIpNum(String ipAddress); static boolean isReachable(String ip); }
IpUtils { public static boolean isInnerIP(String ipAddress) { boolean isInnerIp = false; long ipNum = getIpNum(ipAddress); long aBegin = getIpNum("10.0.0.0"); long aEnd = getIpNum("10.255.255.255"); long bBegin = getIpNum("172.16.0.0"); long bEnd = getIpNum("172.31.255.255"); long cBegin = getIpNum("192.168.0.0"); long cEnd = getIpNum("192.168.255.255"); isInnerIp = isInner(ipNum, aBegin, aEnd) || isInner(ipNum, bBegin, bEnd) || isInner(ipNum, cBegin, cEnd) || "127.0.0.1".equals(ipAddress); return isInnerIp; }  static String getIP4WithPriority(); static String getLocalHostAddress(); static boolean isValidIPv4(String ip); static boolean isValidPort(String port); static List<InetAddress> getIP4ByNetworkInterface(); static boolean isInnerIP(String ipAddress); static long getIpNum(String ipAddress); static boolean isReachable(String ip); static final String LOCALHOST; static final String ANYHOST; }