feat: add ping function
This commit is contained in:
9
wol.js
9
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);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user