From: Bob Halley Date: Wed, 17 Jun 2020 20:16:38 +0000 (-0700) Subject: simplify TTL check when reading a zone file X-Git-Tag: v2.0.0rc1~55 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c8d04a89cbebf83994ba27c5223170bcc86dbac;p=thirdparty%2Fdnspython.git simplify TTL check when reading a zone file --- diff --git a/dns/zone.py b/dns/zone.py index 13d121be..e8413c08 100644 --- a/dns/zone.py +++ b/dns/zone.py @@ -772,23 +772,20 @@ class _MasterReader: raise dns.exception.SyntaxError( "caught exception {}: {}".format(str(ty), str(va))) - if not self.default_ttl_known and \ - isinstance(rd, dns.rdtypes.ANY.SOA.SOA): + if not self.default_ttl_known and rdtype == dns.rdatatype.SOA: # The pre-RFC2308 and pre-BIND9 behavior inherits the zone default # TTL from the SOA minttl if no $TTL statement is present before the # SOA is parsed. self.default_ttl = rd.minimum self.default_ttl_known = True + if ttl is None: + # if we didn't have a TTL on the SOA, set it! + ttl = rd.minimum - # TTL check + # TTL check. We had to wait until now to do this as the SOA RR's + # own TTL can be inferred from its minimum. if ttl is None: - if not (self.last_ttl_known or self.default_ttl_known): - raise dns.exception.SyntaxError("Missing default TTL value") - else: - if self.default_ttl_known: - ttl = self.default_ttl - else: - ttl = self.last_ttl + raise dns.exception.SyntaxError("Missing default TTL value") covers = rd.covers() rds = n.find_rdataset(rdclass, rdtype, covers, True)