[RFC] Detect system default resolver#52
Conversation
|
#48 adds a TimeoutExecutor, would it make sense to read the timeout option from resolve.conf and use that value to create the TimeoutExecutor? |
Most certainly! If @reactphp/core likes the proposed external API I'll go more in depth and add more features like the timeout option 😄 . |
|
Any news on this guys? Any chance for it to being merged in next week? |
|
What's with Windows? This PR will result in many written apps not being able to run on Windows. |
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?
|
@clue we could go with something like this, where $loop = React\EventLoop\Factory::create();
$factory = new React\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.
|
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.