2022-12-18 14:37:59 +01:00
|
|
|
<?php declare(strict_types=1);
|
2019-06-10 19:32:28 +02:00
|
|
|
|
2022-10-29 20:03:07 +02:00
|
|
|
require __DIR__ . "/_bootstrap.php";
|
2019-06-10 19:32:28 +02:00
|
|
|
|
|
|
|
use Amp\Dns;
|
|
|
|
use Amp\DoH;
|
|
|
|
|
2022-10-29 20:03:07 +02:00
|
|
|
$customConfigLoader = new class implements Dns\DnsConfigLoader {
|
|
|
|
public function loadConfig(): Dns\DnsConfig
|
2019-06-10 19:32:28 +02:00
|
|
|
{
|
2022-10-29 20:03:07 +02:00
|
|
|
$hosts = (new Dns\HostLoader)->loadHosts();
|
|
|
|
|
|
|
|
return new Dns\DnsConfig([
|
|
|
|
"8.8.8.8:53",
|
|
|
|
"[2001:4860:4860::8888]:53",
|
2023-01-12 15:49:35 +01:00
|
|
|
], $hosts);
|
2019-06-10 19:32:28 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-06-11 15:22:50 +02:00
|
|
|
// Set default resolver to DNS-over-https resolver
|
2019-06-12 13:48:57 +02:00
|
|
|
$DohConfig = new DoH\DoHConfig(
|
|
|
|
[
|
2023-01-12 15:57:52 +01:00
|
|
|
new DoH\DoHNameserver('https://daniil.it/dns-query'),
|
|
|
|
new DoH\DoHNameserver('https://mozilla.nonexistant-dns.com/dns-query'),
|
|
|
|
new DoH\DoHNameserver('https://mozilla.cloudflare-dns.com/dns-query'), // Will fallback to this
|
2019-06-12 13:48:57 +02:00
|
|
|
],
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
$customConfigLoader
|
|
|
|
);
|
2023-01-12 15:57:52 +01:00
|
|
|
Dns\dnsResolver(new DoH\Rfc8484StubDoHResolver($DohConfig));
|
2019-06-10 19:32:28 +02:00
|
|
|
|
2022-10-29 20:03:07 +02:00
|
|
|
$hostname = $argv[1] ?? "amphp.org";
|
2019-06-10 19:32:28 +02:00
|
|
|
|
2022-10-29 20:03:07 +02:00
|
|
|
try {
|
|
|
|
pretty_print_records($hostname, Dns\resolve($hostname));
|
|
|
|
} catch (Dns\DnsException $e) {
|
|
|
|
pretty_print_error($hostname, $e);
|
|
|
|
}
|