aboutsummaryrefslogtreecommitdiffstats
path: root/lib/resolv.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/resolv.rb')
-rw-r--r--lib/resolv.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/resolv.rb b/lib/resolv.rb
index fc3c78215b..ab10a79d72 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.