node-macaddress icon indicating copy to clipboard operation
node-macaddress copied to clipboard

Error on Ubuntu 20.04 with wifi off

Open chetbox opened this issue 4 years ago • 0 comments

Hi! Firstly, thanks for this great library!

I got this error using macaddress 0.5.2 on Ubuntu 20.04, but only when I turn off wifi . It looks to me like the output of a command isn't being parsed properly:

Failed to get MAC address [
  "Error: invalid iface: 'enx00e04d3a478a\n" +
    'lo\n' +
    "wlp0s20f3' (must conform to reg exp //^[a-z0-9]+$/i/)\n" +
    '    at Object../node_modules/macaddress/lib/getmacaddress.js.module.exports [as getMacAddress] (http://localhost:3000/account/index.js:102475:18)\n' +
    ...

The code that give this error looks like this:

import { one as macAddress } from 'macaddress';

async function foo() {
    try {
      return `MAC:${await macAddress()}`;
    } catch (error) {
      console.warn('Failed to get MAC address', error);
    }

    // return something else
    // ...
}

In our case we use the MAC address as a machine identifier but this means we cannot identify the machine when it is offline.

chetbox avatar Sep 29 '21 09:09 chetbox