import dns.rdatatype
import dns.rrset
import dns.renderer
+import dns.ttl
import dns.tsig
import dns.rdtypes.ANY.OPT
import dns.rdtypes.ANY.TSIG
raise dns.exception.FormError
question = self.question[0]
qname = question.name
- min_ttl = -1
+ min_ttl = dns.ttl.MAX_TTL
rrset = None
count = 0
while count < MAX_CHAIN:
try:
rrset = self.find_rrset(self.answer, qname, question.rdclass,
question.rdtype)
- if min_ttl == -1 or rrset.ttl < min_ttl:
+ if rrset.ttl < min_ttl:
min_ttl = rrset.ttl
break
except KeyError:
crrset = self.find_rrset(self.answer, qname,
question.rdclass,
dns.rdatatype.CNAME)
- if min_ttl == -1 or crrset.ttl < min_ttl:
+ if crrset.ttl < min_ttl:
min_ttl = crrset.ttl
for rd in crrset:
qname = rd.target
srrset = self.find_rrset(self.authority, auname,
question.rdclass,
dns.rdatatype.SOA)
- if min_ttl == -1 or srrset.ttl < min_ttl:
+ if srrset.ttl < min_ttl:
min_ttl = srrset.ttl
if srrset[0].minimum < min_ttl:
min_ttl = srrset[0].minimum
import dns.exception
+MAX_TTL = 2147483647
class BadTTL(dns.exception.SyntaxError):
"""DNS TTL value is not well-formed."""
current = 0
if not current == 0:
raise BadTTL("trailing integer")
- if total < 0 or total > 2147483647:
+ if total < 0 or total > MAX_TTL:
raise BadTTL("TTL should be between 0 and 2^31 - 1 (inclusive)")
return total