0

Are there any packages for node that can determine if a PC is on a LAN vs Wifi connection?

I have gone through the node docs and it doesn't appear there is a native node module. (https://nodejs.org/api/os.html)

Could not find anything in NPM that could determine this either.

Nick Codes
  • 35
  • 5

1 Answers1

0

Remember you can run any bash command you want using exec.

So you can do something along the lines of

const util = require('util');
const exec = util.promisify(require('child_process').exec);

async function main() {
  const { stdout, stderr } = await exec('tail -n+3 /proc/net/wireless | grep -q .');

 if (stdout) { // wirelesss }
}

main()

Adapted: determine if connection is wired or wireless?

Toli
  • 5,547
  • 8
  • 36
  • 56