summaryrefslogtreecommitdiff
path: root/ext/win32/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-07-31 07:17:25 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-07-31 07:17:25 +0000
commit925d48e4969c9fdcf558ddfa4ac95443eb464393 (patch)
tree44e34cbbe1bdea04da1037a68279b76137cc2622 /ext/win32/lib
parentbfb5b0f84b87387ab85819dd155fb91f1e873e01 (diff)
win32/resolv: get_dns_server_list
* ext/win32/resolv/resolv.c (get_dns_server_list): [Win32] get DNS servers only for connected network devices by GetNetworkParams API. [Bug #12604] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/win32/lib')
-rw-r--r--ext/win32/lib/win32/resolv.rb28
1 files changed, 15 insertions, 13 deletions
diff --git a/ext/win32/lib/win32/resolv.rb b/ext/win32/lib/win32/resolv.rb
index 9505457..6990941 100644
--- a/ext/win32/lib/win32/resolv.rb
+++ b/ext/win32/lib/win32/resolv.rb
@@ -34,6 +34,12 @@ module Win32
[ search, nameserver ]
end
end
+end
+
+begin
+ require 'win32/resolv.so'
+rescue LoadError
+end
nt = Module.new do
break true if [nil].pack("p").size > 4
@@ -48,6 +54,7 @@ if not nt
require_relative 'resolv9x'
# return # does not work yet
else
+module Win32
#====================================================================
# Windows NT
#====================================================================
@@ -64,7 +71,7 @@ else
def get_info
search = nil
- nameserver = []
+ nameserver = get_dns_server_list
Registry::HKEY_LOCAL_MACHINE.open(TCPIP_NT) do |reg|
begin
slist = reg.read_s('SearchList')
@@ -91,20 +98,15 @@ else
reg.open('Interfaces') do |h|
h.each_key do |iface, |
h.open(iface) do |regif|
- begin
- [ 'NameServer', 'DhcpNameServer' ].each do |key|
- begin
- ns = regif.read_s(key)
- rescue
- else
- unless ns.empty?
- nameserver.concat(ns.split(/[,\s]\s*/))
- break
- end
- end
+ next unless ns = %w[NameServer DhcpNameServer].find do |key|
+ begin
+ ns = regif.read_s(key)
+ rescue Registry::Error
+ else
+ break ns.split(/[,\s]\s*/) unless ns.empty?
end
- rescue Registry::Error
end
+ next if (nameserver & ns).empty?
if add_search
begin