Skip to content

Commit

Permalink
Merge pull request #257 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 43c9f20 + c37c55c commit dff5fbe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"require": {
"php": ">=5.3.0",
"evenement/evenement": "^3.0 || ^2.0 || ^1.0",
"react/dns": "^1.1",
"react/dns": "^1.7",
"react/event-loop": "^1.0 || ^0.5",
"react/promise": "^2.6.0 || ^1.2.1",
"react/promise-timer": "^1.4.0",
Expand Down
8 changes: 5 additions & 3 deletions src/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,18 @@ public function __construct(LoopInterface $loop, array $options = array())
$resolver = $options['dns'];
} else {
if ($options['dns'] !== true) {
$server = $options['dns'];
$config = $options['dns'];
} else {
// 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->createCached(
$server,
$config,
$loop
);
}
Expand Down

0 comments on commit dff5fbe

Please sign in to comment.