2017-09-12 09:38:26 +02:00
|
|
|
<?php
|
|
|
|
|
2017-09-12 17:05:40 +02:00
|
|
|
require __DIR__ . "/_bootstrap.php";
|
2017-09-12 09:38:26 +02:00
|
|
|
|
|
|
|
use Amp\Dns;
|
|
|
|
use Amp\Loop;
|
|
|
|
use Amp\Promise;
|
|
|
|
|
|
|
|
$customConfigLoader = new class implements Dns\ConfigLoader {
|
2019-01-25 02:27:47 +01:00
|
|
|
public function loadConfig(): Promise
|
|
|
|
{
|
2017-09-12 09:38:26 +02:00
|
|
|
return Amp\call(function () {
|
|
|
|
$hosts = yield (new Dns\HostLoader)->loadHosts();
|
|
|
|
|
|
|
|
return new Dns\Config([
|
|
|
|
"8.8.8.8:53",
|
|
|
|
"[2001:4860:4860::8888]:53",
|
|
|
|
], $hosts, $timeout = 5000, $attempts = 3);
|
|
|
|
});
|
2017-09-12 09:39:42 +02:00
|
|
|
}
|
2017-09-12 09:38:26 +02:00
|
|
|
};
|
|
|
|
|
2019-03-13 17:24:25 +01:00
|
|
|
Dns\resolver(new Dns\Rfc1035StubResolver(null, $customConfigLoader));
|
2017-09-12 09:38:26 +02:00
|
|
|
|
2019-12-12 20:09:10 +01:00
|
|
|
Loop::run(function () use ($argv) {
|
|
|
|
$hostname = $argv[1] ?? "amphp.org";
|
2017-09-12 17:05:40 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
pretty_print_records($hostname, yield Dns\resolve($hostname));
|
2019-01-04 18:20:52 +01:00
|
|
|
} catch (Dns\DnsException $e) {
|
2017-09-12 17:05:40 +02:00
|
|
|
pretty_print_error($hostname, $e);
|
|
|
|
}
|
2017-09-12 09:38:26 +02:00
|
|
|
});
|