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

specify device for advertisement and browsing #31

Closed
defunctzombie opened this issue May 17, 2012 · 8 comments
Closed

specify device for advertisement and browsing #31

defunctzombie opened this issue May 17, 2012 · 8 comments

Comments

@defunctzombie
Copy link

Is there a way to specify which network device mdns should advertise on and/or browse? I have multiple virtual devices and would like to use a specific one.

@agnat
Copy link
Owner

agnat commented May 17, 2012

Yes, you can specify an interface index. See http://agnat.github.com/node_mdns/user_guide.html#advertisement

@defunctzombie
Copy link
Author

Gotcha. Is there a way to get a map of these interfaces so I know which index is what interface?

@agnat
Copy link
Owner

agnat commented May 17, 2012

Well, since node v0.5.1 there is os.networkInterfaces()

http://nodejs.org/docs/latest/api/os.html#os_os_networkinterfaces

I haven't tried it yet, but I'd do something like this:

var index = Object.keys(os.networkInterfces()).indexOf('en0') + 1;

@defunctzombie
Copy link
Author

yea, I guess I was looking for clarification on if those two arrays would be in the same order. so that item 0 in os.networkInterfaces => 1 for mdns and so on.

@agnat
Copy link
Owner

agnat commented May 18, 2012

Hm, looking at the libuv sources, I doubt that it will work correctly. libuv omits interfaces that have no address assigned, possibly messing up the index values.

I'll probably file an issue with the node/libuv guys.

@defunctzombie
Copy link
Author

Is the index something the underlying mdns sys libraries accept as a parameter? Do they not accept any sort of string or return a list of valid index <-> string maps? If they do it would be simple enough to make a js wrapping for accepting the interface string and converting that to a valid index.

@agnat
Copy link
Owner

agnat commented May 18, 2012

On 18.05.2012, at 17:23, Roman Shtylman wrote:

Is the index something the underlying mdns sys libraries accept as a parameter?

Yes.

Do they not accept any sort of string

Yes. (No, they don't accept strings)

or return a list of valid index <-> string maps?

No.

If they do it would be simple enough to make a js wrapping for accepting the interface string and converting that to a valid index.

Yes. If such an API existed I would have wrapped it a long time ago … ;-)

I just hesitated to add highly platform specific code which doesn't really belong here. However, now that node has os.networkInterfaces() it's just a matter of nudging their API a little (by adding an exhaustive flag for example).


Reply to this email directly or view it on GitHub:
#31 (comment)

@agnat
Copy link
Owner

agnat commented Dec 18, 2012

Hey @shtylman.

Just wanted to let you know that there is finally some progress on this one. See #42 for details.

Cheers.

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