Skip to content

Update DNS dependency to support hosts file on all platforms #112

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 1 commit into from
Aug 25, 2017
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
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -846,12 +846,9 @@ 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 hostnames into underlying IP addresses by default.
This implies that it also ignores your `hosts` file and `resolve.conf`, which
means you won't be able to connect to `localhost` and other non-public
hostnames by default.
If you want to use a custom DNS server (such as a local DNS relay), you can set
up the `Connector` like this:
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:

```php
$connector = new Connector($loop, array(
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.*|0.3.*",
"react/dns": "^0.4.11",
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3.5",
"react/stream": "^1.0 || ^0.7 || ^0.6 || ^0.5 || ^0.4.5",
"react/promise": "^2.1 || ^1.2",
Expand Down
32 changes: 32 additions & 0 deletions tests/FunctionalConnectorTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace React\Tests\Socket;

use Clue\React\Block;
use React\EventLoop\StreamSelectLoop;
use React\Socket\TcpServer;
use React\Socket\Connector;

class FunctionalConnectorTest extends TestCase
{
const TIMEOUT = 1.0;

/** @test */
public function connectionToTcpServerShouldSucceedWithLocalhost()
{
$loop = new StreamSelectLoop();

$server = new TcpServer(9998, $loop);
$server->on('connection', $this->expectCallableOnce());
$server->on('connection', array($server, 'close'));

$connector = new Connector($loop);

$connection = Block\await($connector->connect('localhost:9998'), $loop, self::TIMEOUT);

$this->assertInstanceOf('React\Socket\ConnectionInterface', $connection);

$connection->close();
$server->close();
}
}
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