Skip to content

Commit

Permalink
fix: ignore wrong mac address on node 8.x (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 authored Aug 24, 2017
1 parent f5cee41 commit ed491c5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
sudo: false
language: node_js
node_js:
- '8'
- '6'
- '4'
script: 'npm run test-travis'
Expand Down
15 changes: 10 additions & 5 deletions lib/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ function getInterfaceName() {
}

function getIfconfigCMD() {
var val = '/sbin/ifconfig';
var platform = os.platform();
if (platform === 'win32') {
val = 'ipconfig/all';
if (os.platform() === 'win32') {
return 'ipconfig/all';
}
return val;
return '/sbin/ifconfig';
}

/**
Expand Down Expand Up @@ -193,6 +191,13 @@ address.mac = function (interfaceName, callback) {
return callback();
}

// https://github.com/nodejs/node/issues/13581
// bug in node 7.x and <= 8.4.0
if (!process.env.CI && (item.mac === 'ff:00:00:00:00:00' || item.mac === '00:00:00:00:00:00')) {
// wrong address, ignore it
item.mac = '';
}

if (item.mac) {
return callback(null, item.mac);
}
Expand Down

0 comments on commit ed491c5

Please sign in to comment.