From 99ab85d7d3a97b8795528e1834bc9be81e107388 Mon Sep 17 00:00:00 2001 From: Christian Hofmaier Date: Thu, 18 Apr 2019 00:12:29 +0000 Subject: [wolhelper] add sanity checks --- server/lib/wolhelper.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/lib/wolhelper.js b/server/lib/wolhelper.js index e9cb3b0..97c0958 100644 --- a/server/lib/wolhelper.js +++ b/server/lib/wolhelper.js @@ -5,13 +5,15 @@ function wakeUp (clients) { const loop = () => { setTimeout(() => { let client = clients[i] - console.log('Waking up: ' + client.name + ' (' + client.mac + ')') - wol.wake(client.mac, { address: client.ip.slice(0, client.ip.lastIndexOf('.') + 1) + '255' }, err => { if (err) console.log(err) }) + if (client.mac !== null && client.ip !== null) { + console.log('Waking up: ' + client.name + ' (' + client.mac + ')') + wol.wake(client.mac, { address: client.ip.slice(0, client.ip.lastIndexOf('.') + 1) + '255' }, err => { if (err) console.log(err) }) + } i++ if (i < clients.length) loop() }, 10) } - loop() + if (clients.length !== 0) loop() } module.exports = { wakeUp } -- cgit v1.2.3-55-g7522