mirror of
https://github.com/danog/dns.git
synced 2025-01-22 21:41:11 +01:00
Niklas Keller
1a41089d84
Fix BasicResolver::resolve to break redirect loop
Previously we queried domains usually five times (max redirects). It didn't have much impact, because these records were usually cached and immediately returned again, but this resulted in the TTL always being NULL due to cached records being returned.
dns
amphp/dns
provides asynchronous DNS name resolution for Amp.
Installation
composer require amphp/dns
Example
<?php
require __DIR__ . '/vendor/autoload.php';
use Amp\Dns;
use Amp\Loop;
Loop::run(function () {
$githubIpv4 = yield Dns\resolve("github.com", Dns\Record::A);
var_dump($githubIpv4);
$googleIpv4 = Amp\Dns\resolve("google.com", Dns\Record::A);
$googleIpv6 = Amp\Dns\resolve("google.com", Dns\Record::AAAA);
$firstGoogleResult = yield Amp\Promise\first([$googleIpv4, $googleIpv6]);
var_dump($firstGoogleResult);
$combinedGoogleResult = yield Amp\Dns\resolve("google.com");
var_dump($combinedGoogleResult);
$googleMx = yield Amp\Dns\query("google.com", Amp\Dns\Record::MX);
var_dump($googleMx);
});
Languages
PHP
98.6%
Makefile
1.4%