Skip to content

Conversation

@daguej
Copy link

@daguej daguej commented Jan 26, 2012

AKA fix it so it doesn't crash as soon as you start up.

Under Windows, /etc/hosts and /etc/resolv.conf obviously don't exist. This patches platform.js so that you can at least get up and running under Windows.

  • Looks for the hosts file at %SYSTEMROOT%\System32\drivers\etc\hosts - seems to work
  • Getting the system's configured nameservers is a bit trickier. There's a Win32 API available (GetNetworkParams), but that means building a native Addon. You could also parse the output of ipconfig.exe /all, but that feels ugly. I just faked it for now using Google's public DNS servers.

@tjfontaine tjfontaine mentioned this pull request Jan 26, 2012
@tjfontaine
Copy link
Owner

After looking around I see that there is also a way forward on windows with the registry entry System\CurrentControlSet\Services\Tcpip\Parameters\Interfaces I would prefer to traverse this with a native mechanism from node itself, but in the absence of that reg query will work

@daguej
Copy link
Author

daguej commented Jan 26, 2012

Let's just do it properly: https://github.com/daguej/node-winnetinfo

@tjfontaine
Copy link
Owner

I'm all for doing things TheRightWay(tm) where possible.

I wonder if doing it properly is to actually use GetAdaptersAddresses since that's what c-ares and .net use. C-ares actually tries GetAdaptersAddresses, if that fails then GetNetworkParams, and if that fails registry. Considering the library is meant as a drop in replacement, it should probably behave similarly where appropriate.

GetAdaptersAddresses is used in uv_interface_addresses on HEAD. There's a part of me that wonders if os.networkInterfaces shouldn't in fact return this information. However most other platforms don't offer a similar interface, so it would be a quirk to win32 but only in the form of an additional field in the object.

So to use a third party solution like your new module for this, means we either include it as a dependency (in which case your module needs to install cleanly on unix platforms and essentially be a NOOP), or we add it as an optionalDependency and handle the case when its not installed gracefully.

Sadly NPM doesn't currently support conditional dependencies (or even platform dependencies for that matter)

Another option would be for native-dns to break a design goal of being pure javascript and have a binding portion just like your module, which is only built for the win32 platform.

@tjfontaine
Copy link
Owner

f6a794d contains some refactoring, watching of /etc/resolv.conf and /etc/hosts are disabled by default, unless someone sets dns.platform.watching at which point it simply doesn't work for windows currently.

On win32 the initial name servers are google's, and the it should theoretically load the proper hosts file.

Please let me know if this works (it's not currently published to npm)

@taoeffect
Copy link
Collaborator

This project is no longer maintained, but we are happy to link to a well maintained fork.

Please see: #111

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

Successfully merging this pull request may close these issues.

3 participants