Git Product home page Git Product logo

Comments (6)

agnat avatar agnat commented on July 30, 2024

Unfortunately there is no generic way to do it. os.networkInterfaces() skips interfaces that have no address assigned. I've been thinking about proposing a patch to node to get all interfaces. However, if all interfaces have an address there is a hackish way to do it. See #31 for details.

This one is bugging me for quite some time. I'll see what I can do about it.

Thanks for the kind words regarding the documentation.

from node_mdns.

coolaj86 avatar coolaj86 commented on July 30, 2024

Is interfaceIndex a "standard" sort of thing used in various c libs? Perhaps we could suggest to the node devs that they add the interfaceIndex attribute to os.networkInterfaces()?

I believe that should be doable without any API breakage.

from node_mdns.

agnat avatar agnat commented on July 30, 2024

Well it's not exactly standard, but many cross platform libraries do it that way. That's because it's the simplest thing to do in C. I'd still prefer an optional boolean flag. os.networkInterfaces(true) returns the full list while os.networkInterfaces() returns only those with an address. That doesn't break the API and is a little bit more generic IMHO. Think about a network manager written in node that wants to assign addresses to unconfigured interfaces &c. But I wouldn't mind. Any solution would do...

I already looked into it. Implementing it is pretty straight forward. However, I have to deal with this IOWatcher issue (#34 and #38) first, because that's an actual show stopper.

from node_mdns.

agnat avatar agnat commented on July 30, 2024

Sorry for the long delay. But finally there is some progress on this:

  1. serviceUp and serviceDown events now have a human readable networkInterface property. The strings are compatible with those returned by os.networkInterfaces().
  2. mdns.createBrowser() and mdns.createAdvertisement() now support a networkInterface option. It may be set to an interface name, an IP address or an interface index.
  3. The user guide has a new section on network interfaces.

It isn't released yet, because I have to do some more testing. Just check out the master branch if you want to take a look. The raw version of the user guide is here: https://github.com/agnat/node_mdns/blob/master/doc/pages/user_guide.ejs

Thanks for your patience ;)

from node_mdns.

coolaj86 avatar coolaj86 commented on July 30, 2024

Awesome. Thanks.

from node_mdns.

agnat avatar agnat commented on July 30, 2024

I'm about to release v1.1.0 which contains lots of improvements regarding network interface handling. I'm closing this issue.

Have fun...

from node_mdns.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.