From 45ab9b512b493650b4f3cbc55e4b5cf513f3eb5c Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Sun, 5 Feb 2017 09:49:46 +0100 Subject: [PATCH] Search for DhcpNameServer in interfaces on Windows Resolves #49. --- lib/DefaultResolver.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/DefaultResolver.php b/lib/DefaultResolver.php index d9080db..dd746f9 100644 --- a/lib/DefaultResolver.php +++ b/lib/DefaultResolver.php @@ -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) { } + } } }