1
0
mirror of https://github.com/danog/dns.git synced 2024-11-30 04:29:06 +01:00

Update docs

This commit is contained in:
Niklas Keller 2021-12-15 23:41:53 +01:00
parent f76797484d
commit 40d5bc8387
2 changed files with 13 additions and 18 deletions

View File

@ -18,23 +18,18 @@ composer require amphp/dns
require __DIR__ . '/examples/_bootstrap.php';
use Amp\Dns;
use Amp\Loop;
$githubIpv4 = Amp\Dns\resolve("github.com", Dns\Record::A);
pretty_print_records("github.com", $githubIpv4);
EventLoop::run(function () {
$githubIpv4 = yield Dns\resolve("github.com", Dns\Record::A);
pretty_print_records("github.com", $githubIpv4);
$googleIpv4 = Amp\Dns\resolve("google.com", Dns\Record::A);
$googleIpv6 = Amp\Dns\resolve("google.com", Dns\Record::AAAA);
$googleIpv4 = Amp\Dns\resolve("google.com", Dns\Record::A);
$googleIpv6 = Amp\Dns\resolve("google.com", Dns\Record::AAAA);
$firstGoogleResult = Amp\Promise\first([$googleIpv4, $googleIpv6]);
pretty_print_records("google.com", $firstGoogleResult);
$firstGoogleResult = yield Amp\Promise\first([$googleIpv4, $googleIpv6]);
pretty_print_records("google.com", $firstGoogleResult);
$combinedGoogleResult = Amp\Dns\resolve("google.com");
pretty_print_records("google.com", $combinedGoogleResult);
$combinedGoogleResult = yield Amp\Dns\resolve("google.com");
pretty_print_records("google.com", $combinedGoogleResult);
$googleMx = yield Amp\Dns\query("google.com", Amp\Dns\Record::MX);
pretty_print_records("google.com", $googleMx);
});
$googleMx = yield Amp\Dns\query("google.com", Amp\Dns\Record::MX);
pretty_print_records("google.com", $googleMx);
```

View File

@ -31,14 +31,14 @@ Usually you don't have to change the resolver. If you want to use a custom confi
// What's returned depends on what's available for the given hostname.
/** @var Amp\Dns\Record[] $records */
$records = yield Amp\Dns\resolve("github.com");
$records = Amp\Dns\resolve("github.com");
```
```php
// Example with type restriction. Will throw an exception if there are no A records.
/** @var Amp\Dns\Record[] $records */
$records = yield Amp\Dns\resolve("github.com", Amp\Dns\Record::A);
$records = Amp\Dns\resolve("github.com", Amp\Dns\Record::A);
```
### Custom Queries
@ -65,7 +65,7 @@ The `Rfc1035StubResolver` (which is the default resolver shipping with that pack
```php
EventLoop::repeat(600, function () use ($resolver) {
yield Amp\Dns\resolver()->reloadConfig();
Amp\Dns\resolver()->reloadConfig();
});
```