mirror of
https://github.com/seriousm4x/UpSnap.git
synced 2026-07-22 05:32:27 -04:00
reduce ping and port timeout to 0.5 sec
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user