Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allInterfaces - won't work with nodejs version 18. #80

Closed
erossignon opened this issue May 13, 2022 · 2 comments
Closed

allInterfaces - won't work with nodejs version 18. #80

erossignon opened this issue May 13, 2022 · 2 comments

Comments

@erossignon
Copy link

in nodejs 18, os.networkInterfaces() now set familly to be either 4 or 6 instead of 'IPv6' || 'IPv4'

image

As a consequence allInterfaces() method is failing.

function allInterfaces () {
  var networks = os.networkInterfaces()
  var names = Object.keys(networks)
  var res = []

  for (var i = 0; i < names.length; i++) {
    var net = networks[names[i]]
    for (var j = 0; j < net.length; j++) {
      var iface = net[j]
      if (iface.family === 'IPv4') {
        res.push(iface.address)
        // could only addMembership once per interface (https://nodejs.org/api/dgram.html#dgram_socket_addmembership_multicastaddress_multicastinterface)
        break
      }
    }
  }

  return res
}

We need to replace

   if (iface.family === 'IPv4') 

with

   if (iface.family === 'IPv4'  || iface.family === 4)
erossignon added a commit to node-opcua/multicast-dns that referenced this issue May 13, 2022
erossignon added a commit to node-opcua/multicast-dns that referenced this issue May 14, 2022
@erossignon
Copy link
Author

erossignon commented May 14, 2022

@mafintosh
Copy link
Owner

fixed in master and latest release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants