mirror of
https://github.com/danog/dns.git
synced 2024-11-26 20:14:51 +01:00
Add example for a custom config
This commit is contained in:
parent
947c0d1022
commit
b33ec8043f
26
examples/custom-config.php
Normal file
26
examples/custom-config.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . "/../vendor/autoload.php";
|
||||
|
||||
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);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Dns\resolver(new Dns\BasicResolver(null, $customConfigLoader));
|
||||
|
||||
Loop::run(function () {
|
||||
var_dump(yield Dns\resolve("google.com"));
|
||||
});
|
Loading…
Reference in New Issue
Block a user