Skip to content

Update DNS dependency and load system default DNS config on all supported platforms #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ install:
curl -s http://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
fi
- COMPOSER_ROOT_VERSION=`git describe --abbrev=0` composer install --no-interaction
- composer install --no-interaction

script:
- ./vendor/bin/phpunit --coverage-text
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -918,10 +918,12 @@ also shares all of their features and implementation details.
If you want to typehint in your higher-level protocol implementation, you SHOULD
use the generic [`ConnectorInterface`](#connectorinterface) instead.

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

```php
$connector = new Connector($loop, array(
Expand Down Expand Up @@ -1392,12 +1394,10 @@ on affected versions.
## Tests

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

```bash
$ COMPOSER_ROOT_VERSION=`git describe --abbrev=0` composer install
$ composer install
```

To run the test suite, go to the project root and run:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"require": {
"php": ">=5.3.0",
"evenement/evenement": "^3.0 || ^2.0 || ^1.0",
"react/dns": "^0.4.11",
"react/dns": "^0.4.13",
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3.5",
"react/stream": "^1.0 || ^0.7.1",
"react/promise": "^2.1 || ^1.2",
Expand Down
11 changes: 10 additions & 1 deletion src/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace React\Socket;

use React\Dns\Config\Config;
use React\Dns\Resolver\Factory;
use React\Dns\Resolver\Resolver;
use React\EventLoop\LoopInterface;
Expand Down Expand Up @@ -56,9 +57,17 @@ public function __construct(LoopInterface $loop, array $options = array())
if ($options['dns'] instanceof Resolver) {
$resolver = $options['dns'];
} else {
if ($options['dns'] !== true) {
$server = $options['dns'];
} else {
// try to load nameservers from system config or default to Google's public DNS
$config = Config::loadSystemConfigBlocking();
$server = $config->nameservers ? reset($config->nameservers) : '8.8.8.8';
}

$factory = new Factory();
$resolver = $factory->create(
$options['dns'] === true ? '8.8.8.8' : $options['dns'],
$server,
$loop
);
}
Expand Down
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