summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-31 13:40:05 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-31 13:40:05 +0000
commit9cc2d99c022b43f112cf7ddbcc0d80395c420c94 (patch)
tree17f74bbdff8467add49179068c1031bf18c17887 /lib
parentf96333343f0abe20b366929a09b4ac4a194dceb3 (diff)
downloadruby-9cc2d99c022b43f112cf7ddbcc0d80395c420c94.tar.gz
ruby-9cc2d99c022b43f112cf7ddbcc0d80395c420c94.tar.xz
ruby-9cc2d99c022b43f112cf7ddbcc0d80395c420c94.zip
* lib/resolv.rb (Resolv::DNS#each_address): don't query IPv6 address
if the host has no global IPv6 address. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@21921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/resolv.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/resolv.rb b/lib/resolv.rb
index fc3c78215..ab10a79d7 100644
--- a/lib/resolv.rb
+++ b/lib/resolv.rb
@@ -379,8 +379,20 @@ 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.