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

Support parsing DNS config from WMIC on Windows #94

Merged
merged 1 commit into from
Feb 26, 2018

Conversation

clue
Copy link
Member

@clue clue commented Feb 26, 2018

This PR implements DNS server config autodetection on Windows by parsing WMIC output. I've looked into reading this from nslookup (works, but blocks when network is not available), ipconfig /all (difficult to parse due to localization), registry (non-trivial implementation) and wmic (which I ended up using). Afaict this command is available on all Windows versions starting with Windows XP and uses some CSV/JSON-based output format that we can parse.

The WMIC command will now be used on Windows by default by the Config class as introduced with #93. This PR includes a number of test cases for the expected WMIC output, but I would to see if anybody else can test this on their local Windows setup. Any feedback is much appreciated!

Builds on top of #92 and #93
Refs #29

@clue clue added this to the v0.4.13 milestone Feb 26, 2018
@jsor jsor merged commit df893c0 into reactphp:master Feb 26, 2018
@clue clue deleted the wmic branch February 26, 2018 20:53
@clue
Copy link
Member Author

clue commented Feb 26, 2018

See also #95 for a follow-up PR to support multiple DNS servers for a single network interface.

I've also had the chance to perform a number of measurements to see how long the WMIC command takes. A usual run takes around 0.15s, with rare (random?) spikes up to 8s on my test server that does nothing in particular. The very first run seems to take ~1.5s.

We may want to eventually look into parsing ipconfig /all which seems to fluctuate less. Note that parsing likely requires more effort as its output is localized (on some Windows versions?). See also https://gist.github.com/search?utf8=%E2%9C%93&q=ipconfig+%2Fall&ref=searchresults, https://stackoverflow.com/questions/41130434/parsing-second-dns-from-ipconfig-all-windows-batch and https://www.google.de/search?q=windows+ipconfig+/all&source=lnms&tbm=isch. PRs are much appreciated 👍

Also, this feature currently returns a list of all DNS servers. It does currently not take "special" DNS servers into account, such as DNS server settings automatically assigned to VirtualBox network interfaces, see https://gist.github.com/clue/ed235ad8d50087d098e4de5fd370b25e#file-gistfile1-txt-L102 and https://www.virtualbox.org/manual/ch09.html#nat-adv-dns.

Practically, this feature is documented to only actually apply the first DNS server from this list (see #93 and also #6). Because phsyical network interfaces seem to always use a smaller "interface ID", this is unlikely to cause any issues for now. PRs to improve this eventually are much appreciated! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants