MCPcopy
hub / github.com/feross/spoof / getInterfaceMAC

Function getInterfaceMAC

index.js:241–255  ·  view source on GitHub ↗

* Returns currently-set MAC address of given interface. This is distinct from the * interface's hardware MAC address. * @return {string}

(device)

Source from the content-addressed store, hash-verified

239 * @return {string}
240 */
241function 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`.

Callers 2

findInterfacesDarwinFunction · 0.85
findInterfacesLinuxFunction · 0.85

Calls 1

normalizeFunction · 0.70

Tested by

no test coverage detected