Skip to content

Commit

Permalink
Merge pull request #11 from TheBeastOfCaerbannog/master
Browse files Browse the repository at this point in the history
Workaround for Windows 10 WSL
  • Loading branch information
scravy authored Jun 23, 2018
2 parents 68ecfae + 43238cd commit b83e3f8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,21 @@ function parallel(tasks, done) {
}

lib.networkInterfaces = function () {
var ifaces = os.networkInterfaces();
var allAddresses = {};

try {
var ifaces = os.networkInterfaces();
} catch (e) {
// At October 2016 WSL does not support os.networkInterfaces() and throws
// Return empty object as if no interfaces were found
// https://github.com/Microsoft/BashOnWindows/issues/468
if (e.syscall === 'uv_interface_addresses') {
return allAddresses;
} else {
throw e;
};
};

Object.keys(ifaces).forEach(function (iface) {
var addresses = {};
var hasAddresses = false;
Expand Down Expand Up @@ -68,7 +81,7 @@ switch (os.platform()) {
case 'freebsd':
_getMacAddress = require('./lib/unix.js');
break;

default:
console.warn("node-macaddress: Unknown os.platform(), defaulting to 'unix'.");
_getMacAddress = require('./lib/unix.js');
Expand Down

0 comments on commit b83e3f8

Please sign in to comment.