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

22 lines
508 B
PHP
Raw Normal View History

2019-06-10 19:32:28 +02:00
<?php
require __DIR__ . "/_bootstrap.php";
use Amp\Dns;
2019-06-11 15:22:50 +02:00
use Amp\DoH;
2019-06-10 19:32:28 +02:00
use Amp\Loop;
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')]);
2019-06-11 15:22:50 +02:00
Dns\resolver(new DoH\Rfc8484StubResolver($DohConfig));
2019-06-10 19:32:28 +02:00
Loop::run(function () {
$ip = "8.8.8.8";
try {
pretty_print_records($ip, yield Dns\query($ip, Dns\Record::PTR));
} catch (Dns\DnsException $e) {
pretty_print_error($ip, $e);
}
});