From f5e269cefed7b8d4541196b16720bf5ddeeb198c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxi=20Quo=C3=9F?= Date: Thu, 23 Sep 2021 16:39:49 +0200 Subject: [PATCH] reduce ping and port timeout to 0.5 sec --- app/wol/static/js/main.js | 12 ++++++------ app/wol/tasks.py | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/wol/static/js/main.js b/app/wol/static/js/main.js index 726eec7a..af2b304f 100644 --- a/app/wol/static/js/main.js +++ b/app/wol/static/js/main.js @@ -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); + } } } diff --git a/app/wol/tasks.py b/app/wol/tasks.py index 6a18d0b2..3e4f7ad0 100644 --- a/app/wol/tasks.py +++ b/app/wol/tasks.py @@ -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