Skip to content

Commit 0c8d9a6

Browse files
authored
Merge pull request #152 from clue-labs/dns-config
Update DNS dependency and load system default DNS config on all supported platforms
2 parents 9db38c5 + c452f78 commit 0c8d9a6

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ install:
4343
curl -s http://getcomposer.org/installer | php
4444
mv composer.phar /usr/local/bin/composer
4545
fi
46-
- COMPOSER_ROOT_VERSION=`git describe --abbrev=0` composer install --no-interaction
46+
- composer install --no-interaction
4747

4848
script:
4949
- ./vendor/bin/phpunit --coverage-text

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -918,10 +918,12 @@ also shares all of their features and implementation details.
918918
If you want to typehint in your higher-level protocol implementation, you SHOULD
919919
use the generic [`ConnectorInterface`](#connectorinterface) instead.
920920

921-
In particular, the `Connector` class uses Google's public DNS server `8.8.8.8`
922-
to resolve all public hostnames into underlying IP addresses by default.
923-
If you want to use a custom DNS server (such as a local DNS relay or a company
924-
wide DNS server), you can set up the `Connector` like this:
921+
The `Connector` class will try to detect your system DNS settings (and uses
922+
Google's public DNS server `8.8.8.8` as a fallback if unable to determine your
923+
system settings) to resolve all public hostnames into underlying IP addresses by
924+
default.
925+
If you explicitly want to use a custom DNS server (such as a local DNS relay or
926+
a company wide DNS server), you can set up the `Connector` like this:
925927

926928
```php
927929
$connector = new Connector($loop, array(
@@ -1392,12 +1394,10 @@ on affected versions.
13921394
## Tests
13931395

13941396
To run the test suite, you first need to clone this repo and then install all
1395-
dependencies [through Composer](https://getcomposer.org).
1396-
Because the test suite contains some circular dependencies, you may have to
1397-
manually specify the root package version like this:
1397+
dependencies [through Composer](https://getcomposer.org):
13981398

13991399
```bash
1400-
$ COMPOSER_ROOT_VERSION=`git describe --abbrev=0` composer install
1400+
$ composer install
14011401
```
14021402

14031403
To run the test suite, go to the project root and run:

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"require": {
77
"php": ">=5.3.0",
88
"evenement/evenement": "^3.0 || ^2.0 || ^1.0",
9-
"react/dns": "^0.4.11",
9+
"react/dns": "^0.4.13",
1010
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3.5",
1111
"react/stream": "^1.0 || ^0.7.1",
1212
"react/promise": "^2.1 || ^1.2",

src/Connector.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace React\Socket;
44

5+
use React\Dns\Config\Config;
56
use React\Dns\Resolver\Factory;
67
use React\Dns\Resolver\Resolver;
78
use React\EventLoop\LoopInterface;
@@ -56,9 +57,17 @@ public function __construct(LoopInterface $loop, array $options = array())
5657
if ($options['dns'] instanceof Resolver) {
5758
$resolver = $options['dns'];
5859
} else {
60+
if ($options['dns'] !== true) {
61+
$server = $options['dns'];
62+
} else {
63+
// try to load nameservers from system config or default to Google's public DNS
64+
$config = Config::loadSystemConfigBlocking();
65+
$server = $config->nameservers ? reset($config->nameservers) : '8.8.8.8';
66+
}
67+
5968
$factory = new Factory();
6069
$resolver = $factory->create(
61-
$options['dns'] === true ? '8.8.8.8' : $options['dns'],
70+
$server,
6271
$loop
6372
);
6473
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy