From 8deea57be8a4c404006d6a2885473a903fb92402 Mon Sep 17 00:00:00 2001 From: Julian Fleischer Date: Thu, 23 Jun 2022 08:04:08 +0200 Subject: [PATCH] Harden adress.family reading --- .gitignore | 8 +++++--- lib/networkinterfaces.js | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index b84e8d8..aee6327 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ -.DS_Store +.* +!/.gitignore +!/.editorconfig +!/.travis.yml +!/.github /node_modules -.*.swp -/.npmcache /dist *.log diff --git a/lib/networkinterfaces.js b/lib/networkinterfaces.js index 864db9d..5181ded 100644 --- a/lib/networkinterfaces.js +++ b/lib/networkinterfaces.js @@ -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') {