reduce ping and port timeout to 0.5 sec

This commit is contained in:
Maxi Quoß
2021-09-23 16:39:49 +02:00
parent 996af8e0a5
commit f5e269cefe
2 changed files with 8 additions and 8 deletions

View File

@@ -202,20 +202,20 @@ socket.onmessage = function (event) {
document.getElementById("visitors").innerHTML = message.visitors + ' visitors';
notif.show("Visitors updated", "There are currently " + message.visitors + " visitors", "is-info is-light", 5000);
}
return;
}
// set wake button
if ("wake" in message) {
document.getElementById(message.wake.pk + "-btn-wake").classList.add("is-loading");
notif.show("Wake started", message.wake.fields.name + " has been started.", "is-info is-light", 5000);
return;
}
// set devices up or down
if (message.device.up == true) {
setDeviceUp(message.device);
} else {
setDeviceDown(message.device);
if ("device" in message) {
if (message.device.up == true) {
setDeviceUp(message.device);
} else {
setDeviceDown(message.device);
}
}
}

View File

@@ -15,14 +15,14 @@ channel_layer = get_channel_layer()
class WolDevice:
def ping_device(self, ip):
try:
subprocess.check_output(["ping", "-c", "1", "-W", "1", ip])
subprocess.check_output(["ping", "-c", "1", "-W", "0.5", ip])
return True
except subprocess.CalledProcessError:
return False
def check_port(self, ip, port):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(1)
sock.settimeout(0.5)
if sock.connect_ex((ip, port)) == 0:
return True
return False