mirror of
https://github.com/fluencelabs/js-libp2p-tcp
synced 2025-04-24 19:42:28 +00:00
fix: intermittent error when asking for interfaces (#137)
Get interfaces only once per run
This commit is contained in:
parent
e9e1f56b87
commit
af9804e778
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user