diff --git a/wol.js b/wol.js index b1a4cd9..478eaa2 100644 --- a/wol.js +++ b/wol.js @@ -1,4 +1,5 @@ import dgram from "node:dgram" +import { exec } from "node:child_process"; export function createWolPacket(mac) { const parts = mac.split(/[:-]/); @@ -38,4 +39,12 @@ export async function sendWolPacket(mac, broadcast = "255.255.255.255", port = 9 }); }); }); +} + +export function ping(ip) { + return new Promise(resolve => { + exec(`ping -c 1 -W 1 ${ip}`, err => { + resolve(!err); + }); + }); } \ No newline at end of file