[JDB - Wed May 7 20:26:19 2003]:
Show quoted text
Ok, the (attached) updated patch should solve bug #2465 and enable
Net::DNS to find the nameservers on Windows 95/98/Me (later part is
untested, but I did verify that
SYSTEM\CurrentControlSet\Services\VxD\MSTCP exists and contains the
relevant information on 95 and Me).
This patch correctly decodes the DNSServerAddresses value of the
DNSRegisteredAdapters key. It now also enumerates *all* interfaces,
instead of just the ones that are also listed under
DNSRegisteredAdapters. That change should fix bug @2465.
This patch includes my earlier one.
--- Resolver.orig Tue Feb 18 13:22:33 2003
+++ Resolver.pm Wed May 07 18:22:54 2003
@@ -196,21 +196,14 @@
sub res_init_microsoft {
my ($resobj, %keys);
-
- # This will *not* work on win95/98/ME...OTOH, who cares?
- # Ok, so some do...simplest is probably to parse output
- # of: (these are best guesses - no such systems to test on)
- # (on 95) 'winipcfg /all /batch'
- # (on 98 & ME) 'ipconfig /all /batch'
- # There might be the required data resident under .../VxD/MSTCP in
- # the registry on those machines but this is hearsay
- # Actually, the trick of parsing 'ipconfig' could be applied
- # to NT/W2K/XP too for some insulation...
-
- my $root = 'SYSTEM\CurrentControlSet\Services\Tcpip\Parameters';
- $main::HKEY_LOCAL_MACHINE->Open($root, $resobj)
- or Carp::croak "can't read registry: $!";
+ my $root = 'SYSTEM\CurrentControlSet\Services\Tcpip\Parameters';
+ unless ($main::HKEY_LOCAL_MACHINE->Open($root, $resobj)) {
+ # Didn't work, maybe we are on 95/98/Me?
+ $root = 'SYSTEM\CurrentControlSet\Services\VxD\MSTCP';
+ $main::HKEY_LOCAL_MACHINE->Open($root, $resobj)
+ or Carp::croak "can't read registry: $!";
+ }
$resobj->GetValues(\%keys)
or Carp::croak "can't read registry values: $!";
@@ -234,12 +227,29 @@
# opt to silently fail if something isn't ok (maybe we're on NT4)
# drop any duplicates later
my $dnsadapters;
- my $interfaces;
$resobj->Open("DNSRegisteredAdapters", $dnsadapters);
+ if ($dnsadapters) {
+ my @adapters;
+ $dnsadapters->GetKeys(\@adapters);
+ foreach my $adapter (@adapters) {
+ my $regadapter;
+ $dnsadapters->Open($adapter, $regadapter);
+ if ($regadapter) {
+ my($type,$ns);
+ $regadapter->QueryValueEx("DNSServerAddresses", $type, $ns);
+ while (length($ns) >= 4) {
+ my $addr = join('.', unpack("C4", substr($ns,0,4,"")));
+ $nameservers .= " $addr";
+ }
+ }
+ }
+ }
+
+ my $interfaces;
$resobj->Open("Interfaces", $interfaces);
- if ($dnsadapters and $interfaces) {
+ if ($interfaces) {
my @ifacelist;
- $dnsadapters->GetKeys(\@ifacelist);
+ $interfaces->GetKeys(\@ifacelist);
foreach my $iface (@ifacelist) {
my $regiface;
$interfaces->Open($iface, $regiface);
@@ -247,6 +257,8 @@
my $ns;
my $type;
$regiface->QueryValueEx("NameServer", $type, $ns);
+ $nameservers .= " $ns" if $ns;
+ $regiface->QueryValueEx("DhcpNameServer", $type, $ns);
$nameservers .= " $ns" if $ns;
}
}