1
0
mirror of https://github.com/danog/dns.git synced 2025-01-23 05:51:11 +01:00
dns/examples/custom-config.php

28 lines
649 B
PHP
Raw Normal View History

2022-12-17 11:37:04 -06:00
<?php declare(strict_types=1);
2017-09-12 09:38:26 +02:00
require __DIR__ . "/_bootstrap.php";
2017-09-12 09:38:26 +02:00
use Amp\Dns;
$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
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";
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);
}