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

How to interpret interfaceIndex? #42

Closed
coolaj86 opened this issue Oct 12, 2012 · 6 comments
Closed

How to interpret interfaceIndex? #42

coolaj86 opened this issue Oct 12, 2012 · 6 comments
Milestone

Comments

@coolaj86
Copy link

Any idea how I can map interfaceIndex back to os.networkInterfaces()?

Your documentation is absolutely wonderful, but it seems to be missing this one detail.

@agnat
Copy link
Owner

agnat commented Oct 12, 2012

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.

@coolaj86
Copy link
Author

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.

@agnat
Copy link
Owner

agnat commented Oct 12, 2012

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.

@agnat
Copy link
Owner

agnat commented Dec 18, 2012

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 ;)

@coolaj86
Copy link
Author

Awesome. Thanks.

@agnat
Copy link
Owner

agnat commented Dec 29, 2012

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

Have fun...

@agnat agnat closed this as completed Dec 29, 2012
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