"Could not find a nameserver in the Windows Registry" out-of-the-box on Windows
Daniel15 opened this issue · comments
Daniel Lo Nigro commented
I'm hitting this exception when trying to use this library:
Fatal error: Uncaught exception 'Amp\Dns\ResolutionException' with message 'Could not find a nameserver in the Windows Registry.' in C:\src\dnstools.ws\vendor\amphp\dns\lib\DefaultResolver.php:383
Stack trace:
#0 [internal function]: Amp\Dns\DefaultResolver::loadResolvConf()
#1 C:\src\dnstools.ws\vendor\amphp\amp\lib\functions.php(874): Generator->throw(Object(Amp\WindowsRegistry\KeyNotFoundException))
#2 [internal function]: Amp\__coroutineSend(Object(Amp\WindowsRegistry\KeyNotFoundException), NULL, Object(Amp\CoroutineState))
#3 C:\src\dnstools.ws\vendor\amphp\amp\lib\Placeholder.php(91): call_user_func('Amp\\__coroutine...', Object(Amp\WindowsRegistry\KeyNotFoundException), NULL, Object(Amp\CoroutineState))
#4 C:\src\dnstools.ws\vendor\amphp\amp\lib\PrivatePromisor.php(20): Amp\PrivatePlaceholder->resolve(Object(Amp\WindowsRegistry\KeyNotFoundException), NULL)
#5 [internal function]: Amp\PrivatePlaceholder->Amp\{closure}(Object(Amp\WindowsRegistry\KeyNotFoundException), NULL)
#6 C:\src\dnstools.ws\vendor\amphp\amp\lib\ in C:\src\dnstools.ws\vendor\amphp\dns\lib\DefaultResolver.php on line 383
Looking at
Lines 353 to 372 in 8659b56
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\NameServer
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DhcpNameServer
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{guid}\NameServer
However, on my computer, the DNS server is at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{55de6892-f5b0-4632-aeb8-d34874155c77}\DhcpNameServer
.
Instead of just looking at Interfaces\{guid}\NameServer
, I think it should also look for Interfaces\{guid}\DchpNameServer
.
I'm on Windows 10, using DHCP.
Niklas Keller commented
Thanks for the report, I added support for that.
Niklas Keller commented
It's included in https://github.com/amphp/dns/releases/tag/v0.8.14.