summaryrefslogtreecommitdiffstats
path: root/server/lib
diff options
context:
space:
mode:
authorUdo Walter2019-04-16 16:10:17 +0200
committerUdo Walter2019-04-16 16:10:17 +0200
commit8c7fc0cd3154b8e6b725db2eba9c37abb092c980 (patch)
treed413f6578deee98ec6388276bf4fb564d8030613 /server/lib
parent[server] add 10ms delay between wol packets (diff)
downloadbas-8c7fc0cd3154b8e6b725db2eba9c37abb092c980.tar.gz
bas-8c7fc0cd3154b8e6b725db2eba9c37abb092c980.tar.xz
bas-8c7fc0cd3154b8e6b725db2eba9c37abb092c980.zip
[wol] move wol stuff to lib
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/wolhelper.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/server/lib/wolhelper.js b/server/lib/wolhelper.js
new file mode 100644
index 0000000..fb5bd95
--- /dev/null
+++ b/server/lib/wolhelper.js
@@ -0,0 +1,17 @@
+const wol = require('node-wol')
+
+function wakeUp (clients) {
+ let i = 0
+ 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) })
+ i++
+ if (i < clients.length) loop()
+ }, 10)
+ }
+ loop()
+}
+
+module.exports = { wakeUp } \ No newline at end of file