Uh oh!
There was an error while loading. Please reload this page.
[RFC] Detect system default resolver - #52
Conversation
jsor
commented
Feb 23, 2017
#48 adds a TimeoutExecutor, would it make sense to read the timeout option from resolve.conf and use that value to create the TimeoutExecutor? |
WyriHaximus
commented
Feb 23, 2017
Most certainly! If @reactphp/core likes the proposed external API I'll go more in depth and add more features like the timeout option 😄 . |
mailopl
commented
Jul 28, 2017
Any news on this guys? Any chance for it to being merged in next week? |
kelunik
commented
Jul 28, 2017
What's with Windows? This PR will result in many written apps not being able to run on Windows. |
WyriHaximus
commented
Jul 28, 2017
clue
left a comment
There was a problem hiding this comment.
Thanks for filing this ticket @WyriHaximus, I'd love to get this feature in! 👍
I'm currently unsure about its API, but have you seen the (somewhat outdated) https://github.com/reactphp/dns/blob/master/src/Config/FilesystemFactory.php ?
I think it make more sense to keep this in a separate class and then pass the nameserver configuration to the default create*() methods.
What do you think about this?
WyriHaximus
commented
Sep 12, 2017
@clue we could go with something like this, where $loop = React\EventLoop\Factory::create();
$factory = newReact\Dns\Resolver\Factory();
$dns = $factory->createCached(determineSystemDefaultServer('8.8.8.8'), $loop); |
| } | ||
| if (count($nameservers) > 0) { | ||
| shuffle($nameservers); |
There was a problem hiding this comment.
I think it should use the first one, not a random one. I think the first one is considered the primary DNS and order should be respected in /etc/resolv.conf.
| $nameserverPosition = stripos($line, 'nameserver'); | ||
| if ($nameserverPosition !== false) { | ||
| $nameserverLine = trim(substr($line, $nameserverPosition + 11)); | ||
| list ($nameservers[]) = explode(' ', $nameserverLine); |
There was a problem hiding this comment.
There can be only one nameserver per nameserver config option in /etc/resolv.conf.
| return array_pop($nameservers); | ||
| } | ||
| throw new \Exception('Nameserver configuration missing'); |
There was a problem hiding this comment.
man resolv.conf says it should default to the local nameserver if none are present, but Amp doesn't do this either, at least currently.
kelunik
commented
Sep 13, 2017
I added some comments regarding the implementation. While it will usually work to read |
As discussed in #29 a PR that detects the system default resolver on *nix systems.