Skip to content
Closed
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
30 changes: 18 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ on:
jobs:
PHPUnit:
name: PHPUnit (PHP ${{ matrix.php }})
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
php:
- 8.2
- 8.1
- 8.0
- 7.4
Expand All @@ -23,11 +24,12 @@ jobs:
- 5.4
- 5.3
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
ini-file: development
- run: composer install
- run: vendor/bin/phpunit --coverage-text
if: ${{ matrix.php >= 7.3 }}
Expand All @@ -36,26 +38,30 @@ jobs:

PHPUnit-macOS:
name: PHPUnit (macOS)
runs-on: macos-10.15
runs-on: macos-12
continue-on-error: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
coverage: xdebug
ini-file: development
- run: composer install
- run: vendor/bin/phpunit --coverage-text

PHPUnit-hhvm:
name: PHPUnit (HHVM)
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
continue-on-error: true
steps:
- uses: actions/checkout@v2
- uses: azjezz/setup-hhvm@v1
- uses: actions/checkout@v3
- run: cp "$(which composer)" composer.phar && ./composer.phar self-update --2.2 # downgrade Composer for HHVM
- name: Run hhvm composer.phar install
uses: docker://hhvm/hhvm:3.30-lts-latest
with:
version: lts-3.30
- run: composer self-update --2.2 # downgrade Composer for HHVM
- run: hhvm $(which composer) install
- run: hhvm vendor/bin/phpunit
args: hhvm composer.phar install
- name: Run hhvm vendor/bin/phpunit
uses: docker://hhvm/hhvm:3.30-lts-latest
with:
args: hhvm vendor/bin/phpunit
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# Changelog

## 1.11.0 (2023-06-02)

