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

Ability to obtain the default gateway #5417

Closed
silverwind opened this issue Feb 24, 2016 · 5 comments
Closed

Ability to obtain the default gateway #5417

silverwind opened this issue Feb 24, 2016 · 5 comments
Labels
feature request Issues that request new features to be added to Node.js. libuv Issues and PRs related to the libuv dependency or the uv binding. os Issues and PRs related to the os subsystem.

Comments

@silverwind
Copy link
Contributor

I think it would be very useful to have a method on os which returns

  • the default gateway of the machine, v4 and v6
  • the default gateway's network interface name (if any)

Basically, something like @indutny's netroute but cross-platform. The ability to access this information seems critical for applications that do low-level things on the local network and I think this justifies its existance in core. My personal use case would be to automatically determine the right interface to do packet capture on.

Right now, the only way (without native modules) to obtain the information in a cross-platform way would be parsing the output of various commands, which is of course slow and error-prone.

@bnoordhuis: the request has been brought up in 2012 and you rejected it as bloat. Does this still stand?

cc: @sindresorhus (sindresorhus/internal-ip#5)

@silverwind silverwind added os Issues and PRs related to the os subsystem. feature request Issues that request new features to be added to Node.js. labels Feb 24, 2016
@silverwind silverwind changed the title Ability to obtain the default gateway and related information Ability to obtain the default gateway Feb 24, 2016
@bnoordhuis
Copy link
Member

It would have to be implemented in libuv first and it would need to be generic enough to be useful. It should provide more than just the defaults and do something sane on multi-homed machines. Routing can be pretty complicated so there's a lot of potential for complexity.

@Fishrock123 Fishrock123 added the libuv Issues and PRs related to the libuv dependency or the uv binding. label Feb 24, 2016
@indutny
Copy link
Member

indutny commented Feb 25, 2016

@silverwind IMO, this is complicated non-obvious thing. Don't know if libuv may want to have it. Routing is hard.

@silverwind
Copy link
Contributor Author

Yes, I see networkInterfaces as kind of borderline for libuv's purpose of being a IO library, this one may be too.

@jasnell
Copy link
Member

jasnell commented May 4, 2016

Is there reason to keep this one open? given the responses it's not likely to be something we'll actually get. Perhaps open a feature request in libuv instead?

@silverwind
Copy link
Contributor Author

I guess we can close it. It's still a desireable future in my eyes, but probably too hard to get right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. libuv Issues and PRs related to the libuv dependency or the uv binding. os Issues and PRs related to the os subsystem.
Projects
None yet
Development

No branches or pull requests

5 participants