Skip to content

Commit

Permalink
Merge pull request #41 from clue-labs/dns-multiple
Browse files Browse the repository at this point in the history
Support falling back to multiple DNS servers from DNS config
  • Loading branch information
clue authored Jun 25, 2021
2 parents 4f41115 + e9065b2 commit cf8207f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"php": ">=5.3",
"evenement/evenement": "^3.0 || ^2.0 || ^1.0",
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3",
"react/dns": "^1.1",
"react/dns": "^1.7",
"react/promise": "~2.1|~1.2"
},
"require-dev": {
Expand Down
6 changes: 4 additions & 2 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ public function __construct(LoopInterface $loop, ResolverInterface $resolver = n
if ($resolver === null) {
// try to load nameservers from system config or default to Google's public DNS
$config = DnsConfig::loadSystemConfigBlocking();
$server = $config->nameservers ? \reset($config->nameservers) : '8.8.8.8';
if (!$config->nameservers) {
$config->nameservers[] = '8.8.8.8'; // @codeCoverageIgnore
}

$factory = new DnsFactory();
$resolver = $factory->create($server, $loop);
$resolver = $factory->create($config, $loop);
}

$this->loop = $loop;
Expand Down

0 comments on commit cf8207f

Please sign in to comment.