Quoting drbrain / segment7.net, on Fri, Jun 10, 2005 at 06:39:16PM +0900:
> I would like to retrieve the TTL values from Resolv, but they seem to  
> get thrown away long before they're near the public API, and digging  

No, thrown away just before you need it.

#each_resource calls #extract_resource, which yields only the resource data,
but not the TTL.

> through the guts of Resolv::DNS would only result in much duplicate  
> code.

This is a pseudo-patch, its not backwards compatible, and certainly not tested.

Wanting the TTL is very reasonable, it seems to me. If you can deal with the
backwards compat, you might be able to Tanaka.


Index: net/dns/resolv.rb
===================================================================
--- net/dns/resolv.rb   (revision 201)
+++ net/dns/resolv.rb   (working copy)
@@ -544,7 +544,7 @@
       if typeclass < Resource::ANY
         n0 = Name.create(name)
         msg.each_answer {|n, ttl, data|
-          yield data if n0 == n
+          yield data, ttl if n0 == n
         }
       end
       yielded = false
@@ -553,7 +553,7 @@
         if n0 == n
           case data
           when typeclass
-            yield data
+            yield data, ttl
             yielded = true
           when Resource::CNAME
             n0 = data.name
@@ -565,7 +565,7 @@
         if n0 == n
           case data
           when typeclass
-            yield data
+            yield data, ttl
           end
         end
       }