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:
parent
bb798c6dce
commit
d42960ec2d
@ -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;
|
||||
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user