зеркало из https://github.com/github/ruby.git
* lib/resolv.rb (Resolv::DNS#each_address): don't query IPv6 address
if the host has no global IPv6 address. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
074a374c86
Коммит
c109d8ab9f
|
@ -1,3 +1,8 @@
|
|||
Sat Jan 31 22:38:46 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* lib/resolv.rb (Resolv::DNS#each_address): don't query IPv6 address
|
||||
if the host has no global IPv6 address.
|
||||
|
||||
Sat Jan 31 22:29:05 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* include/ruby/ruby.h (STR2CSTR): removed.
|
||||
|
|
|
@ -379,9 +379,21 @@ class Resolv
|
|||
|
||||
def each_address(name)
|
||||
each_resource(name, Resource::IN::A) {|resource| yield resource.address}
|
||||
each_resource(name, Resource::IN::AAAA) {|resource| yield resource.address}
|
||||
if use_ipv6?
|
||||
each_resource(name, Resource::IN::AAAA) {|resource| yield resource.address}
|
||||
end
|
||||
end
|
||||
|
||||
def use_ipv6?
|
||||
begin
|
||||
list = Socket.ip_address_list
|
||||
rescue NotImplementedError
|
||||
return true
|
||||
end
|
||||
list.any? {|a| a.ipv6? && !a.ipv6_loopback? && !a.ipv6_linklocal? }
|
||||
end
|
||||
private :use_ipv6?
|
||||
|
||||
##
|
||||
# Gets the hostname for +address+ from the DNS resolver.
|
||||
#
|
||||
|
|
Загрузка…
Ссылка в новой задаче