summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2014-09-05 08:10:16 -0700
committerBob Halley <halley@dnspython.org>2014-09-05 08:10:16 -0700
commite843b4187c0be8f3350e9029fccfe520eec60f6d (patch)
tree8ada0b88f7cb5038eaa47481450f1a6f9ccbe90b
parented01dc7c5f2f39e38e77ee9fa769ca8ef88c9e7d (diff)
downloaddnspython-e843b4187c0be8f3350e9029fccfe520eec60f6d.tar.gz
All rdata comparsion now uses the digestable form.
-rw-r--r--ChangeLog10
-rw-r--r--dns/rdata.py19
-rw-r--r--dns/rdtypes/ANY/CERT.py12
-rw-r--r--dns/rdtypes/ANY/DNSKEY.py8
-rw-r--r--dns/rdtypes/ANY/GPOS.py8
-rw-r--r--dns/rdtypes/ANY/HINFO.py6
-rw-r--r--dns/rdtypes/ANY/HIP.py27
-rw-r--r--dns/rdtypes/ANY/ISDN.py6
-rw-r--r--dns/rdtypes/ANY/LOC.py12
-rw-r--r--dns/rdtypes/ANY/NSEC.py3
-rw-r--r--dns/rdtypes/ANY/NSEC3.py3
-rw-r--r--dns/rdtypes/ANY/NSEC3PARAM.py3
-rw-r--r--dns/rdtypes/ANY/RP.py6
-rw-r--r--dns/rdtypes/ANY/RRSIG.py16
-rw-r--r--dns/rdtypes/ANY/SOA.py13
-rw-r--r--dns/rdtypes/ANY/SSHFP.py8
-rw-r--r--dns/rdtypes/ANY/TLSA.py8
-rw-r--r--dns/rdtypes/ANY/X25.py3
-rw-r--r--dns/rdtypes/IN/A.py5
-rw-r--r--dns/rdtypes/IN/AAAA.py5
-rw-r--r--dns/rdtypes/IN/APL.py12
-rw-r--r--dns/rdtypes/IN/DHCID.py3
-rw-r--r--dns/rdtypes/IN/IPSECKEY.py12
-rw-r--r--dns/rdtypes/IN/NAPTR.py14
-rw-r--r--dns/rdtypes/IN/NSAP.py3
-rw-r--r--dns/rdtypes/IN/PX.py10
-rw-r--r--dns/rdtypes/IN/SRV.py8
-rw-r--r--dns/rdtypes/IN/WKS.py12
-rw-r--r--dns/rdtypes/dsbase.py10
-rw-r--r--dns/rdtypes/mxbase.py13
-rw-r--r--dns/rdtypes/nsbase.py5
-rw-r--r--dns/rdtypes/txtbase.py3
32 files changed, 17 insertions, 269 deletions
diff --git a/ChangeLog b/ChangeLog
index b28613f..a6a52de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2014-09-05 Bob Halley <halley@dnspython.org>
+
+ * Comparing two rdata is now always done by comparing the binary
+ data of the DNSSEC digestable forms. This corrects a number of
+ errors where dnspython's rdata comparsion order was not the
+ DNSSEC order.
+
+ * Add CAA implementation. Thanks to Brian Wellington for the
+ patch.
+
2014-09-01 Bob Halley <halley@dnspython.org>
* (Version 1.12.0 released)
diff --git a/dns/rdata.py b/dns/rdata.py
index 74ddef0..46fa089 100644
--- a/dns/rdata.py
+++ b/dns/rdata.py
@@ -207,7 +207,8 @@ class Rdata(object):
rdclass. Return < 0 if self < other in the DNSSEC ordering,
0 if self == other, and > 0 if self > other.
"""
- raise NotImplementedError
+ return dns.util.cmp(self.to_digestable(dns.name.root),
+ other.to_digestable(dns.name.root))
def __eq__(self, other):
if not isinstance(other, Rdata):
@@ -260,19 +261,6 @@ class Rdata(object):
def __hash__(self):
return hash(self.to_digestable(dns.name.root))
- def _wire_cmp(self, other):
- # A number of types compare rdata in wire form, so we provide
- # the method here instead of duplicating it.
- #
- # We specifiy an arbitrary origin of '.' when doing the
- # comparison, since the rdata may have relative names and we
- # can't convert a relative name to wire without an origin.
- b1 = io.BytesIO()
- self.to_wire(b1, None, dns.name.root)
- b2 = io.BytesIO()
- other.to_wire(b2, None, dns.name.root)
- return dns.util.cmp(b1.getvalue(), b2.getvalue())
-
@classmethod
def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
"""Build an rdata object from text format.
@@ -362,9 +350,6 @@ class GenericRdata(Rdata):
def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
return cls(rdclass, rdtype, wire[current : current + rdlen])
- def _cmp(self, other):
- return dns.util.cmp(self.data, other.data)
-
_rdata_modules = {}
_module_prefix = 'dns.rdtypes'
diff --git a/dns/rdtypes/ANY/CERT.py b/dns/rdtypes/ANY/CERT.py
index f7a397f..4c27212 100644
--- a/dns/rdtypes/ANY/CERT.py
+++ b/dns/rdtypes/ANY/CERT.py
@@ -119,15 +119,3 @@ class CERT(dns.rdata.Rdata):
certificate)
from_wire = classmethod(from_wire)
-
- def _cmp(self, other):
- f = io.BytesIO()
- self.to_wire(f)
- wire1 = f.getvalue()
- f.seek(0)
- f.truncate()
- other.to_wire(f)
- wire2 = f.getvalue()
- f.close()
-
- return dns.util.cmp(wire1, wire2)
diff --git a/dns/rdtypes/ANY/DNSKEY.py b/dns/rdtypes/ANY/DNSKEY.py
index 246a2fd..0c9a42f 100644
--- a/dns/rdtypes/ANY/DNSKEY.py
+++ b/dns/rdtypes/ANY/DNSKEY.py
@@ -127,14 +127,6 @@ class DNSKEY(dns.rdata.Rdata):
return cls(rdclass, rdtype, header[0], header[1], header[2],
key)
- def _cmp(self, other):
- hs = struct.pack("!HBB", self.flags, self.protocol, self.algorithm)
- ho = struct.pack("!HBB", other.flags, other.protocol, other.algorithm)
- v = dns.util.cmp(hs, ho)
- if v == 0:
- v = dns.util.cmp(self.key, other.key)
- return v
-
def flags_to_text_set(self):
"""Convert a DNSKEY flags value to set texts
@rtype: set([string])"""
diff --git a/dns/rdtypes/ANY/GPOS.py b/dns/rdtypes/ANY/GPOS.py
index 5952c3c..c560c0a 100644
--- a/dns/rdtypes/ANY/GPOS.py
+++ b/dns/rdtypes/ANY/GPOS.py
@@ -115,14 +115,6 @@ class GPOS(dns.rdata.Rdata):
from_wire = classmethod(from_wire)
- def _cmp(self, other):
- v = dns.util.cmp(self.latitude, other.latitude)
- if v == 0:
- v = dns.util.cmp(self.longitude, other.longitude)
- if v == 0:
- v = dns.util.cmp(self.altitude, other.altitude)
- return v
-
def _get_float_latitude(self):
return float(self.latitude)
diff --git a/dns/rdtypes/ANY/HINFO.py b/dns/rdtypes/ANY/HINFO.py
index 12e2609..4abb624 100644
--- a/dns/rdtypes/ANY/HINFO.py
+++ b/dns/rdtypes/ANY/HINFO.py
@@ -74,9 +74,3 @@ class HINFO(dns.rdata.Rdata):
return cls(rdclass, rdtype, cpu, os)
from_wire = classmethod(from_wire)
-
- def _cmp(self, other):
- v = dns.util.cmp(self.cpu, other.cpu)
- if v == 0:
- v = dns.util.cmp(self.os, other.os)
- return v
diff --git a/dns/rdtypes/ANY/HIP.py b/dns/rdtypes/ANY/HIP.py
index 60f78dc..bb48069 100644
--- a/dns/rdtypes/ANY/HIP.py
+++ b/dns/rdtypes/ANY/HIP.py
@@ -113,30 +113,3 @@ class HIP(dns.rdata.Rdata):
server = server.choose_relativity(origin, relativize)
servers.append(server)
self.servers = servers
-
- def _cmp(self, other):
- b1 = io.BytesIO()
- lh = len(self.hit)
- lk = len(self.key)
- b1.write(struct.pack("!BBH", lh, self.algorithm, lk))
- b1.write(self.hit)
- b1.write(self.key)
- b2 = io.BytesIO()
- lh = len(other.hit)
- lk = len(other.key)
- b2.write(struct.pack("!BBH", lh, other.algorithm, lk))
- b2.write(other.hit)
- b2.write(other.key)
- v = dns.util.cmp(b1.getvalue(), b2.getvalue())
- if v != 0:
- return v
- ls = len(self.servers)
- lo = len(other.servers)
- count = min(ls, lo)
- i = 0
- while i < count:
- v = dns.util.cmp(self.servers[i], other.servers[i])
- if v != 0:
- return v
- i += 1
- return ls - lo
diff --git a/dns/rdtypes/ANY/ISDN.py b/dns/rdtypes/ANY/ISDN.py
index d292a89..1bd4b3d 100644
--- a/dns/rdtypes/ANY/ISDN.py
+++ b/dns/rdtypes/ANY/ISDN.py
@@ -87,9 +87,3 @@ class ISDN(dns.rdata.Rdata):
return cls(rdclass, rdtype, address, subaddress)
from_wire = classmethod(from_wire)
-
- def _cmp(self, other):
- v = dns.util.cmp(self.address, other.address)
- if v == 0:
- v = dns.util.cmp(self.subaddress, other.subaddress)
- return v
diff --git a/dns/rdtypes/ANY/LOC.py b/dns/rdtypes/ANY/LOC.py
index 0c9bbdd..f240c67 100644
--- a/dns/rdtypes/ANY/LOC.py
+++ b/dns/rdtypes/ANY/LOC.py
@@ -313,18 +313,6 @@ class LOC(dns.rdata.Rdata):
from_wire = classmethod(from_wire)
- def _cmp(self, other):
- f = io.BytesIO()
- self.to_wire(f)
- wire1 = f.getvalue()
- f.seek(0)
- f.truncate()
- other.to_wire(f)
- wire2 = f.getvalue()
- f.close()
-
- return dns.util.cmp(wire1, wire2)
-
def _get_float_latitude(self):
return _tuple_to_float(self.latitude)
diff --git a/dns/rdtypes/ANY/NSEC.py b/dns/rdtypes/ANY/NSEC.py
index b3f0220..eb6ac2f 100644
--- a/dns/rdtypes/ANY/NSEC.py
+++ b/dns/rdtypes/ANY/NSEC.py
@@ -124,6 +124,3 @@ class NSEC(dns.rdata.Rdata):
def choose_relativity(self, origin = None, relativize = True):
self.next = self.next.choose_relativity(origin, relativize)
-
- def _cmp(self, other):
- return self._wire_cmp(other)
diff --git a/dns/rdtypes/ANY/NSEC3.py b/dns/rdtypes/ANY/NSEC3.py
index 76a2867..ec0aa48 100644
--- a/dns/rdtypes/ANY/NSEC3.py
+++ b/dns/rdtypes/ANY/NSEC3.py
@@ -178,6 +178,3 @@ class NSEC3(dns.rdata.Rdata):
return cls(rdclass, rdtype, algorithm, flags, iterations, salt, next, windows)
from_wire = classmethod(from_wire)
-
- def _cmp(self, other):
- return self._wire_cmp(other)
diff --git a/dns/rdtypes/ANY/NSEC3PARAM.py b/dns/rdtypes/ANY/NSEC3PARAM.py
index ede6863..bddc2a9 100644
--- a/dns/rdtypes/ANY/NSEC3PARAM.py
+++ b/dns/rdtypes/ANY/NSEC3PARAM.py
@@ -82,6 +82,3 @@ class NSEC3PARAM(dns.rdata.Rdata):
return cls(rdclass, rdtype, algorithm, flags, iterations, salt)
from_wire = classmethod(from_wire)
-
- def _cmp(self, other):
- return self._wire_cmp(other)
diff --git a/dns/rdtypes/ANY/RP.py b/dns/rdtypes/ANY/RP.py
index f7afca0..c22be99 100644
--- a/dns/rdtypes/ANY/RP.py
+++ b/dns/rdtypes/ANY/RP.py
@@ -79,9 +79,3 @@ class RP(dns.rdata.Rdata):
def choose_relativity(self, origin = None, relativize = True):
self.mbox = self.mbox.choose_relativity(origin, relativize)
self.txt = self.txt.choose_relativity(origin, relativize)
-
- def _cmp(self, other):
- v = dns.util.cmp(self.mbox, other.mbox)
- if v == 0:
- v = dns.util.cmp(self.txt, other.txt)
- return v
diff --git a/dns/rdtypes/ANY/RRSIG.py b/dns/rdtypes/ANY/RRSIG.py
index b45e0c9..6f39cb8 100644
--- a/dns/rdtypes/ANY/RRSIG.py
+++ b/dns/rdtypes/ANY/RRSIG.py
@@ -150,19 +150,3 @@ class RRSIG(dns.rdata.Rdata):
def choose_relativity(self, origin = None, relativize = True):
self.signer = self.signer.choose_relativity(origin, relativize)
-
- def _cmp(self, other):
- hs = struct.pack('!HBBIIIH', self.type_covered,
- self.algorithm, self.labels,
- self.original_ttl, self.expiration,
- self.inception, self.key_tag)
- ho = struct.pack('!HBBIIIH', other.type_covered,
- other.algorithm, other.labels,
- other.original_ttl, other.expiration,
- other.inception, other.key_tag)
- v = dns.util.cmp(hs, ho)
- if v == 0:
- v = dns.util.cmp(self.signer, other.signer)
- if v == 0:
- v = dns.util.cmp(self.signature, other.signature)
- return v
diff --git a/dns/rdtypes/ANY/SOA.py b/dns/rdtypes/ANY/SOA.py
index be010f8..00d5b1a 100644
--- a/dns/rdtypes/ANY/SOA.py
+++ b/dns/rdtypes/ANY/SOA.py
@@ -113,16 +113,3 @@ class SOA(dns.rdata.Rdata):
def choose_relativity(self, origin = None, relativize = True):
self.mname = self.mname.choose_relativity(origin, relativize)
self.rname = self.rname.choose_relativity(origin, relativize)
-
- def _cmp(self, other):
- v = dns.util.cmp(self.mname, other.mname)
- if v == 0:
- v = dns.util.cmp(self.rname, other.rname)
- if v == 0:
- self_ints = struct.pack('!IIIII', self.serial, self.refresh,
- self.retry, self.expire, self.minimum)
- other_ints = struct.pack('!IIIII', other.serial, other.refresh,
- other.retry, other.expire,
- other.minimum)
- v = dns.util.cmp(self_ints, other_ints)
- return v
diff --git a/dns/rdtypes/ANY/SSHFP.py b/dns/rdtypes/ANY/SSHFP.py
index b7ee254..43afaa3 100644
--- a/dns/rdtypes/ANY/SSHFP.py
+++ b/dns/rdtypes/ANY/SSHFP.py
@@ -75,11 +75,3 @@ class SSHFP(dns.rdata.Rdata):
return cls(rdclass, rdtype, header[0], header[1], fingerprint)
from_wire = classmethod(from_wire)
-
- def _cmp(self, other):
- hs = struct.pack("!BB", self.algorithm, self.fp_type)
- ho = struct.pack("!BB", other.algorithm, other.fp_type)
- v = dns.util.cmp(hs, ho)
- if v == 0:
- v = dns.util.cmp(self.fingerprint, other.fingerprint)
- return v
diff --git a/dns/rdtypes/ANY/TLSA.py b/dns/rdtypes/ANY/TLSA.py
index d4320e4..76c8c52 100644
--- a/dns/rdtypes/ANY/TLSA.py
+++ b/dns/rdtypes/ANY/TLSA.py
@@ -80,11 +80,3 @@ class TLSA(dns.rdata.Rdata):
return cls(rdclass, rdtype, header[0], header[1], header[2], cert)
from_wire = classmethod(from_wire)
-
- def _cmp(self, other):
- hs = struct.pack("!BBB", self.usage, self.selector, self.mtype)
- ho = struct.pack("!BBB", other.usage, other.selector, other.mtype)
- v = dns.util.cmp(hs, ho)
- if v == 0:
- v = dns.util.cmp(self.cert, other.cert)
- return v
diff --git a/dns/rdtypes/ANY/X25.py b/dns/rdtypes/ANY/X25.py
index 33ebd45..3d6f927 100644
--- a/dns/rdtypes/ANY/X25.py
+++ b/dns/rdtypes/ANY/X25.py
@@ -57,6 +57,3 @@ class X25(dns.rdata.Rdata):
return cls(rdclass, rdtype, address)
from_wire = classmethod(from_wire)
-
- def _cmp(self, other):
- return dns.util.cmp(self.address, other.address)
diff --git a/dns/rdtypes/IN/A.py b/dns/rdtypes/IN/A.py
index e216406..df4f6ed 100644
--- a/dns/rdtypes/IN/A.py
+++ b/dns/rdtypes/IN/A.py
@@ -51,8 +51,3 @@ class A(dns.rdata.Rdata):
return cls(rdclass, rdtype, address)
from_wire = classmethod(from_wire)
-
- def _cmp(self, other):
- sa = dns.ipv4.inet_aton(self.address)
- oa = dns.ipv4.inet_aton(other.address)
- return dns.util.cmp(sa, oa)
diff --git a/dns/rdtypes/IN/AAAA.py b/dns/rdtypes/IN/AAAA.py
index e955d14..ee4c735 100644
--- a/dns/rdtypes/IN/AAAA.py
+++ b/dns/rdtypes/IN/AAAA.py
@@ -52,8 +52,3 @@ class AAAA(dns.rdata.Rdata):
return cls(rdclass, rdtype, address)
from_wire = classmethod(from_wire)
-
- def _cmp(self, other):
- sa = dns.inet.inet_pton(dns.inet.AF_INET6, self.address)
- oa = dns.inet.inet_pton(dns.inet.AF_INET6, other.address)
- return dns.util.cmp(sa, oa)
diff --git a/dns/rdtypes/IN/APL.py b/dns/rdtypes/IN/APL.py
index 58e35b6..0f2f175 100644
--- a/dns/rdtypes/IN/APL.py
+++ b/dns/rdtypes/IN/APL.py
@@ -157,15 +157,3 @@ class APL(dns.rdata.Rdata):
return cls(rdclass, rdtype, items)
from_wire = classmethod(from_wire)
-
- def _cmp(self, other):
- f = io.BytesIO()
- self.to_wire(f)
- wire1 = f.getvalue()
- f.seek(0)
- f.truncate()
- other.to_wire(f)
- wire2 = f.getvalue()
- f.close()
-
- return dns.util.cmp(wire1, wire2)
diff --git a/dns/rdtypes/IN/DHCID.py b/dns/rdtypes/IN/DHCID.py
index 898cc91..260b118 100644
--- a/dns/rdtypes/IN/DHCID.py
+++ b/dns/rdtypes/IN/DHCID.py
@@ -58,6 +58,3 @@ class DHCID(dns.rdata.Rdata):
return cls(rdclass, rdtype, data)
from_wire = classmethod(from_wire)
-
- def _cmp(self, other):
- return dns.util.cmp(self.data, other.data)
diff --git a/dns/rdtypes/IN/IPSECKEY.py b/dns/rdtypes/IN/IPSECKEY.py
index 3ae3495..02db282 100644
--- a/dns/rdtypes/IN/IPSECKEY.py
+++ b/dns/rdtypes/IN/IPSECKEY.py
@@ -147,15 +147,3 @@ class IPSECKEY(dns.rdata.Rdata):
gateway, key)
from_wire = classmethod(from_wire)
-
- def _cmp(self, other):
- f = io.BytesIO()
- self.to_wire(f)
- wire1 = f.getvalue()
- f.seek(0)
- f.truncate()
- other.to_wire(f)
- wire2 = f.getvalue()
- f.close()
-
- return dns.util.cmp(wire1, wire2)
diff --git a/dns/rdtypes/IN/NAPTR.py b/dns/rdtypes/IN/NAPTR.py
index 5140808..725389c 100644
--- a/dns/rdtypes/IN/NAPTR.py
+++ b/dns/rdtypes/IN/NAPTR.py
@@ -116,17 +116,3 @@ class NAPTR(dns.rdata.Rdata):
def choose_relativity(self, origin = None, relativize = True):
self.replacement = self.replacement.choose_relativity(origin,
relativize)
-
- def _cmp(self, other):
- sp = struct.pack("!HH", self.order, self.preference)
- op = struct.pack("!HH", other.order, other.preference)
- v = dns.util.cmp(sp, op)
- if v == 0:
- v = dns.util.cmp(self.flags, other.flags)
- if v == 0:
- v = dns.util.cmp(self.service, other.service)
- if v == 0:
- v = dns.util.cmp(self.regexp, other.regexp)
- if v == 0:
- v = dns.util.cmp(self.replacement, other.replacement)
- return v
diff --git a/dns/rdtypes/IN/NSAP.py b/dns/rdtypes/IN/NSAP.py
index faa2f6c..7ffdd10 100644
--- a/dns/rdtypes/IN/NSAP.py
+++ b/dns/rdtypes/IN/NSAP.py
@@ -55,6 +55,3 @@ class NSAP(dns.rdata.Rdata):
return cls(rdclass, rdtype, address)
from_wire = classmethod(from_wire)
-
- def _cmp(self, other):
- return dns.util.cmp(self.address, other.address)
diff --git a/dns/rdtypes/IN/PX.py b/dns/rdtypes/IN/PX.py
index b848e5c..70ae66b 100644
--- a/dns/rdtypes/IN/PX.py
+++ b/dns/rdtypes/IN/PX.py
@@ -86,13 +86,3 @@ class PX(dns.rdata.Rdata):
def choose_relativity(self, origin = None, relativize = True):
self.map822 = self.map822.choose_relativity(origin, relativize)
self.mapx400 = self.mapx400.choose_relativity(origin, relativize)
-
- def _cmp(self, other):
- sp = struct.pack("!H", self.preference)
- op = struct.pack("!H", other.preference)
- v = dns.util.cmp(sp, op)
- if v == 0:
- v = dns.util.cmp(self.map822, other.map822)
- if v == 0:
- v = dns.util.cmp(self.mapx400, other.mapx400)
- return v
diff --git a/dns/rdtypes/IN/SRV.py b/dns/rdtypes/IN/SRV.py
index 64449d7..3bc9e1e 100644
--- a/dns/rdtypes/IN/SRV.py
+++ b/dns/rdtypes/IN/SRV.py
@@ -80,11 +80,3 @@ class SRV(dns.rdata.Rdata):
def choose_relativity(self, origin = None, relativize = True):
self.target = self.target.choose_relativity(origin, relativize)
-
- def _cmp(self, other):
- sp = struct.pack("!HHH", self.priority, self.weight, self.port)
- op = struct.pack("!HHH", other.priority, other.weight, other.port)
- v = dns.util.cmp(sp, op)
- if v == 0:
- v = dns.util.cmp(self.target, other.target)
- return v
diff --git a/dns/rdtypes/IN/WKS.py b/dns/rdtypes/IN/WKS.py
index 8a9137b..f73c41a 100644
--- a/dns/rdtypes/IN/WKS.py
+++ b/dns/rdtypes/IN/WKS.py
@@ -96,15 +96,3 @@ class WKS(dns.rdata.Rdata):
return cls(rdclass, rdtype, address, protocol, bitmap)
from_wire = classmethod(from_wire)
-
- def _cmp(self, other):
- sa = dns.ipv4.inet_aton(self.address)
- oa = dns.ipv4.inet_aton(other.address)
- v = dns.util.cmp(sa, oa)
- if v == 0:
- sp = struct.pack('!B', self.protocol)
- op = struct.pack('!B', other.protocol)
- v = dns.util.cmp(sp, op)
- if v == 0:
- v = dns.util.cmp(self.bitmap, other.bitmap)
- return v
diff --git a/dns/rdtypes/dsbase.py b/dns/rdtypes/dsbase.py
index fac237d..1b6817a 100644
--- a/dns/rdtypes/dsbase.py
+++ b/dns/rdtypes/dsbase.py
@@ -78,13 +78,3 @@ class DSBase(dns.rdata.Rdata):
rdlen -= 4
digest = wire[current : current + rdlen].unwrap()
return cls(rdclass, rdtype, header[0], header[1], header[2], digest)
-
- def _cmp(self, other):
- hs = struct.pack("!HBB", self.key_tag, self.algorithm,
- self.digest_type)
- ho = struct.pack("!HBB", other.key_tag, other.algorithm,
- other.digest_type)
- v = dns.util.cmp(hs, ho)
- if v == 0:
- v = dns.util.cmp(self.digest, other.digest)
- return v
diff --git a/dns/rdtypes/mxbase.py b/dns/rdtypes/mxbase.py
index 4f6206f..167ebad 100644
--- a/dns/rdtypes/mxbase.py
+++ b/dns/rdtypes/mxbase.py
@@ -15,6 +15,7 @@
"""MX-like base classes."""
+import io
import struct
import dns.exception
@@ -74,14 +75,6 @@ class MXBase(dns.rdata.Rdata):
def choose_relativity(self, origin = None, relativize = True):
self.exchange = self.exchange.choose_relativity(origin, relativize)
- def _cmp(self, other):
- sp = struct.pack("!H", self.preference)
- op = struct.pack("!H", other.preference)
- v = dns.util.cmp(sp, op)
- if v == 0:
- v = dns.util.cmp(self.exchange, other.exchange)
- return v
-
class UncompressedMX(MXBase):
"""Base class for rdata that is like an MX record, but whose name
is not compressed when converted to DNS wire format, and whose
@@ -91,7 +84,9 @@ class UncompressedMX(MXBase):
super(UncompressedMX, self).to_wire(file, None, origin)
def to_digestable(self, origin = None):
- return self.to_wire(f, None, origin)
+ f = io.BytesIO()
+ self.to_wire(f, None, origin)
+ return f.getvalue()
class UncompressedDowncasingMX(MXBase):
"""Base class for rdata that is like an MX record, but whose name
diff --git a/dns/rdtypes/nsbase.py b/dns/rdtypes/nsbase.py
index 37c35a9..615fa5d 100644
--- a/dns/rdtypes/nsbase.py
+++ b/dns/rdtypes/nsbase.py
@@ -64,9 +64,6 @@ class NSBase(dns.rdata.Rdata):
def choose_relativity(self, origin = None, relativize = True):
self.target = self.target.choose_relativity(origin, relativize)
- def _cmp(self, other):
- return dns.util.cmp(self.target, other.target)
-
class UncompressedNS(NSBase):
"""Base class for rdata that is like an NS record, but whose name
is not compressed when convert to DNS wire format, and whose
@@ -76,4 +73,4 @@ class UncompressedNS(NSBase):
super(UncompressedNS, self).to_wire(file, None, origin)
def to_digestable(self, origin = None):
- return self.to_wire(None, None, origin)
+ return self.target.to_wire(None, None, origin)
diff --git a/dns/rdtypes/txtbase.py b/dns/rdtypes/txtbase.py
index 0554f62..c6cbb59 100644
--- a/dns/rdtypes/txtbase.py
+++ b/dns/rdtypes/txtbase.py
@@ -80,6 +80,3 @@ class TXTBase(dns.rdata.Rdata):
rdlen -= l
strings.append(s)
return cls(rdclass, rdtype, strings)
-
- def _cmp(self, other):
- return dns.util.cmp(self.strings, other.strings)