2022-12-17 11:37:04 -06:00
|
|
|
<?php declare(strict_types=1);
|
2017-09-12 09:38:26 +02:00
|
|
|
|
2017-09-12 17:05:40 +02:00
|
|
|
require __DIR__ . "/_bootstrap.php";
|
2017-09-12 09:38:26 +02:00
|
|
|
|
|
|
|
use Amp\Dns;
|
|
|
|
|
2022-07-04 15:24:42 -05:00
|
|
|
$customConfigLoader = new class implements Dns\DnsConfigLoader {
|
|
|
|
public function loadConfig(): Dns\DnsConfig
|
2019-01-24 19:27:47 -06:00
|
|
|
{
|
2020-11-09 10:47:03 -06:00
|
|
|
$hosts = (new Dns\HostLoader)->loadHosts();
|
2017-09-12 09:38:26 +02:00
|
|
|
|
2022-07-04 15:24:42 -05:00
|
|
|
return new Dns\DnsConfig([
|
2020-11-09 10:47:03 -06:00
|
|
|
"8.8.8.8:53",
|
|
|
|
"[2001:4860:4860::8888]:53",
|
2022-02-03 23:41:14 +01:00
|
|
|
], $hosts, 5, 3);
|
2017-09-12 09:39:42 +02:00
|
|
|
}
|
2017-09-12 09:38:26 +02:00
|
|
|
};
|
|
|
|
|
2023-01-09 23:53:10 +01:00
|
|
|
Dns\dnsResolver(new Dns\Rfc1035StubDnsResolver(null, $customConfigLoader));
|
2017-09-12 09:38:26 +02:00
|
|
|
|
2020-11-09 10:47:03 -06:00
|
|
|
$hostname = $argv[1] ?? "amphp.org";
|
2017-09-12 17:05:40 +02:00
|
|
|
|
2020-11-09 10:47:03 -06:00
|
|
|
try {
|
|
|
|
pretty_print_records($hostname, Dns\resolve($hostname));
|
|
|
|
} catch (Dns\DnsException $e) {
|
|
|
|
pretty_print_error($hostname, $e);
|
|
|
|
}
|