* Returns currently-set MAC address of given interface. This is distinct from the * interface's hardware MAC address. * @return {string}
(device)
| 239 | * @return {string} |
| 240 | */ |
| 241 | function getInterfaceMAC (device) { |
| 242 | if (process.platform === 'darwin' || process.platform === 'linux') { |
| 243 | let output |
| 244 | try { |
| 245 | output = cp.execSync(quote(['ifconfig', device]), { stdio: 'pipe' }).toString() |
| 246 | } catch (err) { |
| 247 | return null |
| 248 | } |
| 249 | |
| 250 | const address = MAC_ADDRESS_RE.exec(output) |
| 251 | return address && normalize(address[0]) |
| 252 | } else if (process.platform === 'win32') { |
| 253 | console.error('No windows support for this method yet - PR welcome!') |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | /** |
| 258 | * Sets the mac address for given `device` to `mac`. |
no test coverage detected