[ruby/resolv] Check for Windows in JRuby-compatible way
https://github.com/ruby/resolv/commit/de95f557b0
This commit is contained in:
parent
d3bd8df2b8
commit
b1d5d1666e
@ -173,11 +173,14 @@ class Resolv
|
|||||||
|
|
||||||
class ResolvTimeout < Timeout::Error; end
|
class ResolvTimeout < Timeout::Error; end
|
||||||
|
|
||||||
|
WINDOWS = /mswin|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM || ::RbConfig::CONFIG['host_os'] =~ /mswin/
|
||||||
|
private_constant :WINDOWS
|
||||||
|
|
||||||
##
|
##
|
||||||
# Resolv::Hosts is a hostname resolver that uses the system hosts file.
|
# Resolv::Hosts is a hostname resolver that uses the system hosts file.
|
||||||
|
|
||||||
class Hosts
|
class Hosts
|
||||||
if /mswin|mingw|cygwin/ =~ RUBY_PLATFORM and
|
if WINDOWS
|
||||||
begin
|
begin
|
||||||
require 'win32/resolv'
|
require 'win32/resolv'
|
||||||
DefaultFileName = Win32::Resolv.get_hosts_path || IO::NULL
|
DefaultFileName = Win32::Resolv.get_hosts_path || IO::NULL
|
||||||
@ -1019,7 +1022,7 @@ class Resolv
|
|||||||
if File.exist? filename
|
if File.exist? filename
|
||||||
config_hash = Config.parse_resolv_conf(filename)
|
config_hash = Config.parse_resolv_conf(filename)
|
||||||
else
|
else
|
||||||
if /mswin|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM
|
if WINDOWS
|
||||||
require 'win32/resolv'
|
require 'win32/resolv'
|
||||||
search, nameserver = Win32::Resolv.get_resolv_info
|
search, nameserver = Win32::Resolv.get_resolv_info
|
||||||
config_hash = {}
|
config_hash = {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user