Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
fix: intermittent error when asking for interfaces (#137)
Browse files Browse the repository at this point in the history
Get interfaces only once per run
  • Loading branch information
mikeal authored Dec 28, 2020
1 parent e9e1f56 commit af9804e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ function isAnyAddr (ip) {
* @param {string} family One of ['IPv6', 'IPv4']
* @returns {string[]} an array of ip address strings
*/
const networks = os.networkInterfaces()
function getNetworkAddrs (family) {
return Object.values(os.networkInterfaces()).reduce((addresses, netAddrs) => {
return Object.values(networks).reduce((addresses, netAddrs) => {
netAddrs.forEach(netAddr => {
// Add the ip of each matching network interface
if (netAddr.family === family) addresses.push(netAddr.address)
Expand Down

0 comments on commit af9804e

Please sign in to comment.