-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFillDomains.java
38 lines (30 loc) · 893 Bytes
/
FillDomains.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.net.*;
import java.util.*;
import java.io.*;
import java.nio.file.*;
class FillDomains {
private final static int SOCKET_PORT = 80;
FillDomains() {
}
public void fill(ArrayList<Target> servers, String filePath) {
List<String> domainsList = new ArrayList<>();
try {
domainsList = Files.readAllLines(Paths.get(filePath));
} catch (FileNotFoundException fnfexc) {
System.err.println(filePath + " not found");
} catch (Exception exc) {
System.err.println(exc.getMessage());
}
int order = 0;
for (String hostname : domainsList) {
try {
servers.add(new Target(order++,
new InetSocketAddress(InetAddress.getByName(hostname), SOCKET_PORT))
);
} catch (UnknownHostException e) {
System.err.println("\tUnknown host: " + hostname + " SKIPPED");
}
}
System.out.println("Total number of target servers: " + servers.size());
}
}