mirror of
https://github.com/danog/dns.git
synced 2024-11-26 20:14:51 +01:00
Update docs
This commit is contained in:
parent
f76797484d
commit
40d5bc8387
25
README.md
25
README.md
@ -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);
|
||||
```
|
||||
|
@ -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();
|
||||
});
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user