summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2021-12-02 05:33:35 -0800
committerBob Halley <halley@dnspython.org>2021-12-02 05:33:35 -0800
commit3b6bc40b11830eb18b56472054bb0e58f9f4072a (patch)
treeb09ef25d1ccd22e0680eb3ba4cb47ff2735644cd
parentfce73919a484d3a985e1acd5a099796cd9a563f2 (diff)
downloaddnspython-3b6bc40b11830eb18b56472054bb0e58f9f4072a.tar.gz
incorporate review feedback
-rw-r--r--dns/node.py8
-rw-r--r--dns/rdataset.py15
2 files changed, 15 insertions, 8 deletions
diff --git a/dns/node.py b/dns/node.py
index 4a750eb..7f172dd 100644
--- a/dns/node.py
+++ b/dns/node.py
@@ -102,7 +102,13 @@ class Node:
"""
# Make having just one rdataset at the node fast.
if len(self.rdatasets) > 0:
- if rdataset.rdtype == dns.rdatatype.CNAME:
+ # We don't want adding RRSIG(CNAME) to delete CNAMEs,
+ # so we treat it as expressing "CNAME intent" for classifying
+ # the node as a CNAME node, even if we haven't added the CNAME
+ # yet.
+ if rdataset.rdtype == dns.rdatatype.CNAME or \
+ (rdataset.rdtype == dns.rdatatype.RRSIG and
+ rdataset.covers == dns.rdatatype.CNAME):
self.rdatasets = [rds for rds in self.rdatasets
if rds.ok_for_cname()]
else:
diff --git a/dns/rdataset.py b/dns/rdataset.py
index e9d8fc2..868c1fc 100644
--- a/dns/rdataset.py
+++ b/dns/rdataset.py
@@ -42,12 +42,10 @@ class IncompatibleTypes(dns.exception.DNSException):
_ok_for_cname = {
- (dns.rdatatype.CNAME, dns.rdatatype.NONE),
- (dns.rdatatype.RRSIG, dns.rdatatype.CNAME),
- (dns.rdatatype.NSEC, dns.rdatatype.NONE),
- (dns.rdatatype.RRSIG, dns.rdatatype.NSEC),
- (dns.rdatatype.NSEC3, dns.rdatatype.NONE),
- (dns.rdatatype.RRSIG, dns.rdatatype.NSEC3),
+ dns.rdatatype.CNAME,
+ dns.rdatatype.NSEC, # RFC 4035 section 2.5
+ dns.rdatatype.NSEC3, # This is not likely to happen, but not impossible!
+ dns.rdatatype.KEY, # RFC 4035 section 2.5, RFC 3007
}
_delete_for_other_data = {
@@ -55,6 +53,7 @@ _delete_for_other_data = {
(dns.rdatatype.RRSIG, dns.rdatatype.CNAME),
}
+
class Rdataset(dns.set.Set):
"""A DNS rdataset."""
@@ -339,7 +338,9 @@ class Rdataset(dns.set.Set):
def ok_for_cname(self):
"""Is this rdataset compatible with a CNAME node?"""
- return (self.rdtype, self.covers) in _ok_for_cname
+ return self.rdtype in _ok_for_cname or \
+ (self.rdtype == dns.rdatatype.RRSIG and
+ self.covers in _ok_for_cname)
def ok_for_other_data(self):
"""Is this rdataset compatible with an 'other data' (i.e. not CNAME)