* Feature: Include timeout logic to avoid dependency on reactphp/promise-timer.
(#213 by @clue)

* Improve test suite and project setup and report failed assertions.
(#210 by @clue, #212 by @WyriHaximus and #209 and #211 by @SimonFrings)

## 1.10.0 (2022-09-08)

* Feature: Full support for PHP 8.2 release.
(#201 by @clue and #207 by @WyriHaximus)

* Feature: Optimize forward compatibility with Promise v3, avoid hitting autoloader.
(#202 by @clue)

* Feature / Fix: Improve error reporting when custom error handler is used.
(#197 by @clue)

* Fix: Fix invalid references in exception stack trace.
(#191 by @clue)

* Minor documentation improvements.
(#195 by @SimonFrings and #203 by @nhedger)

* Improve test suite, update to use default loop and new reactphp/async package.
(#204, #205 and #206 by @clue and #196 by @SimonFrings)

## 1.9.0 (2021-12-20)

* Feature: Full support for PHP 8.1 release and prepare PHP 8.2 compatibility
Expand Down
34 changes: 28 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ easily be used to create a DNS server.
* [Advanced usage](#advanced-usage)
* [UdpTransportExecutor](#udptransportexecutor)
* [TcpTransportExecutor](#tcptransportexecutor)
* [DNS over TLS](#dns-over-tls-dot)
* [SelectiveTransportExecutor](#selectivetransportexecutor)
* [HostsFileExecutor](#hostsfileexecutor)
* [Install](#install)
Expand Down Expand Up @@ -115,7 +116,7 @@ See also the wiki for possible [cache implementations](https://github.com/reactp

### resolve()

The `resolve(string $domain): PromiseInterface<string,Exception>` method can be used to
The `resolve(string $domain): PromiseInterface<string>` method can be used to
resolve the given $domain name to a single IPv4 address (type `A` query).

```php
Expand Down Expand Up @@ -151,7 +152,7 @@ $promise->cancel();

### resolveAll()

The `resolveAll(string $host, int $type): PromiseInterface<array,Exception>` method can be used to
The `resolveAll(string $host, int $type): PromiseInterface<array>` method can be used to
resolve all record values for the given $domain name and query $type.

```php
Expand Down Expand Up @@ -336,6 +337,27 @@ $executor = new CoopExecutor(
packages. Higher-level components should take advantage of the Socket
component instead of reimplementing this socket logic from scratch.

#### DNS over TLS (DoT)
DoT provides secure DNS lookups over Transport Layer Security (TLS).
The tls:// scheme must be provided when configuring nameservers to
enable DoT communication to a TLS supporting DNS server.
The port 853 is used by default.

```php
$executor = new TcpTransportExecutor('tls://8.8.8.8');
````

> Note: To ensure security and privacy, DoT resolvers typically only support
TLS 1.2 and above. DoT is not supported on legacy PHP < 5.6 and HHVM

##### TLS Configuration
[SSL Context parameters](https://www.php.net/manual/en/context.ssl.php) can be set appending passing query parameters to the nameserver URI in the format `wrapper[parameter]=value`.

```php
// Verify that the 8.8.8.8 resolver's certificate CN matches dns.google
$executor = new TcpTransportExecutor('tls://8.8.8.8?ssl[peer_name]=dns.google');
````

### SelectiveTransportExecutor

The `SelectiveTransportExecutor` class can be used to
Expand Down Expand Up @@ -410,7 +432,7 @@ This project follows [SemVer](https://semver.org/).
This will install the latest supported version:

```bash
$ composer require react/dns:^1.9
composer require react/dns:^1.11
```

See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.
Expand All @@ -426,21 +448,21 @@ To run the test suite, you first need to clone this repo and then install all
dependencies [through Composer](https://getcomposer.org/):

```bash
$ composer install
composer install
```

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

```bash
$ vendor/bin/phpunit
vendor/bin/phpunit
```

The test suite also contains a number of functional integration tests that rely
on a stable internet connection.
If you do not want to run these, they can simply be skipped like this:

```bash
$ vendor/bin/phpunit --exclude-group internet
vendor/bin/phpunit --exclude-group internet
```

## License
Expand Down
16 changes: 10 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,21 @@
"php": ">=5.3.0",
"react/cache": "^1.0 || ^0.6 || ^0.5",
"react/event-loop": "^1.2",
"react/promise": "^3.0 || ^2.7 || ^1.2.1",
"react/promise-timer": "^1.8"
"react/promise": "^3.0 || ^2.7 || ^1.2.1"
},
"require-dev": {
"clue/block-react": "^1.2",
"phpunit/phpunit": "^9.3 || ^4.8.35"
"phpunit/phpunit": "^9.5 || ^4.8.35",
"react/async": "^4 || ^3 || ^2",
"react/promise-timer": "^1.9"
},
"autoload": {
"psr-4": { "React\\Dns\\": "src" }
"psr-4": {
"React\\Dns\\": "src/"
}
},
"autoload-dev": {
"psr-4": { "React\\Tests\\Dns\\": "tests" }
"psr-4": {
"React\\Tests\\Dns\\": "tests/"
}
}
}
14 changes: 11 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- PHPUnit configuration file with new format for PHPUnit 9.3+ -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
<!-- PHPUnit configuration file with new format for PHPUnit 9.5+ -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResult="false"
colors="true"
Expand All @@ -17,4 +17,12 @@
<directory>./src/</directory>
</include>
</coverage>
<php>
<ini name="error_reporting" value="-1" />
<!-- Evaluate assertions, requires running with "php -d zend.assertions=1 vendor/bin/phpunit" -->
<!-- <ini name="zend.assertions=1" value="1" /> -->
<ini name="assert.active" value="1" />
<ini name="assert.exception" value="1" />
<ini name="assert.bail" value="0" />
</php>
</phpunit>
10 changes: 9 additions & 1 deletion phpunit.xml.legacy
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- PHPUnit configuration file with old format for PHPUnit 9.2 or older -->
<!-- PHPUnit configuration file with old format for legacy PHPUnit -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/4.8/phpunit.xsd"
bootstrap="vendor/autoload.php"
Expand All @@ -15,4 +15,12 @@
<directory>./src/</directory>
</whitelist>
</filter>
<php>
<ini name="error_reporting" value="-1" />
<!-- Evaluate assertions, requires running with "php -d zend.assertions=1 vendor/bin/phpunit" -->
<!-- <ini name="zend.assertions=1" value="1" /> -->
<ini name="assert.active" value="1" />
<ini name="assert.exception" value="1" />
<ini name="assert.bail" value="0" />
</php>
</phpunit>
2 changes: 1 addition & 1 deletion src/Query/ExecutorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ interface ExecutorInterface
* ```
*
* @param Query $query
* @return \React\Promise\PromiseInterface<\React\Dns\Model\Message,\Exception>
* @return \React\Promise\PromiseInterface<\React\Dns\Model\Message>
* resolves with response message on success or rejects with an Exception on error
*/
public function query(Query $query);
Expand Down
3 changes: 1 addition & 2 deletions src/Query/RetryExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace React\Dns\Query;

use React\Promise\CancellablePromiseInterface;
use React\Promise\Deferred;
use React\Promise\PromiseInterface;

Expand All @@ -25,7 +24,7 @@ public function query(Query $query)
public function tryQuery(Query $query, $retries)
{
$deferred = new Deferred(function () use (&$promise) {
if ($promise instanceof CancellablePromiseInterface || (!\interface_exists('React\Promise\CancellablePromiseInterface') && \method_exists($promise, 'cancel'))) {
if ($promise instanceof PromiseInterface && \method_exists($promise, 'cancel')) {
$promise->cancel();
}
});
Expand Down
Loading