Skip to content

Commit

Permalink
Harden adress.family reading
Browse files Browse the repository at this point in the history
  • Loading branch information
scravy committed Jun 23, 2022
1 parent 1722be3 commit 8deea57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.DS_Store
.*
!/.gitignore
!/.editorconfig
!/.travis.yml
!/.github
/node_modules
.*.swp
/.npmcache
/dist
*.log
8 changes: 5 additions & 3 deletions lib/networkinterfaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ module.exports = function () {
return allAddresses;
} else {
throw e;
};
};
}
}

Object.keys(ifaces).forEach(function (iface) {
var addresses = {};
var hasAddresses = false;
ifaces[iface].forEach(function (address) {
if (!address.internal) {
var family = typeof address.family === 'number' ? "ipv" + address.family : address.family.toLowerCase() || "";
var family = (typeof address.family === 'number')
? ("ipv" + address.family)
: (address.family || "").toLowerCase();
addresses[family] = address.address;
hasAddresses = true;
if (address.mac && address.mac !== '00:00:00:00:00:00') {
Expand Down

0 comments on commit 8deea57

Please sign in to comment.