dns-over-https/examples/ptr-record.php

20 lines
501 B
PHP
Raw Normal View History

2022-12-18 14:37:59 +01:00
<?php declare(strict_types=1);
2019-06-10 19:32:28 +02:00
require __DIR__ . "/_bootstrap.php";
use Amp\Dns;
2023-01-12 15:49:35 +01:00
use Amp\Dns\DnsRecord;
2019-06-11 15:22:50 +02:00
use Amp\DoH;
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-11 16:40:22 +02:00
$DohConfig = new DoH\DoHConfig([new DoH\Nameserver('https://mozilla.cloudflare-dns.com/dns-query')]);
2023-01-12 15:49:35 +01:00
Dns\dnsResolver(new DoH\Rfc8484StubDohResolver($DohConfig));
2019-06-11 15:22:50 +02:00
2022-10-29 20:03:07 +02:00
$ip = $argv[1] ?? "8.8.8.8";
2019-06-10 19:32:28 +02:00
2022-10-29 20:03:07 +02:00
try {
2023-01-12 15:49:35 +01:00
pretty_print_records($ip, Dns\query($ip, DnsRecord::PTR));
2022-10-29 20:03:07 +02:00
} catch (Dns\DnsException $e) {
pretty_print_error($ip, $e);
}