summaryrefslogtreecommitdiffstats
path: root/server/lib/wolhelper.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/wolhelper.js')
-rw-r--r--server/lib/wolhelper.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/server/lib/wolhelper.js b/server/lib/wolhelper.js
index c840e44..eaca0e6 100644
--- a/server/lib/wolhelper.js
+++ b/server/lib/wolhelper.js
@@ -8,7 +8,10 @@ function wakeUp (clients) {
const loop = () => {
setTimeout(() => {
let client = clients[i]
- if (client.mac !== null && client.ip !== null) {
+
+ // Regex for mac address
+ const regex = /^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$/
+ if (client.mac !== null && client.ip !== null && regex.test(client.mac)) {
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) })
log({
@@ -20,7 +23,7 @@ function wakeUp (clients) {
} else {
log({
category: 'ERROR_WAKE_ON_LAN',
- description: 'Client is missing ip or mac address.',
+ description: 'Client has an invalid ip or mac address.',
client,
clientId: client.id
})