diff options
author | Bob Halley <halley@dnspython.org> | 2020-06-01 08:23:03 -0700 |
---|---|---|
committer | Bob Halley <halley@dnspython.org> | 2020-06-01 08:23:03 -0700 |
commit | c19e6716a86593528ae3d4904bf1cefcfcd477b9 (patch) | |
tree | 7c2d015ce1456031beb5fe44da280bbedffb3d3f /dns | |
parent | 77b9cdc41ffe002c0bb49f387b4f1fdbb190ff60 (diff) | |
download | dnspython-c19e6716a86593528ae3d4904bf1cefcfcd477b9.tar.gz |
Fix remaining canonical form problems, and add a test. [Issue #496]
Diffstat (limited to 'dns')
-rw-r--r-- | dns/rdtypes/ANY/NSEC.py | 9 | ||||
-rw-r--r-- | dns/rdtypes/IN/KX.py | 2 | ||||
-rw-r--r-- | dns/rdtypes/IN/NAPTR.py | 10 | ||||
-rw-r--r-- | dns/rdtypes/IN/PX.py | 5 | ||||
-rw-r--r-- | dns/rdtypes/IN/SRV.py | 1 |
5 files changed, 25 insertions, 2 deletions
diff --git a/dns/rdtypes/ANY/NSEC.py b/dns/rdtypes/ANY/NSEC.py index 63203b5..7da00e9 100644 --- a/dns/rdtypes/ANY/NSEC.py +++ b/dns/rdtypes/ANY/NSEC.py @@ -15,6 +15,7 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +import io import struct import dns.exception @@ -92,6 +93,14 @@ class NSEC(dns.rdata.Rdata): file.write(struct.pack('!BB', window, len(bitmap))) file.write(bitmap) + def to_digestable(self, origin=None): + file = io.BytesIO() + file.write(self.next.to_digestable(origin)) + for (window, bitmap) in self.windows: + file.write(struct.pack('!BB', window, len(bitmap))) + file.write(bitmap) + return file.getvalue() + @classmethod def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin=None): (next, cused) = dns.name.from_wire(wire[: current + rdlen], current) diff --git a/dns/rdtypes/IN/KX.py b/dns/rdtypes/IN/KX.py index 1318a58..ebf8fd7 100644 --- a/dns/rdtypes/IN/KX.py +++ b/dns/rdtypes/IN/KX.py @@ -18,6 +18,6 @@ import dns.rdtypes.mxbase -class KX(dns.rdtypes.mxbase.UncompressedMX): +class KX(dns.rdtypes.mxbase.UncompressedDowncasingMX): """KX record""" diff --git a/dns/rdtypes/IN/NAPTR.py b/dns/rdtypes/IN/NAPTR.py index 9668dce..c68efc3 100644 --- a/dns/rdtypes/IN/NAPTR.py +++ b/dns/rdtypes/IN/NAPTR.py @@ -15,6 +15,7 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +import io import struct import dns.exception @@ -84,6 +85,15 @@ class NAPTR(dns.rdata.Rdata): _write_string(file, self.regexp) self.replacement.to_wire(file, compress, origin) + def to_digestable(self, origin=None): + file = io.BytesIO() + two_ints = struct.pack("!HH", self.order, self.preference) + file.write(two_ints) + _write_string(file, self.flags) + _write_string(file, self.service) + _write_string(file, self.regexp) + return file.getvalue() + self.replacement.to_digestable(origin) + @classmethod def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin=None): (order, preference) = struct.unpack('!HH', wire[current: current + 4]) diff --git a/dns/rdtypes/IN/PX.py b/dns/rdtypes/IN/PX.py index 109a873..e11f265 100644 --- a/dns/rdtypes/IN/PX.py +++ b/dns/rdtypes/IN/PX.py @@ -56,6 +56,11 @@ class PX(dns.rdata.Rdata): self.map822.to_wire(file, None, origin) self.mapx400.to_wire(file, None, origin) + def to_digestable(self, origin=None): + return struct.pack("!H", self.preference) + \ + self.map822.to_digestable(origin) + \ + self.mapx400.to_digestable(origin) + @classmethod def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin=None): (preference, ) = struct.unpack('!H', wire[current: current + 2]) diff --git a/dns/rdtypes/IN/SRV.py b/dns/rdtypes/IN/SRV.py index bfd25ea..8c08f0b 100644 --- a/dns/rdtypes/IN/SRV.py +++ b/dns/rdtypes/IN/SRV.py @@ -59,7 +59,6 @@ class SRV(dns.rdata.Rdata): self.target.to_wire(file, compress, origin) def to_digestable(self, origin=None): - # TODO how to avoid code duplication here? This is mostly identical to self.to_wire. f = io.BytesIO() f.write(struct.pack("!HHH", self.priority, self.weight, self.port)) f.write(self.target.to_digestable(origin)) |