1
0
mirror of https://github.com/danog/dns.git synced 2024-11-26 20:14:51 +01:00

Resolve localhost locally as per RFC 6761

This commit is contained in:
Daniil Gentili 2018-12-24 13:12:09 +01:00
parent e943bcfde7
commit 2cc9e78a96

View File

@ -115,6 +115,17 @@ final class BasicResolver implements Resolver {
$name = normalizeDnsName($name);
if (in_array($name, ['localhost', 'localhost.'])) {
switch ($typeRestriction) {
case Record::A:
return [new Record('127.0.0.1', Record::A, null)];
case Record::AAAA:
return [new Record('::1', Record::AAAA, null)];
default:
return [new Record('127.0.0.1', Record::A, null), new Record('::1', Record::AAAA, null)];
}
}
if ($records = $this->queryHosts($name, $typeRestriction)) {
return $records;
}