]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
allow BIND 8 TTL syntax in ttl-like places (SOA, SIG, RRSIG)
authorBob Halley <halley@dnspython.org>
Tue, 10 Jan 2006 23:15:41 +0000 (23:15 +0000)
committerBob Halley <halley@dnspython.org>
Tue, 10 Jan 2006 23:15:41 +0000 (23:15 +0000)
ChangeLog
dns/rdtypes/ANY/SOA.py
dns/rdtypes/sigbase.py
dns/tokenizer.py
tests/bugs.py

index 7ad275805657cde72acbc2b279eed678b73260d5..70704975bb5163e0f374c33523972907cdc2cefb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,10 @@
        * dns/ttl.py: TTLs are now bounds checked to be within the closed
          interval [0, 2^31 - 1].
 
+       * The BIND 8 TTL syntax is now accepted in the SOA refresh, retry,
+         expire, and minimum fields, and in the original_ttl field of
+         SIG and RRSIG records.
+
 2006-01-04  Bob Halley  <halley@dnspython.org>
 
        * dns/resolver.py: The windows registry irritatingly changes the
index 9acd56097551f5b2a6e288af37c84520ed1e219c..a40740660f35af3a998eab1b5141c0e675b8a6e6 100644 (file)
@@ -66,10 +66,10 @@ class SOA(dns.rdata.Rdata):
         mname = mname.choose_relativity(origin, relativize)
         rname = rname.choose_relativity(origin, relativize)
         serial = tok.get_uint32()
-        refresh = tok.get_uint32()
-        retry = tok.get_uint32()
-        expire = tok.get_uint32()
-        minimum = tok.get_uint32()
+        refresh = tok.get_ttl()
+        retry = tok.get_ttl()
+        expire = tok.get_ttl()
+        minimum = tok.get_ttl()
         tok.get_eol()
         return cls(rdclass, rdtype, mname, rname, serial, refresh, retry,
                    expire, minimum )
index 96e24685d6b1ecdc8c3287a3cc88e5da553b1324..444e909eb98fc01af28d410e4d373aa999ed4788 100644 (file)
@@ -101,7 +101,7 @@ class SIGBase(dns.rdata.Rdata):
         type_covered = dns.rdatatype.from_text(tok.get_string())
         algorithm = dns.dnssec.algorithm_from_text(tok.get_string())
         labels = tok.get_int()
-        original_ttl = tok.get_uint32()
+        original_ttl = tok.get_ttl()
         expiration = sigtime_to_posixtime(tok.get_string())
         inception = sigtime_to_posixtime(tok.get_string())
         key_tag = tok.get_int()
index 4f96a67e69ed7d4f246b78d39bf867b972d2361d..1c1c0ae122f9f95feff0564e2c2254a866485164 100644 (file)
@@ -20,6 +20,7 @@ import sys
 
 import dns.exception
 import dns.name
+import dns.ttl
 
 _DELIMITERS = {
     ' ' : True,
@@ -420,3 +421,9 @@ class Tokenizer(object):
             raise dns.exception.SyntaxError, \
                   'expected EOL or EOF, got %d "%s"' % (ttype, t)
         return t
+
+    def get_ttl(self):
+        (ttype, t) = self.get()
+        if ttype != IDENTIFIER:
+            raise dns.exception.SyntaxError, 'expecting an identifier'
+        return dns.ttl.from_text(t)
index 8fa9cb54c459223735b08db3586487e94d378083..f038005a49b90760ef5096089f556458c6eb7bf7 100644 (file)
@@ -18,6 +18,7 @@ import unittest
 import dns.rdata
 import dns.rdataclass
 import dns.rdatatype
+import dns.ttl
 
 class BugsTestCase(unittest.TestCase):
 
@@ -27,5 +28,17 @@ class BugsTestCase(unittest.TestCase):
         self.failUnless(rdata.float_latitude == 30.5)
         self.failUnless(rdata.float_longitude == -100.5)
 
+    def test_SOA_BIND8_TTL(self):
+        rdata1 = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.SOA,
+                                     "a b 100 1s 1m 1h 1d")
+        rdata2 = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.SOA,
+                                     "a b 100 1 60 3600 86400")
+        self.failUnless(rdata1 == rdata2)
+
+    def test_TTL_bounds_check(self):
+        def bad():
+            ttl = dns.ttl.from_text("2147483648")
+        self.failUnlessRaises(dns.ttl.BadTTL, bad)
+
 if __name__ == '__main__':
     unittest.main()