added host name support

This commit is contained in:
jomu
2017-10-10 15:40:56 +00:00
parent a3bee0a7cf
commit d17b681025

View File

@ -9,17 +9,19 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author joern.muehlencord
*/
public class PortScanner {
private final static Logger LOGGER = LoggerFactory.getLogger(PortScanner.class);
private final static Logger LOGGER = LoggerFactory.getLogger(PortScanner.class);
private final int startPort;
private final int endPort;
private final int timeout;
private String host = null;
public PortScanner(int timeoutInMs, int startPort, int endPort) {
this.startPort = startPort;
@ -32,6 +34,7 @@ public class PortScanner {
}
public List<PortInformation> scan(String ip) {
this.host = ip;
final List<PortInformation> resultList = new ArrayList<>();
final ExecutorService es = Executors.newFixedThreadPool(20);
@ -42,7 +45,7 @@ public class PortScanner {
es.shutdown();
try {
for (final Future<PortInformation> f : futures) {
for (final Future<PortInformation> f : futures) {
resultList.add(f.get());
}
} catch (InterruptedException | ExecutionException ex) {
@ -53,6 +56,10 @@ public class PortScanner {
}
/* *** getter *** */
public String getHost() {
return host;
}
public int getStartPort() {
return startPort;
}