Created
June 29, 2025 06:38
-
-
Save Shinrai/33a4cbc13802847f6451340f2592705c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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