This commit is contained in:
parent
b3752fd4ae
commit
32723679e1
1 changed files with 15 additions and 6 deletions
|
@ -81,7 +81,8 @@ public class PacketHandler {
|
||||||
var status = PingResponsePacket.PingResponseStatus.ERROR;
|
var status = PingResponsePacket.PingResponseStatus.ERROR;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Process process = Runtime.getRuntime().exec(new String[] { "ping", "-3Ac", "10", "-W", "1", packet.target.getHostAddress() });
|
// -3 was also an arumetn but not wokring on all
|
||||||
|
Process process = Runtime.getRuntime().exec(new String[] { "ping", "-Ac", "10", "-W", "1", packet.target.getHostAddress() });
|
||||||
|
|
||||||
try (BufferedReader reader = process.inputReader()) {
|
try (BufferedReader reader = process.inputReader()) {
|
||||||
for (String l : reader.lines().toList()) {
|
for (String l : reader.lines().toList()) {
|
||||||
|
@ -100,13 +101,21 @@ public class PacketHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.printf("Ping request #%d to %s - %s avg %.3f / mdev %.3f ms\n", packet.requestId, packet.target.getHostAddress(), status, average, meanDeviation);
|
var code = process.waitFor();
|
||||||
Packets.send(new PingResponsePacket(packet.requestId, status, average, meanDeviation), outputStream);
|
if (code != 0) {
|
||||||
} catch (IOException e) {
|
System.out.printf("ping returned " + code);
|
||||||
System.err.println("Error executing ping request");
|
}
|
||||||
e.printStackTrace();
|
|
||||||
|
} catch (IOException | InterruptedException e) {
|
||||||
|
System.err.println("Error executing ping request: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.printf("Ping request #%d to %s - %s avg %.3f / mdev %.3f ms\n", packet.requestId, packet.target.getHostAddress(), status, average, meanDeviation);
|
||||||
|
try {
|
||||||
|
Packets.send(new PingResponsePacket(packet.requestId, status, average, meanDeviation), outputStream);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue