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

Search for DhcpNameServer in interfaces on Windows

Resolves #49.
This commit is contained in:
Niklas Keller 2017-02-05 09:49:46 +01:00
parent 6924079756
commit 45ab9b512b

View File

@ -367,10 +367,16 @@ REGEX;
if ($nameserver === "") {
$subKeys = (yield $reader->listKeys("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces"));
while ($nameserver === "" && ($key = array_shift($subKeys))) {
try {
$nameserver = (yield $reader->read("{$key}\\NameServer"));
} catch (KeyNotFoundException $e) { }
foreach ($subKeys as $key) {
foreach (["NameServer", "DhcpNameServer"] as $property) {
try {
$nameserver = (yield $reader->read("{$key}\\{$property}"));
if ($nameserver !== "") {
break 2;
}
} catch (KeyNotFoundException $e) { }
}
}
}