Skip to content
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

Rename DatagramTransportExecutor to UdpTransportExecutor #103

Merged
merged 1 commit into from
Jun 25, 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
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ easily be used to create a DNS server.
* [Caching](#caching)
* [Custom cache adapter](#custom-cache-adapter)
* [Advanced usage](#advanced-usage)
* [DatagramTransportExecutor](#datagramtransportexecutor)
* [UdpTransportExecutor](#udptransportexecutor)
* [HostsFileExecutor](#hostsfileexecutor)
* [Install](#install)
* [Tests](#tests)
Expand Down Expand Up @@ -118,10 +118,10 @@ See also the wiki for possible [cache implementations](https://github.com/reactp

## Advanced Usage

### DatagramTransportExecutor
### UdpTransportExecutor

The `DatagramTransportExecutor` can be used to
send DNS queries over a datagram transport such as UDP.
The `UdpTransportExecutor` can be used to
send DNS queries over a UDP transport.

This is the main class that sends a DNS query to your DNS server and is used
internally by the `Resolver` for the actual message transport.
Expand All @@ -131,7 +131,7 @@ The following example looks up the `IPv6` address for `igor.io`.

```php
$loop = Factory::create();
$executor = new DatagramTransportExecutor($loop);
$executor = new UdpTransportExecutor($loop);

$executor->query(
'8.8.8.8:53',
Expand All @@ -152,7 +152,7 @@ want to use this in combination with a `TimeoutExecutor` like this:

```php
$executor = new TimeoutExecutor(
new DatagramTransportExecutor($loop),
new UdpTransportExecutor($loop),
3.0,
$loop
);
Expand All @@ -165,7 +165,7 @@ combination with a `RetryExecutor` like this:
```php
$executor = new RetryExecutor(
new TimeoutExecutor(
new DatagramTransportExecutor($loop),
new UdpTransportExecutor($loop),
3.0,
$loop
)
Expand All @@ -180,14 +180,14 @@ $executor = new RetryExecutor(

### HostsFileExecutor

Note that the above `Executor` class always performs an actual DNS query.
Note that the above `UdpTransportExecutor` class always performs an actual DNS query.
If you also want to take entries from your hosts file into account, you may
use this code:

```php
$hosts = \React\Dns\Config\HostsFile::loadFromPathBlocking();

$executor = new Executor($loop, new Parser(), new BinaryDumper(), null);
$executor = new UdpTransportExecutor($loop);
$executor = new HostsFileExecutor($hosts, $executor);

$executor->query(
Expand Down
4 changes: 2 additions & 2 deletions examples/04-query-a-and-aaaa.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

use React\Dns\Model\Message;
use React\Dns\Query\DatagramTransportExecutor;
use React\Dns\Query\Query;
use React\Dns\Query\UdpTransportExecutor;
use React\EventLoop\Factory;

require __DIR__ . '/../vendor/autoload.php';

$loop = Factory::create();
$executor = new DatagramTransportExecutor($loop);
$executor = new UdpTransportExecutor($loop);

$name = isset($argv[1]) ? $argv[1] : 'www.google.com';

Expand Down
2 changes: 1 addition & 1 deletion src/Query/Executor.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

/**
* @deprecated unused, exists for BC only
* @see DatagramTransportExecutor
* @see UdpTransportExecutor
*/
class Executor implements ExecutorInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use React\Promise\Deferred;

/**
* Send DNS queries over a datagram transport such as UDP.
* Send DNS queries over a UDP transport.
*
* This is the main class that sends a DNS query to your DNS server and is used
* internally by the `Resolver` for the actual message transport.
Expand All @@ -19,11 +19,11 @@
*
* ```php
* $loop = Factory::create();
* $executor = new DatagramTransportExecutor($loop);
* $executor = new UdpTransportExecutor($loop);
*
* $executor->query(
* '8.8.8.8:53',
* new Query($name, Message::TYPE_AAAA, Message::CLASS_IN, time())
* new Query($name, Message::TYPE_AAAA, Message::CLASS_IN)
* )->then(function (Message $message) {
* foreach ($message->answers as $answer) {
* echo 'IPv6: ' . $answer->data . PHP_EOL;
Expand All @@ -40,7 +40,7 @@
*
* ```php
* $executor = new TimeoutExecutor(
* new DatagramTransportExecutor($loop),
* new UdpTransportExecutor($loop),
* 3.0,
* $loop
* );
Expand All @@ -53,7 +53,7 @@
* ```php
* $executor = new RetryExecutor(
* new TimeoutExecutor(
* new DatagramTransportExecutor($loop),
* new UdpTransportExecutor($loop),
* 3.0,
* $loop
* )
Expand All @@ -66,7 +66,7 @@
* packages. Higher-level components should take advantage of the Datagram
* component instead of reimplementing this socket logic from scratch.
*/
class DatagramTransportExecutor implements ExecutorInterface
class UdpTransportExecutor implements ExecutorInterface
{
private $loop;
private $parser;
Expand Down
4 changes: 2 additions & 2 deletions src/Resolver/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
use React\Cache\CacheInterface;
use React\Dns\Config\HostsFile;
use React\Dns\Query\CachedExecutor;
use React\Dns\Query\DatagramTransportExecutor;
use React\Dns\Query\ExecutorInterface;
use React\Dns\Query\HostsFileExecutor;
use React\Dns\Query\RecordCache;
use React\Dns\Query\RetryExecutor;
use React\Dns\Query\TimeoutExecutor;
use React\Dns\Query\UdpTransportExecutor;
use React\EventLoop\LoopInterface;

class Factory
Expand Down Expand Up @@ -69,7 +69,7 @@ private function decorateHostsFileExecutor(ExecutorInterface $executor)
protected function createExecutor(LoopInterface $loop)
{
return new TimeoutExecutor(
new DatagramTransportExecutor($loop),
new UdpTransportExecutor($loop),
5.0,
$loop
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace React\Tests\Dns\Query;

use React\Tests\Dns\TestCase;
use React\Dns\Query\DatagramTransportExecutor;
use React\Dns\Query\Query;
use React\Dns\Model\Message;
use React\EventLoop\Factory;
use React\Dns\Protocol\Parser;
use React\Dns\Protocol\BinaryDumper;
use React\Dns\Protocol\Parser;
use React\Dns\Query\Query;
use React\Dns\Query\UdpTransportExecutor;
use React\EventLoop\Factory;
use React\Tests\Dns\TestCase;

class DatagramTransportExecutorTest extends TestCase
class UdpTransportExecutorTest extends TestCase
{
public function testQueryRejectsIfMessageExceedsUdpSize()
{
Expand All @@ -20,7 +20,7 @@ public function testQueryRejectsIfMessageExceedsUdpSize()
$dumper = $this->getMockBuilder('React\Dns\Protocol\BinaryDumper')->getMock();
$dumper->expects($this->once())->method('toBinary')->willReturn(str_repeat('.', 513));

$executor = new DatagramTransportExecutor($loop, null, $dumper);
$executor = new UdpTransportExecutor($loop, null, $dumper);

$query = new Query('google.com', Message::TYPE_A, Message::CLASS_IN);
$promise = $executor->query('8.8.8.8:53', $query);
Expand All @@ -34,7 +34,7 @@ public function testQueryRejectsIfServerConnectionFails()
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
$loop->expects($this->never())->method('addReadStream');

$executor = new DatagramTransportExecutor($loop);
$executor = new UdpTransportExecutor($loop);

$query = new Query('google.com', Message::TYPE_A, Message::CLASS_IN);
$promise = $executor->query('///', $query);
Expand All @@ -52,7 +52,7 @@ public function testQueryRejectsOnCancellation()
$loop->expects($this->once())->method('addReadStream');
$loop->expects($this->once())->method('removeReadStream');

$executor = new DatagramTransportExecutor($loop);
$executor = new UdpTransportExecutor($loop);

$query = new Query('google.com', Message::TYPE_A, Message::CLASS_IN);
$promise = $executor->query('8.8.8.8:53', $query);
Expand All @@ -66,7 +66,7 @@ public function testQueryKeepsPendingIfServerRejectsNetworkPacket()
{
$loop = Factory::create();

$executor = new DatagramTransportExecutor($loop);
$executor = new UdpTransportExecutor($loop);

$query = new Query('google.com', Message::TYPE_A, Message::CLASS_IN);

Expand Down Expand Up @@ -94,7 +94,7 @@ public function testQueryKeepsPendingIfServerSendInvalidMessage()
});

$address = stream_socket_get_name($server, false);
$executor = new DatagramTransportExecutor($loop);
$executor = new UdpTransportExecutor($loop);

$query = new Query('google.com', Message::TYPE_A, Message::CLASS_IN);

Expand Down Expand Up @@ -129,7 +129,7 @@ public function testQueryKeepsPendingIfServerSendInvalidId()
});

$address = stream_socket_get_name($server, false);
$executor = new DatagramTransportExecutor($loop, $parser, $dumper);
$executor = new UdpTransportExecutor($loop, $parser, $dumper);

$query = new Query('google.com', Message::TYPE_A, Message::CLASS_IN);

Expand Down Expand Up @@ -164,7 +164,7 @@ public function testQueryRejectsIfServerSendsTruncatedResponse()
});

$address = stream_socket_get_name($server, false);
$executor = new DatagramTransportExecutor($loop, $parser, $dumper);
$executor = new UdpTransportExecutor($loop, $parser, $dumper);

$query = new Query('google.com', Message::TYPE_A, Message::CLASS_IN);

Expand Down Expand Up @@ -203,7 +203,7 @@ public function testQueryResolvesIfServerSendsValidResponse()
});

$address = stream_socket_get_name($server, false);
$executor = new DatagramTransportExecutor($loop, $parser, $dumper);
$executor = new UdpTransportExecutor($loop, $parser, $dumper);

$query = new Query('google.com', Message::TYPE_A, Message::CLASS_IN);

Expand Down