1
0
mirror of https://github.com/danog/dns.git synced 2024-11-27 04:24:48 +01:00
dns/examples/custom-config.php
Aaron Piotrowski bd86e80712
Rename Config to DnsConfig
We've been trying to avoid such generic names in other libraries.
2022-07-04 15:24:42 -05:00

28 lines
618 B
PHP

<?php
require __DIR__ . "/_bootstrap.php";
use Amp\Dns;
$customConfigLoader = new class implements Dns\DnsConfigLoader {
public function loadConfig(): Dns\DnsConfig
{
$hosts = (new Dns\HostLoader)->loadHosts();
return new Dns\DnsConfig([
"8.8.8.8:53",
"[2001:4860:4860::8888]:53",
], $hosts, 5, 3);
}
};
Dns\resolver(new Dns\Rfc1035StubResolver(null, $customConfigLoader));
$hostname = $argv[1] ?? "amphp.org";
try {
pretty_print_records($hostname, Dns\resolve($hostname));
} catch (Dns\DnsException $e) {
pretty_print_error($hostname, $e);
}