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

Fix issue with type restricted resolve and add test

This commit is contained in:
Niklas Keller 2017-06-23 18:35:48 +02:00
parent 3c80f0a4b1
commit a10643fa37
2 changed files with 35 additions and 1 deletions

View File

@ -88,6 +88,8 @@ class BasicResolver implements Resolver {
$this->query($name, Record::A),
$this->query($name, Record::AAAA),
]);
$records = \array_merge(...$records);
} catch (MultiReasonException $e) {
foreach ($e->getReasons() as $reason) {
if ($reason instanceof NoRecordException) {
@ -113,7 +115,7 @@ class BasicResolver implements Resolver {
}
}
return \array_merge(...$records);
return $records;
});
}

View File

@ -27,6 +27,38 @@ class IntegrationTest extends TestCase {
});
}
public function testResolveIPv4only() {
Loop::run(function () {
$records = yield Dns\resolve("google.com", Record::A);
/** @var Record $record */
foreach ($records as $record) {
$this->assertSame(Record::A, $record->getType());
$inAddr = @\inet_pton($record->getValue());
$this->assertNotFalse(
$inAddr,
"Server name google.com did not resolve to a valid IP address"
);
}
});
}
public function testResolveIPv6only() {
Loop::run(function () {
$records = yield Dns\resolve("google.com", Record::AAAA);
/** @var Record $record */
foreach ($records as $record) {
$this->assertSame(Record::AAAA, $record->getType());
$inAddr = @\inet_pton($record->getValue());
$this->assertNotFalse(
$inAddr,
"Server name google.com did not resolve to a valid IP address"
);
}
});
}
public function testPtrLookup() {
Loop::run(function () {
$result = yield Dns\query("8.8.4.4", Record::PTR);