Skip to content

Instantly share code, notes, and snippets.

@Shinrai
Created June 29, 2025 06:38
Show Gist options
  • Select an option

  • Save Shinrai/33a4cbc13802847f6451340f2592705c to your computer and use it in GitHub Desktop.

Select an option

Save Shinrai/33a4cbc13802847f6451340f2592705c to your computer and use it in GitHub Desktop.
const express = require('express');
const wol = require('wake_on_lan');
const app = express();
app.use(express.json());
app.post('/wake', (req, res) => {
const { mac, ip = '255.255.255.255', port = 9 } = req.body;
if (!mac) {
return res.status(400).json({ error: 'MAC address required' });
}
wol.wake(mac, { address: ip, port }, err => {
if (err) {
console.error('WoL error:', err);
return res.status(500).json({ error: err.message });
}
console.log(`Sent WoL to ${mac} via ${ip}:${port}`);
res.json({ success: true });
});
});
const PORT = process.env.PORT || 3000;
app.listen(PORT, '0.0.0.0', () => console.log(`WOL proxy listening on port ${PORT}`));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment