some don't support that
All checks were successful
/ deploy (push) Successful in 29s

This commit is contained in:
Minecon724 2024-12-27 13:21:21 +01:00
parent b3752fd4ae
commit 32723679e1
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8

View file

@ -81,7 +81,8 @@ public class PacketHandler {
var status = PingResponsePacket.PingResponseStatus.ERROR;
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()) {
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);
Packets.send(new PingResponsePacket(packet.requestId, status, average, meanDeviation), outputStream);
} catch (IOException e) {
System.err.println("Error executing ping request");
e.printStackTrace();
var code = process.waitFor();
if (code != 0) {
System.out.printf("ping returned " + code);
}
} 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);
}
});
}