1
0
mirror of https://github.com/danog/dns.git synced 2024-11-30 04:29:06 +01:00
dns/examples/custom-config.php

33 lines
782 B
PHP
Raw Normal View History

2017-09-12 09:38:26 +02:00
<?php
require __DIR__ . "/_bootstrap.php";
2017-09-12 09:38:26 +02:00
use Amp\Dns;
use Amp\Loop;
use Amp\Promise;
$customConfigLoader = new class implements Dns\ConfigLoader {
public function loadConfig(): Promise {
return Amp\call(function () {
$hosts = yield (new Dns\HostLoader)->loadHosts();
return new Dns\Config([
"8.8.8.8:53",
"[2001:4860:4860::8888]:53",
], $hosts, $timeout = 5000, $attempts = 3);
});
2017-09-12 09:39:42 +02:00
}
2017-09-12 09:38:26 +02:00
};
Dns\resolver(new Dns\BasicResolver(null, $customConfigLoader));
Loop::run(function () {
$hostname = "amphp.org";
try {
pretty_print_records($hostname, yield Dns\resolve($hostname));
} catch (Dns\ResolutionException $e) {
pretty_print_error($hostname, $e);
}
2017-09-12 09:38:26 +02:00
});