Created
July 14, 2023 10:13
-
-
Save Hermann-SW/d1dfba93834702dca40031e1e9532638 to your computer and use it in GitHub Desktop.
minimal nodejs code to power on wakeonlan enabled PC with given mac address
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// eslinted; send wakeonlan magic packet for mac address defined in m | |
// | |
const m = Buffer.from([0x9c, 0x6b, 0x00, 0x15, 0xbd, 0xc2]); | |
const p = Buffer.concat([Buffer.alloc(6,0xff),m,m,m,m,m,m,m,m,m,m,m,m,m,m,m,m]); | |
const sock = require('dgram').createSocket('udp4').on('listening', function() { | |
sock.setBroadcast(true); | |
sock.send(p, 0, p.length, 9, '255.255.255.255', function() { | |
sock.close(); | |
}); | |
}).bind(); |
Author
Hermann-SW
commented
Jul 14, 2023
I have found it of benefit to send magic packets 3 times, some times the first or second packet is lost, dropped, ignored, etc.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment