| 53 | } |
| 54 | |
| 55 | private static List<InetAddress> parseIpRange(String ipRange) throws UnknownHostException { |
| 56 | |
| 57 | List<InetAddress> addresses = new ArrayList<InetAddress>(); |
| 58 | if (ipRange.indexOf("-") != -1) { //multiple IPs: ipRange = 172.31.229.240-172.31.229.250 |
| 59 | String[] ips = ipRange.split("-"); |
| 60 | String[] octets = ips[0].split("\\."); |
| 61 | int lowerBound = Integer.parseInt(octets[3]); |
| 62 | int upperBound = Integer.parseInt(ips[1].split("\\.")[3]); |
| 63 | |
| 64 | for (int i = lowerBound; i <= upperBound; i++) { |
| 65 | String ip = octets[0] + "." + octets[1] + "." + octets[2] + "." + i; |
| 66 | addresses.add(InetAddress.getByName(ip)); |
| 67 | } |
| 68 | } else { //single ip: ipRange = 172.31.229.240 |
| 69 | addresses.add(InetAddress.getByName(ipRange)); |
| 70 | } |
| 71 | return addresses; |
| 72 | } |
| 73 | |
| 74 | private static String checkHosts(List<InetAddress> inetAddresses) throws IOException { |
| 75 | String alive = ""; |