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

Resolve localhost locally as per RFC 6761

This commit is contained in:
Daniil Gentili 2018-12-24 12:49:01 +01:00 committed by Niklas Keller
parent bb798c6dce
commit d42960ec2d
2 changed files with 11 additions and 11 deletions

View File

@ -27,6 +27,17 @@ final class Config
throw new ConfigException("Invalid attempt count ({$attempts}), must be 1 or greater");
}
// Windows does not include localhost in its host file. Fetch it from the system instead
if (!isset($knownHosts[Record::A]["localhost"]) && !isset($knownHosts[Record::AAAA]["localhost"])) {
// PHP currently provides no way to **resolve** IPv6 hostnames (not even with fallback)
$local = \gethostbyname("localhost");
if ($local !== "localhost") {
$knownHosts[Record::A]["localhost"] = $local;
} else {
$knownHosts[Record::AAAA]["localhost"] = '::1';
}
}
$this->nameservers = $nameservers;
$this->knownHosts = $knownHosts;
$this->timeout = $timeout;

View File

@ -79,17 +79,6 @@ class HostLoader
}
}
// Windows does not include localhost in its host file. Fetch it from the system instead
if (!isset($data[Record::A]["localhost"]) && !isset($data[Record::AAAA]["localhost"])) {
// PHP currently provides no way to **resolve** IPv6 hostnames (not even with fallback)
$local = \gethostbyname("localhost");
if ($local !== "localhost") {
$data[Record::A]["localhost"] = $local;
} else {
$data[Record::AAAA]["localhost"] = "::1";
}
}
return $data;
});
}