summaryrefslogtreecommitdiff
path: root/lib/dnspython/dns
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dnspython/dns')
-rw-r--r--lib/dnspython/dns/__init__.py3
-rw-r--r--lib/dnspython/dns/dnssec.py6
-rw-r--r--lib/dnspython/dns/e164.py2
-rw-r--r--lib/dnspython/dns/edns.py2
-rw-r--r--lib/dnspython/dns/entropy.py2
-rw-r--r--lib/dnspython/dns/exception.py2
-rw-r--r--lib/dnspython/dns/flags.py2
-rw-r--r--lib/dnspython/dns/hash.py2
-rw-r--r--lib/dnspython/dns/inet.py2
-rw-r--r--lib/dnspython/dns/ipv4.py42
-rw-r--r--lib/dnspython/dns/ipv6.py10
-rw-r--r--lib/dnspython/dns/message.py5
-rw-r--r--lib/dnspython/dns/name.py6
-rw-r--r--lib/dnspython/dns/namedict.py2
-rw-r--r--lib/dnspython/dns/node.py2
-rw-r--r--lib/dnspython/dns/opcode.py2
-rw-r--r--lib/dnspython/dns/query.py2
-rw-r--r--lib/dnspython/dns/rcode.py2
-rw-r--r--lib/dnspython/dns/rdata.py24
-rw-r--r--lib/dnspython/dns/rdataclass.py4
-rw-r--r--lib/dnspython/dns/rdataset.py2
-rw-r--r--lib/dnspython/dns/rdatatype.py2
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/AFSDB.py2
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/CERT.py6
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/CNAME.py2
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/DLV.py2
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/DNAME.py2
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/DNSKEY.py79
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/DS.py2
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/GPOS.py18
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/HINFO.py14
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/HIP.py6
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/ISDN.py6
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/KEY.py20
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/LOC.py2
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/MX.py2
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/NS.py2
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/NSEC.py21
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/NSEC3.py10
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/NSEC3PARAM.py4
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/NXT.py99
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/PTR.py2
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/RP.py2
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/RRSIG.py143
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/RT.py2
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/SIG.py26
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/SOA.py8
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/SPF.py2
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/SSHFP.py12
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/TXT.py2
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/X25.py12
-rw-r--r--lib/dnspython/dns/rdtypes/ANY/__init__.py5
-rw-r--r--lib/dnspython/dns/rdtypes/IN/A.py2
-rw-r--r--lib/dnspython/dns/rdtypes/IN/AAAA.py2
-rw-r--r--lib/dnspython/dns/rdtypes/IN/APL.py4
-rw-r--r--lib/dnspython/dns/rdtypes/IN/DHCID.py4
-rw-r--r--lib/dnspython/dns/rdtypes/IN/IPSECKEY.py4
-rw-r--r--lib/dnspython/dns/rdtypes/IN/KX.py2
-rw-r--r--lib/dnspython/dns/rdtypes/IN/NAPTR.py12
-rw-r--r--lib/dnspython/dns/rdtypes/IN/NSAP.py4
-rw-r--r--lib/dnspython/dns/rdtypes/IN/NSAP_PTR.py2
-rw-r--r--lib/dnspython/dns/rdtypes/IN/PX.py10
-rw-r--r--lib/dnspython/dns/rdtypes/IN/SRV.py2
-rw-r--r--lib/dnspython/dns/rdtypes/IN/WKS.py4
-rw-r--r--lib/dnspython/dns/rdtypes/IN/__init__.py2
-rw-r--r--lib/dnspython/dns/rdtypes/__init__.py4
-rw-r--r--lib/dnspython/dns/rdtypes/dsbase.py4
-rw-r--r--lib/dnspython/dns/rdtypes/keybase.py149
-rw-r--r--lib/dnspython/dns/rdtypes/mxbase.py2
-rw-r--r--lib/dnspython/dns/rdtypes/nsbase.py2
-rw-r--r--lib/dnspython/dns/rdtypes/sigbase.py168
-rw-r--r--lib/dnspython/dns/rdtypes/txtbase.py4
-rw-r--r--lib/dnspython/dns/renderer.py5
-rw-r--r--lib/dnspython/dns/resolver.py412
-rw-r--r--lib/dnspython/dns/reversename.py2
-rw-r--r--lib/dnspython/dns/rrset.py2
-rw-r--r--lib/dnspython/dns/set.py2
-rw-r--r--lib/dnspython/dns/tokenizer.py2
-rw-r--r--lib/dnspython/dns/tsig.py2
-rw-r--r--lib/dnspython/dns/tsigkeyring.py2
-rw-r--r--lib/dnspython/dns/ttl.py2
-rw-r--r--lib/dnspython/dns/update.py2
-rw-r--r--lib/dnspython/dns/version.py6
-rw-r--r--lib/dnspython/dns/wiredata.py59
-rw-r--r--lib/dnspython/dns/zone.py2
85 files changed, 865 insertions, 665 deletions
diff --git a/lib/dnspython/dns/__init__.py b/lib/dnspython/dns/__init__.py
index 56e1e8a2ea..c848e48581 100644
--- a/lib/dnspython/dns/__init__.py
+++ b/lib/dnspython/dns/__init__.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009, 2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -49,5 +49,6 @@ __all__ = [
'rdtypes',
'update',
'version',
+ 'wiredata',
'zone',
]
diff --git a/lib/dnspython/dns/dnssec.py b/lib/dnspython/dns/dnssec.py
index a595fd4478..dd6a27a536 100644
--- a/lib/dnspython/dns/dnssec.py
+++ b/lib/dnspython/dns/dnssec.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009, 2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -99,7 +99,7 @@ def key_id(key, origin=None):
return (ord(rdata[-3]) << 8) + ord(rdata[-2])
else:
total = 0
- for i in range(len(rdata) / 2):
+ for i in range(len(rdata) // 2):
total += (ord(rdata[2 * i]) << 8) + ord(rdata[2 * i + 1])
if len(rdata) % 2 != 0:
total += ord(rdata[len(rdata) - 1]) << 8
@@ -299,7 +299,7 @@ def _validate_rrsig(rrset, rrsig, keys, origin=None, now=None):
if _is_rsa(rrsig.algorithm):
# PKCS1 algorithm identifier goop
digest = _make_algorithm_id(rrsig.algorithm) + digest
- padlen = keylen / 8 - len(digest) - 3
+ padlen = keylen // 8 - len(digest) - 3
digest = chr(0) + chr(1) + chr(0xFF) * padlen + chr(0) + digest
elif _is_dsa(rrsig.algorithm):
pass
diff --git a/lib/dnspython/dns/e164.py b/lib/dnspython/dns/e164.py
index d8f71ec799..d6dcd1b186 100644
--- a/lib/dnspython/dns/e164.py
+++ b/lib/dnspython/dns/e164.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2006, 2007, 2009 Nominum, Inc.
+# Copyright (C) 2006, 2007, 2009, 2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/edns.py b/lib/dnspython/dns/edns.py
index 1731cedde4..f8b6009d3f 100644
--- a/lib/dnspython/dns/edns.py
+++ b/lib/dnspython/dns/edns.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2009 Nominum, Inc.
+# Copyright (C) 2009, 2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/entropy.py b/lib/dnspython/dns/entropy.py
index fd9d4f8cdf..d380cf8c0d 100644
--- a/lib/dnspython/dns/entropy.py
+++ b/lib/dnspython/dns/entropy.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2009 Nominum, Inc.
+# Copyright (C) 2009, 2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/exception.py b/lib/dnspython/dns/exception.py
index c6d6570d98..db6ef6e6e3 100644
--- a/lib/dnspython/dns/exception.py
+++ b/lib/dnspython/dns/exception.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/flags.py b/lib/dnspython/dns/flags.py
index 17afdbc2ec..35a8305e80 100644
--- a/lib/dnspython/dns/flags.py
+++ b/lib/dnspython/dns/flags.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2001-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/hash.py b/lib/dnspython/dns/hash.py
index 7bd5ae5980..0c708036b1 100644
--- a/lib/dnspython/dns/hash.py
+++ b/lib/dnspython/dns/hash.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2010 Nominum, Inc.
+# Copyright (C) 2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/inet.py b/lib/dnspython/dns/inet.py
index 8a8f3e1ca8..3b7e88f7b1 100644
--- a/lib/dnspython/dns/inet.py
+++ b/lib/dnspython/dns/inet.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/ipv4.py b/lib/dnspython/dns/ipv4.py
index 1569da5475..e117966e5f 100644
--- a/lib/dnspython/dns/ipv4.py
+++ b/lib/dnspython/dns/ipv4.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -15,22 +15,28 @@
"""IPv4 helper functions."""
-import socket
-import sys
+import struct
-if sys.hexversion < 0x02030000 or sys.platform == 'win32':
- #
- # Some versions of Python 2.2 have an inet_aton which rejects
- # the valid IP address '255.255.255.255'. It appears this
- # problem is still present on the Win32 platform even in 2.3.
- # We'll work around the problem.
- #
- def inet_aton(text):
- if text == '255.255.255.255':
- return '\xff' * 4
- else:
- return socket.inet_aton(text)
-else:
- inet_aton = socket.inet_aton
+import dns.exception
-inet_ntoa = socket.inet_ntoa
+def inet_ntoa(address):
+ if len(address) != 4:
+ raise dns.exception.SyntaxError
+ return '%u.%u.%u.%u' % (ord(address[0]), ord(address[1]),
+ ord(address[2]), ord(address[3]))
+
+def inet_aton(text):
+ parts = text.split('.')
+ if len(parts) != 4:
+ raise dns.exception.SyntaxError
+ for part in parts:
+ if not part.isdigit():
+ raise dns.exception.SyntaxError
+ if len(part) > 1 and part[0] == '0':
+ # No leading zeros
+ raise dns.exception.SyntaxError
+ try:
+ bytes = [int(part) for part in parts]
+ return struct.pack('BBBB', *bytes)
+ except:
+ raise dns.exception.SyntaxError
diff --git a/lib/dnspython/dns/ipv6.py b/lib/dnspython/dns/ipv6.py
index 33c6713796..69db34a7de 100644
--- a/lib/dnspython/dns/ipv6.py
+++ b/lib/dnspython/dns/ipv6.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -89,7 +89,7 @@ def inet_ntoa(address):
hex = ':'.join(chunks)
return hex
-_v4_ending = re.compile(r'(.*):(\d+)\.(\d+)\.(\d+)\.(\d+)$')
+_v4_ending = re.compile(r'(.*):(\d+\.\d+\.\d+\.\d+)$')
_colon_colon_start = re.compile(r'::.*')
_colon_colon_end = re.compile(r'.*::$')
@@ -113,9 +113,9 @@ def inet_aton(text):
#
m = _v4_ending.match(text)
if not m is None:
- text = "%s:%04x:%04x" % (m.group(1),
- int(m.group(2)) * 256 + int(m.group(3)),
- int(m.group(4)) * 256 + int(m.group(5)))
+ b = dns.ipv4.inet_aton(m.group(2))
+ text = "%s:%02x%02x:%02x%02x" % (m.group(1), ord(b[0]), ord(b[1]),
+ ord(b[2]), ord(b[3]))
#
# Try to turn '::<whatever>' into ':<whatever>'; if no match try to
# turn '<whatever>::' into '<whatever>:'
diff --git a/lib/dnspython/dns/message.py b/lib/dnspython/dns/message.py
index a124a3e177..cf29133934 100644
--- a/lib/dnspython/dns/message.py
+++ b/lib/dnspython/dns/message.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2001-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -34,6 +34,7 @@ import dns.rdatatype
import dns.rrset
import dns.renderer
import dns.tsig
+import dns.wiredata
class ShortHeader(dns.exception.FormError):
"""Raised if the DNS packet passed to from_wire() is too short."""
@@ -577,7 +578,7 @@ class _WireReader(object):
def __init__(self, wire, message, question_only=False,
one_rr_per_rrset=False):
- self.wire = wire
+ self.wire = dns.wiredata.maybe_wrap(wire)
self.message = message
self.current = 0
self.updating = False
diff --git a/lib/dnspython/dns/name.py b/lib/dnspython/dns/name.py
index f239c9b5de..ed3ffeec57 100644
--- a/lib/dnspython/dns/name.py
+++ b/lib/dnspython/dns/name.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2001-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -29,6 +29,7 @@ if sys.hexversion >= 0x02030000:
import encodings.idna
import dns.exception
+import dns.wiredata
NAMERELN_NONE = 0
NAMERELN_SUPERDOMAIN = 1
@@ -670,6 +671,7 @@ def from_wire(message, current):
if not isinstance(message, str):
raise ValueError("input to from_wire() must be a byte string")
+ message = dns.wiredata.maybe_wrap(message)
labels = []
biggest_pointer = current
hops = 0
@@ -678,7 +680,7 @@ def from_wire(message, current):
cused = 1
while count != 0:
if count < 64:
- labels.append(message[current : current + count])
+ labels.append(message[current : current + count].unwrap())
current += count
if hops == 0:
cused += count
diff --git a/lib/dnspython/dns/namedict.py b/lib/dnspython/dns/namedict.py
index 54afb77188..9f5a0efb7c 100644
--- a/lib/dnspython/dns/namedict.py
+++ b/lib/dnspython/dns/namedict.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/node.py b/lib/dnspython/dns/node.py
index 785a245464..7625c66d3a 100644
--- a/lib/dnspython/dns/node.py
+++ b/lib/dnspython/dns/node.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2001-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/opcode.py b/lib/dnspython/dns/opcode.py
index 705bd09a43..3258c34cd9 100644
--- a/lib/dnspython/dns/opcode.py
+++ b/lib/dnspython/dns/opcode.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2001-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/query.py b/lib/dnspython/dns/query.py
index 9dc88a635c..addee4e3f2 100644
--- a/lib/dnspython/dns/query.py
+++ b/lib/dnspython/dns/query.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rcode.py b/lib/dnspython/dns/rcode.py
index c055f2e7cd..7807782aa4 100644
--- a/lib/dnspython/dns/rcode.py
+++ b/lib/dnspython/dns/rcode.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2001-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdata.py b/lib/dnspython/dns/rdata.py
index 399677e984..350bf790b8 100644
--- a/lib/dnspython/dns/rdata.py
+++ b/lib/dnspython/dns/rdata.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2001-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -32,6 +32,7 @@ import dns.name
import dns.rdataclass
import dns.rdatatype
import dns.tokenizer
+import dns.wiredata
_hex_chunksize = 32
@@ -256,6 +257,19 @@ 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 = cStringIO.StringIO()
+ self.to_wire(b1, None, dns.name.root)
+ b2 = cStringIO.StringIO()
+ other.to_wire(b2, None, dns.name.root)
+ return cmp(b1.getvalue(), b2.getvalue())
+
def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
"""Build an rdata object from text format.
@@ -399,12 +413,15 @@ def from_text(rdclass, rdtype, tok, origin = None, relativize = True):
Once a class is chosen, its from_text() class method is called
with the parameters to this function.
+ If I{tok} is a string, then a tokenizer is created and the string
+ is used as its input.
+
@param rdclass: The rdata class
@type rdclass: int
@param rdtype: The rdata type
@type rdtype: int
- @param tok: The tokenizer
- @type tok: dns.tokenizer.Tokenizer
+ @param tok: The tokenizer or input text
+ @type tok: dns.tokenizer.Tokenizer or string
@param origin: The origin to use for relative names
@type origin: dns.name.Name
@param relativize: Should names be relativized?
@@ -456,5 +473,6 @@ def from_wire(rdclass, rdtype, wire, current, rdlen, origin = None):
@type origin: dns.name.Name
@rtype: dns.rdata.Rdata instance"""
+ wire = dns.wiredata.maybe_wrap(wire)
cls = get_rdata_class(rdclass, rdtype)
return cls.from_wire(rdclass, rdtype, wire, current, rdlen, origin)
diff --git a/lib/dnspython/dns/rdataclass.py b/lib/dnspython/dns/rdataclass.py
index 887fd1ad6b..7601e70c3a 100644
--- a/lib/dnspython/dns/rdataclass.py
+++ b/lib/dnspython/dns/rdataclass.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2001-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -74,7 +74,7 @@ def from_text(text):
@param text: the text
@type text: string
@rtype: int
- @raises dns.rdataclass.UnknownRdataClass: the class is unknown
+ @raises dns.rdataclass.UnknownRdataclass: the class is unknown
@raises ValueError: the rdata class value is not >= 0 and <= 65535
"""
diff --git a/lib/dnspython/dns/rdataset.py b/lib/dnspython/dns/rdataset.py
index f556d2288b..dcd2b40191 100644
--- a/lib/dnspython/dns/rdataset.py
+++ b/lib/dnspython/dns/rdataset.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2001-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdatatype.py b/lib/dnspython/dns/rdatatype.py
index 1a02b7d3cd..380cfcd0d3 100644
--- a/lib/dnspython/dns/rdatatype.py
+++ b/lib/dnspython/dns/rdatatype.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2001-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdtypes/ANY/AFSDB.py b/lib/dnspython/dns/rdtypes/ANY/AFSDB.py
index e8ca6f5cbb..c729789afa 100644
--- a/lib/dnspython/dns/rdtypes/ANY/AFSDB.py
+++ b/lib/dnspython/dns/rdtypes/ANY/AFSDB.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdtypes/ANY/CERT.py b/lib/dnspython/dns/rdtypes/ANY/CERT.py
index d2703519d5..c102521a14 100644
--- a/lib/dnspython/dns/rdtypes/ANY/CERT.py
+++ b/lib/dnspython/dns/rdtypes/ANY/CERT.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -106,13 +106,13 @@ class CERT(dns.rdata.Rdata):
file.write(self.certificate)
def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
- prefix = wire[current : current + 5]
+ prefix = wire[current : current + 5].unwrap()
current += 5
rdlen -= 5
if rdlen < 0:
raise dns.exception.FormError
(certificate_type, key_tag, algorithm) = struct.unpack("!HHB", prefix)
- certificate = wire[current : current + rdlen]
+ certificate = wire[current : current + rdlen].unwrap()
return cls(rdclass, rdtype, certificate_type, key_tag, algorithm,
certificate)
diff --git a/lib/dnspython/dns/rdtypes/ANY/CNAME.py b/lib/dnspython/dns/rdtypes/ANY/CNAME.py
index 7f5c4b3bd7..fb8e9be49e 100644
--- a/lib/dnspython/dns/rdtypes/ANY/CNAME.py
+++ b/lib/dnspython/dns/rdtypes/ANY/CNAME.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdtypes/ANY/DLV.py b/lib/dnspython/dns/rdtypes/ANY/DLV.py
index 07b9548342..8bd79793d1 100644
--- a/lib/dnspython/dns/rdtypes/ANY/DLV.py
+++ b/lib/dnspython/dns/rdtypes/ANY/DLV.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2009, 2010 Nominum, Inc.
+# Copyright (C) 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdtypes/ANY/DNAME.py b/lib/dnspython/dns/rdtypes/ANY/DNAME.py
index 99b5013f33..d864001190 100644
--- a/lib/dnspython/dns/rdtypes/ANY/DNAME.py
+++ b/lib/dnspython/dns/rdtypes/ANY/DNAME.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdtypes/ANY/DNSKEY.py b/lib/dnspython/dns/rdtypes/ANY/DNSKEY.py
index ad66ef0c69..1d678d2f2a 100644
--- a/lib/dnspython/dns/rdtypes/ANY/DNSKEY.py
+++ b/lib/dnspython/dns/rdtypes/ANY/DNSKEY.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2004-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2004-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -13,13 +13,82 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-import dns.rdtypes.keybase
+
+import struct
+
+import dns.exception
+import dns.dnssec
+import dns.rdata
# flag constants
SEP = 0x0001
REVOKE = 0x0080
ZONE = 0x0100
-class DNSKEY(dns.rdtypes.keybase.KEYBase):
- """DNSKEY record"""
- pass
+class DNSKEY(dns.rdata.Rdata):
+ """DNSKEY record
+
+ @ivar flags: the key flags
+ @type flags: int
+ @ivar protocol: the protocol for which this key may be used
+ @type protocol: int
+ @ivar algorithm: the algorithm used for the key
+ @type algorithm: int
+ @ivar key: the public key
+ @type key: string"""
+
+ __slots__ = ['flags', 'protocol', 'algorithm', 'key']
+
+ def __init__(self, rdclass, rdtype, flags, protocol, algorithm, key):
+ super(DNSKEY, self).__init__(rdclass, rdtype)
+ self.flags = flags
+ self.protocol = protocol
+ self.algorithm = algorithm
+ self.key = key
+
+ def to_text(self, origin=None, relativize=True, **kw):
+ return '%d %d %d %s' % (self.flags, self.protocol, self.algorithm,
+ dns.rdata._base64ify(self.key))
+
+ def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
+ flags = tok.get_uint16()
+ protocol = tok.get_uint8()
+ algorithm = dns.dnssec.algorithm_from_text(tok.get_string())
+ chunks = []
+ while 1:
+ t = tok.get().unescape()
+ if t.is_eol_or_eof():
+ break
+ if not t.is_identifier():
+ raise dns.exception.SyntaxError
+ chunks.append(t.value)
+ b64 = ''.join(chunks)
+ key = b64.decode('base64_codec')
+ return cls(rdclass, rdtype, flags, protocol, algorithm, key)
+
+ from_text = classmethod(from_text)
+
+ def to_wire(self, file, compress = None, origin = None):
+ header = struct.pack("!HBB", self.flags, self.protocol, self.algorithm)
+ file.write(header)
+ file.write(self.key)
+
+ def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
+ if rdlen < 4:
+ raise dns.exception.FormError
+ header = struct.unpack('!HBB', wire[current : current + 4])
+ current += 4
+ rdlen -= 4
+ key = wire[current : current + rdlen].unwrap()
+ return cls(rdclass, rdtype, header[0], header[1], header[2],
+ key)
+
+ from_wire = classmethod(from_wire)
+
+ 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 = cmp(hs, ho)
+ if v == 0:
+ v = cmp(self.key, other.key)
+ return v
diff --git a/lib/dnspython/dns/rdtypes/ANY/DS.py b/lib/dnspython/dns/rdtypes/ANY/DS.py
index 3a06f448f7..56b6332de2 100644
--- a/lib/dnspython/dns/rdtypes/ANY/DS.py
+++ b/lib/dnspython/dns/rdtypes/ANY/DS.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdtypes/ANY/GPOS.py b/lib/dnspython/dns/rdtypes/ANY/GPOS.py
index 6f63cc05f6..38d1d88b28 100644
--- a/lib/dnspython/dns/rdtypes/ANY/GPOS.py
+++ b/lib/dnspython/dns/rdtypes/ANY/GPOS.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -29,7 +29,7 @@ def _validate_float_string(what):
raise dns.exception.FormError
if not right == '' and not right.isdigit():
raise dns.exception.FormError
-
+
class GPOS(dns.rdata.Rdata):
"""GPOS record
@@ -42,7 +42,7 @@ class GPOS(dns.rdata.Rdata):
@see: RFC 1712"""
__slots__ = ['latitude', 'longitude', 'altitude']
-
+
def __init__(self, rdclass, rdtype, latitude, longitude, altitude):
super(GPOS, self).__init__(rdclass, rdtype)
if isinstance(latitude, float) or \
@@ -66,14 +66,14 @@ class GPOS(dns.rdata.Rdata):
def to_text(self, origin=None, relativize=True, **kw):
return '%s %s %s' % (self.latitude, self.longitude, self.altitude)
-
+
def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
latitude = tok.get_string()
longitude = tok.get_string()
altitude = tok.get_string()
tok.get_eol()
return cls(rdclass, rdtype, latitude, longitude, altitude)
-
+
from_text = classmethod(from_text)
def to_wire(self, file, compress = None, origin = None):
@@ -92,14 +92,14 @@ class GPOS(dns.rdata.Rdata):
byte = chr(l)
file.write(byte)
file.write(self.altitude)
-
+
def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
l = ord(wire[current])
current += 1
rdlen -= 1
if l > rdlen:
raise dns.exception.FormError
- latitude = wire[current : current + l]
+ latitude = wire[current : current + l].unwrap()
current += l
rdlen -= l
l = ord(wire[current])
@@ -107,7 +107,7 @@ class GPOS(dns.rdata.Rdata):
rdlen -= 1
if l > rdlen:
raise dns.exception.FormError
- longitude = wire[current : current + l]
+ longitude = wire[current : current + l].unwrap()
current += l
rdlen -= l
l = ord(wire[current])
@@ -115,7 +115,7 @@ class GPOS(dns.rdata.Rdata):
rdlen -= 1
if l != rdlen:
raise dns.exception.FormError
- altitude = wire[current : current + l]
+ altitude = wire[current : current + l].unwrap()
return cls(rdclass, rdtype, latitude, longitude, altitude)
from_wire = classmethod(from_wire)
diff --git a/lib/dnspython/dns/rdtypes/ANY/HINFO.py b/lib/dnspython/dns/rdtypes/ANY/HINFO.py
index e592ad39a7..15fd54e69e 100644
--- a/lib/dnspython/dns/rdtypes/ANY/HINFO.py
+++ b/lib/dnspython/dns/rdtypes/ANY/HINFO.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -27,7 +27,7 @@ class HINFO(dns.rdata.Rdata):
@see: RFC 1035"""
__slots__ = ['cpu', 'os']
-
+
def __init__(self, rdclass, rdtype, cpu, os):
super(HINFO, self).__init__(rdclass, rdtype)
self.cpu = cpu
@@ -36,13 +36,13 @@ class HINFO(dns.rdata.Rdata):
def to_text(self, origin=None, relativize=True, **kw):
return '"%s" "%s"' % (dns.rdata._escapify(self.cpu),
dns.rdata._escapify(self.os))
-
+
def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
cpu = tok.get_string()
os = tok.get_string()
tok.get_eol()
return cls(rdclass, rdtype, cpu, os)
-
+
from_text = classmethod(from_text)
def to_wire(self, file, compress = None, origin = None):
@@ -56,14 +56,14 @@ class HINFO(dns.rdata.Rdata):
byte = chr(l)
file.write(byte)
file.write(self.os)
-
+
def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
l = ord(wire[current])
current += 1
rdlen -= 1
if l > rdlen:
raise dns.exception.FormError
- cpu = wire[current : current + l]
+ cpu = wire[current : current + l].unwrap()
current += l
rdlen -= l
l = ord(wire[current])
@@ -71,7 +71,7 @@ class HINFO(dns.rdata.Rdata):
rdlen -= 1
if l != rdlen:
raise dns.exception.FormError
- os = wire[current : current + l]
+ os = wire[current : current + l].unwrap()
return cls(rdclass, rdtype, cpu, os)
from_wire = classmethod(from_wire)
diff --git a/lib/dnspython/dns/rdtypes/ANY/HIP.py b/lib/dnspython/dns/rdtypes/ANY/HIP.py
index 8f96ae93d6..968b36f5e2 100644
--- a/lib/dnspython/dns/rdtypes/ANY/HIP.py
+++ b/lib/dnspython/dns/rdtypes/ANY/HIP.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2010 Nominum, Inc.
+# Copyright (C) 2010, 2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -86,10 +86,10 @@ class HIP(dns.rdata.Rdata):
wire[current : current + 4])
current += 4
rdlen -= 4
- hit = wire[current : current + lh]
+ hit = wire[current : current + lh].unwrap()
current += lh
rdlen -= lh
- key = wire[current : current + lk]
+ key = wire[current : current + lk].unwrap()
current += lk
rdlen -= lk
servers = []
diff --git a/lib/dnspython/dns/rdtypes/ANY/ISDN.py b/lib/dnspython/dns/rdtypes/ANY/ISDN.py
index 424d3a9a3c..0c2d3cd035 100644
--- a/lib/dnspython/dns/rdtypes/ANY/ISDN.py
+++ b/lib/dnspython/dns/rdtypes/ANY/ISDN.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -73,7 +73,7 @@ class ISDN(dns.rdata.Rdata):
rdlen -= 1
if l > rdlen:
raise dns.exception.FormError
- address = wire[current : current + l]
+ address = wire[current : current + l].unwrap()
current += l
rdlen -= l
if rdlen > 0:
@@ -82,7 +82,7 @@ class ISDN(dns.rdata.Rdata):
rdlen -= 1
if l != rdlen:
raise dns.exception.FormError
- subaddress = wire[current : current + l]
+ subaddress = wire[current : current + l].unwrap()
else:
subaddress = ''
return cls(rdclass, rdtype, address, subaddress)
diff --git a/lib/dnspython/dns/rdtypes/ANY/KEY.py b/lib/dnspython/dns/rdtypes/ANY/KEY.py
deleted file mode 100644
index c8581edbeb..0000000000
--- a/lib/dnspython/dns/rdtypes/ANY/KEY.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
-#
-# Permission to use, copy, modify, and distribute this software and its
-# documentation for any purpose with or without fee is hereby granted,
-# provided that the above copyright notice and this permission notice
-# appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
-# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-import dns.rdtypes.keybase
-
-class KEY(dns.rdtypes.keybase.KEYBase):
- """KEY record"""
- pass
diff --git a/lib/dnspython/dns/rdtypes/ANY/LOC.py b/lib/dnspython/dns/rdtypes/ANY/LOC.py
index 518dd6010f..154546d79d 100644
--- a/lib/dnspython/dns/rdtypes/ANY/LOC.py
+++ b/lib/dnspython/dns/rdtypes/ANY/LOC.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdtypes/ANY/MX.py b/lib/dnspython/dns/rdtypes/ANY/MX.py
index 9cad260672..92f41532a7 100644
--- a/lib/dnspython/dns/rdtypes/ANY/MX.py
+++ b/lib/dnspython/dns/rdtypes/ANY/MX.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdtypes/ANY/NS.py b/lib/dnspython/dns/rdtypes/ANY/NS.py
index 4b03a3ab47..6b45d4d4b6 100644
--- a/lib/dnspython/dns/rdtypes/ANY/NS.py
+++ b/lib/dnspython/dns/rdtypes/ANY/NS.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdtypes/ANY/NSEC.py b/lib/dnspython/dns/rdtypes/ANY/NSEC.py
index 72859ce108..ad113a4b59 100644
--- a/lib/dnspython/dns/rdtypes/ANY/NSEC.py
+++ b/lib/dnspython/dns/rdtypes/ANY/NSEC.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2004-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2004-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -79,7 +79,7 @@ class NSEC(dns.rdata.Rdata):
bitmap = ['\0'] * 32
window = new_window
offset = nrdtype % 256
- byte = offset / 8
+ byte = offset // 8
bit = offset % 8
octets = byte + 1
bitmap[byte] = chr(ord(bitmap[byte]) | (0x80 >> bit))
@@ -111,7 +111,7 @@ class NSEC(dns.rdata.Rdata):
rdlen -= 2
if rdlen < octets:
raise dns.exception.FormError("bad NSEC bitmap length")
- bitmap = wire[current : current + octets]
+ bitmap = wire[current : current + octets].unwrap()
current += octets
rdlen -= octets
windows.append((window, bitmap))
@@ -125,17 +125,4 @@ class NSEC(dns.rdata.Rdata):
self.next = self.next.choose_relativity(origin, relativize)
def _cmp(self, other):
- v = cmp(self.next, other.next)
- if v == 0:
- b1 = cStringIO.StringIO()
- for (window, bitmap) in self.windows:
- b1.write(chr(window))
- b1.write(chr(len(bitmap)))
- b1.write(bitmap)
- b2 = cStringIO.StringIO()
- for (window, bitmap) in other.windows:
- b2.write(chr(window))
- b2.write(chr(len(bitmap)))
- b2.write(bitmap)
- v = cmp(b1.getvalue(), b2.getvalue())
- return v
+ return self._wire_cmp(other)
diff --git a/lib/dnspython/dns/rdtypes/ANY/NSEC3.py b/lib/dnspython/dns/rdtypes/ANY/NSEC3.py
index 932d7b4032..c7ac7375b4 100644
--- a/lib/dnspython/dns/rdtypes/ANY/NSEC3.py
+++ b/lib/dnspython/dns/rdtypes/ANY/NSEC3.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2004-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2004-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -118,7 +118,7 @@ class NSEC3(dns.rdata.Rdata):
bitmap = ['\0'] * 32
window = new_window
offset = nrdtype % 256
- byte = offset / 8
+ byte = offset // 8
bit = offset % 8
octets = byte + 1
bitmap[byte] = chr(ord(bitmap[byte]) | (0x80 >> bit))
@@ -145,13 +145,13 @@ class NSEC3(dns.rdata.Rdata):
wire[current : current + 5])
current += 5
rdlen -= 5
- salt = wire[current : current + slen]
+ salt = wire[current : current + slen].unwrap()
current += slen
rdlen -= slen
(nlen, ) = struct.unpack('!B', wire[current])
current += 1
rdlen -= 1
- next = wire[current : current + nlen]
+ next = wire[current : current + nlen].unwrap()
current += nlen
rdlen -= nlen
windows = []
@@ -166,7 +166,7 @@ class NSEC3(dns.rdata.Rdata):
rdlen -= 2
if rdlen < octets:
raise dns.exception.FormError("bad NSEC3 bitmap length")
- bitmap = wire[current : current + octets]
+ bitmap = wire[current : current + octets].unwrap()
current += octets
rdlen -= octets
windows.append((window, bitmap))
diff --git a/lib/dnspython/dns/rdtypes/ANY/NSEC3PARAM.py b/lib/dnspython/dns/rdtypes/ANY/NSEC3PARAM.py
index ec91e5e85c..4e687825ad 100644
--- a/lib/dnspython/dns/rdtypes/ANY/NSEC3PARAM.py
+++ b/lib/dnspython/dns/rdtypes/ANY/NSEC3PARAM.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2004-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2004-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -71,7 +71,7 @@ class NSEC3PARAM(dns.rdata.Rdata):
wire[current : current + 5])
current += 5
rdlen -= 5
- salt = wire[current : current + slen]
+ salt = wire[current : current + slen].unwrap()
current += slen
rdlen -= slen
if rdlen != 0:
diff --git a/lib/dnspython/dns/rdtypes/ANY/NXT.py b/lib/dnspython/dns/rdtypes/ANY/NXT.py
deleted file mode 100644
index 99ae9b9dff..0000000000
--- a/lib/dnspython/dns/rdtypes/ANY/NXT.py
+++ /dev/null
@@ -1,99 +0,0 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
-#
-# Permission to use, copy, modify, and distribute this software and its
-# documentation for any purpose with or without fee is hereby granted,
-# provided that the above copyright notice and this permission notice
-# appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
-# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-import dns.exception
-import dns.rdata
-import dns.rdatatype
-import dns.name
-
-class NXT(dns.rdata.Rdata):
- """NXT record
-
- @ivar next: the next name
- @type next: dns.name.Name object
- @ivar bitmap: the type bitmap
- @type bitmap: string
- @see: RFC 2535"""
-
- __slots__ = ['next', 'bitmap']
-
- def __init__(self, rdclass, rdtype, next, bitmap):
- super(NXT, self).__init__(rdclass, rdtype)
- self.next = next
- self.bitmap = bitmap
-
- def to_text(self, origin=None, relativize=True, **kw):
- next = self.next.choose_relativity(origin, relativize)
- bits = []
- for i in xrange(0, len(self.bitmap)):
- byte = ord(self.bitmap[i])
- for j in xrange(0, 8):
- if byte & (0x80 >> j):
- bits.append(dns.rdatatype.to_text(i * 8 + j))
- text = ' '.join(bits)
- return '%s %s' % (next, text)
-
- def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
- next = tok.get_name()
- next = next.choose_relativity(origin, relativize)
- bitmap = ['\x00', '\x00', '\x00', '\x00',
- '\x00', '\x00', '\x00', '\x00',
- '\x00', '\x00', '\x00', '\x00',
- '\x00', '\x00', '\x00', '\x00' ]
- while 1:
- token = tok.get().unescape()
- if token.is_eol_or_eof():
- break
- if token.value.isdigit():
- nrdtype = int(token.value)
- else:
- nrdtype = dns.rdatatype.from_text(token.value)
- if nrdtype == 0:
- raise dns.exception.SyntaxError("NXT with bit 0")
- if nrdtype > 127:
- raise dns.exception.SyntaxError("NXT with bit > 127")
- i = nrdtype // 8
- bitmap[i] = chr(ord(bitmap[i]) | (0x80 >> (nrdtype % 8)))
- bitmap = dns.rdata._truncate_bitmap(bitmap)
- return cls(rdclass, rdtype, next, bitmap)
-
- from_text = classmethod(from_text)
-
- def to_wire(self, file, compress = None, origin = None):
- self.next.to_wire(file, None, origin)
- file.write(self.bitmap)
-
- def to_digestable(self, origin = None):
- return self.next.to_digestable(origin) + self.bitmap
-
- def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
- (next, cused) = dns.name.from_wire(wire[: current + rdlen], current)
- current += cused
- rdlen -= cused
- bitmap = wire[current : current + rdlen]
- if not origin is None:
- next = next.relativize(origin)
- return cls(rdclass, rdtype, next, bitmap)
-
- from_wire = classmethod(from_wire)
-
- def choose_relativity(self, origin = None, relativize = True):
- self.next = self.next.choose_relativity(origin, relativize)
-
- def _cmp(self, other):
- v = cmp(self.next, other.next)
- if v == 0:
- v = cmp(self.bitmap, other.bitmap)
- return v
diff --git a/lib/dnspython/dns/rdtypes/ANY/PTR.py b/lib/dnspython/dns/rdtypes/ANY/PTR.py
index 6c4b79eaac..4a037537b6 100644
--- a/lib/dnspython/dns/rdtypes/ANY/PTR.py
+++ b/lib/dnspython/dns/rdtypes/ANY/PTR.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdtypes/ANY/RP.py b/lib/dnspython/dns/rdtypes/ANY/RP.py
index 421ce8e207..26c55314e1 100644
--- a/lib/dnspython/dns/rdtypes/ANY/RP.py
+++ b/lib/dnspython/dns/rdtypes/ANY/RP.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdtypes/ANY/RRSIG.py b/lib/dnspython/dns/rdtypes/ANY/RRSIG.py
index 0e4816f648..63d389cd7a 100644
--- a/lib/dnspython/dns/rdtypes/ANY/RRSIG.py
+++ b/lib/dnspython/dns/rdtypes/ANY/RRSIG.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2004-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2004-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -13,8 +13,143 @@
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-import dns.rdtypes.sigbase
+import calendar
+import struct
+import time
-class RRSIG(dns.rdtypes.sigbase.SIGBase):
- """RRSIG record"""
+import dns.dnssec
+import dns.exception
+import dns.rdata
+import dns.rdatatype
+
+class BadSigTime(dns.exception.DNSException):
+ """Raised when a SIG or RRSIG RR's time cannot be parsed."""
pass
+
+def sigtime_to_posixtime(what):
+ if len(what) != 14:
+ raise BadSigTime
+ year = int(what[0:4])
+ month = int(what[4:6])
+ day = int(what[6:8])
+ hour = int(what[8:10])
+ minute = int(what[10:12])
+ second = int(what[12:14])
+ return calendar.timegm((year, month, day, hour, minute, second,
+ 0, 0, 0))
+
+def posixtime_to_sigtime(what):
+ return time.strftime('%Y%m%d%H%M%S', time.gmtime(what))
+
+class RRSIG(dns.rdata.Rdata):
+ """RRSIG record
+
+ @ivar type_covered: the rdata type this signature covers
+ @type type_covered: int
+ @ivar algorithm: the algorithm used for the sig
+ @type algorithm: int
+ @ivar labels: number of labels
+ @type labels: int
+ @ivar original_ttl: the original TTL
+ @type original_ttl: long
+ @ivar expiration: signature expiration time
+ @type expiration: long
+ @ivar inception: signature inception time
+ @type inception: long
+ @ivar key_tag: the key tag
+ @type key_tag: int
+ @ivar signer: the signer
+ @type signer: dns.name.Name object
+ @ivar signature: the signature
+ @type signature: string"""
+
+ __slots__ = ['type_covered', 'algorithm', 'labels', 'original_ttl',
+ 'expiration', 'inception', 'key_tag', 'signer',
+ 'signature']
+
+ def __init__(self, rdclass, rdtype, type_covered, algorithm, labels,
+ original_ttl, expiration, inception, key_tag, signer,
+ signature):
+ super(RRSIG, self).__init__(rdclass, rdtype)
+ self.type_covered = type_covered
+ self.algorithm = algorithm
+ self.labels = labels
+ self.original_ttl = original_ttl
+ self.expiration = expiration
+ self.inception = inception
+ self.key_tag = key_tag
+ self.signer = signer
+ self.signature = signature
+
+ def covers(self):
+ return self.type_covered
+
+ def to_text(self, origin=None, relativize=True, **kw):
+ return '%s %d %d %d %s %s %d %s %s' % (
+ dns.rdatatype.to_text(self.type_covered),
+ self.algorithm,
+ self.labels,
+ self.original_ttl,
+ posixtime_to_sigtime(self.expiration),
+ posixtime_to_sigtime(self.inception),
+ self.key_tag,
+ self.signer,
+ dns.rdata._base64ify(self.signature)
+ )
+
+ def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
+ type_covered = dns.rdatatype.from_text(tok.get_string())
+ algorithm = dns.dnssec.algorithm_from_text(tok.get_string())
+ labels = tok.get_int()
+ original_ttl = tok.get_ttl()
+ expiration = sigtime_to_posixtime(tok.get_string())
+ inception = sigtime_to_posixtime(tok.get_string())
+ key_tag = tok.get_int()
+ signer = tok.get_name()
+ signer = signer.choose_relativity(origin, relativize)
+ chunks = []
+ while 1:
+ t = tok.get().unescape()
+ if t.is_eol_or_eof():
+ break
+ if not t.is_identifier():
+ raise dns.exception.SyntaxError
+ chunks.append(t.value)
+ b64 = ''.join(chunks)
+ signature = b64.decode('base64_codec')
+ return cls(rdclass, rdtype, type_covered, algorithm, labels,
+ original_ttl, expiration, inception, key_tag, signer,
+ signature)
+
+ from_text = classmethod(from_text)
+
+ def to_wire(self, file, compress = None, origin = None):
+ header = struct.pack('!HBBIIIH', self.type_covered,
+ self.algorithm, self.labels,
+ self.original_ttl, self.expiration,
+ self.inception, self.key_tag)
+ file.write(header)
+ self.signer.to_wire(file, None, origin)
+ file.write(self.signature)
+
+ def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
+ header = struct.unpack('!HBBIIIH', wire[current : current + 18])
+ current += 18
+ rdlen -= 18
+ (signer, cused) = dns.name.from_wire(wire[: current + rdlen], current)
+ current += cused
+ rdlen -= cused
+ if not origin is None:
+ signer = signer.relativize(origin)
+ signature = wire[current : current + rdlen].unwrap()
+ return cls(rdclass, rdtype, header[0], header[1], header[2],
+ header[3], header[4], header[5], header[6], signer,
+ signature)
+
+ from_wire = classmethod(from_wire)
+
+ def choose_relativity(self, origin = None, relativize = True):
+ self.signer = self.signer.choose_relativity(origin, relativize)
+
+ def _cmp(self, other):
+ return self._wire_cmp(other)
diff --git a/lib/dnspython/dns/rdtypes/ANY/RT.py b/lib/dnspython/dns/rdtypes/ANY/RT.py
index 1efd3724d9..f9653fdb34 100644
--- a/lib/dnspython/dns/rdtypes/ANY/RT.py
+++ b/lib/dnspython/dns/rdtypes/ANY/RT.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdtypes/ANY/SIG.py b/lib/dnspython/dns/rdtypes/ANY/SIG.py
deleted file mode 100644
index 501e29cc8c..0000000000
--- a/lib/dnspython/dns/rdtypes/ANY/SIG.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
-#
-# Permission to use, copy, modify, and distribute this software and its
-# documentation for any purpose with or without fee is hereby granted,
-# provided that the above copyright notice and this permission notice
-# appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
-# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-import dns.rdtypes.sigbase
-
-class SIG(dns.rdtypes.sigbase.SIGBase):
- """SIG record"""
- def to_digestable(self, origin = None):
- return struct.pack('!HBBIIIH', self.type_covered,
- self.algorithm, self.labels,
- self.original_ttl, self.expiration,
- self.inception, self.key_tag) + \
- self.signer.to_digestable(origin) + \
- self.signature
diff --git a/lib/dnspython/dns/rdtypes/ANY/SOA.py b/lib/dnspython/dns/rdtypes/ANY/SOA.py
index a25a35e29b..2d6f21b56b 100644
--- a/lib/dnspython/dns/rdtypes/ANY/SOA.py
+++ b/lib/dnspython/dns/rdtypes/ANY/SOA.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -41,7 +41,7 @@ class SOA(dns.rdata.Rdata):
__slots__ = ['mname', 'rname', 'serial', 'refresh', 'retry', 'expire',
'minimum']
-
+
def __init__(self, rdclass, rdtype, mname, rname, serial, refresh, retry,
expire, minimum):
super(SOA, self).__init__(rdclass, rdtype)
@@ -59,7 +59,7 @@ class SOA(dns.rdata.Rdata):
return '%s %s %d %d %d %d %d' % (
mname, rname, self.serial, self.refresh, self.retry,
self.expire, self.minimum )
-
+
def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
mname = tok.get_name()
rname = tok.get_name()
@@ -73,7 +73,7 @@ class SOA(dns.rdata.Rdata):
tok.get_eol()
return cls(rdclass, rdtype, mname, rname, serial, refresh, retry,
expire, minimum )
-
+
from_text = classmethod(from_text)
def to_wire(self, file, compress = None, origin = None):
diff --git a/lib/dnspython/dns/rdtypes/ANY/SPF.py b/lib/dnspython/dns/rdtypes/ANY/SPF.py
index 9b5a9a9fed..8860dd72bb 100644
--- a/lib/dnspython/dns/rdtypes/ANY/SPF.py
+++ b/lib/dnspython/dns/rdtypes/ANY/SPF.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2006, 2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2006, 2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdtypes/ANY/SSHFP.py b/lib/dnspython/dns/rdtypes/ANY/SSHFP.py
index 162dda5c48..cec650a570 100644
--- a/lib/dnspython/dns/rdtypes/ANY/SSHFP.py
+++ b/lib/dnspython/dns/rdtypes/ANY/SSHFP.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2005-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2005-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -30,7 +30,7 @@ class SSHFP(dns.rdata.Rdata):
@see: draft-ietf-secsh-dns-05.txt"""
__slots__ = ['algorithm', 'fp_type', 'fingerprint']
-
+
def __init__(self, rdclass, rdtype, algorithm, fp_type,
fingerprint):
super(SSHFP, self).__init__(rdclass, rdtype)
@@ -43,7 +43,7 @@ class SSHFP(dns.rdata.Rdata):
self.fp_type,
dns.rdata._hexify(self.fingerprint,
chunksize=128))
-
+
def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
algorithm = tok.get_uint8()
fp_type = tok.get_uint8()
@@ -51,19 +51,19 @@ class SSHFP(dns.rdata.Rdata):
fingerprint = fingerprint.decode('hex_codec')
tok.get_eol()
return cls(rdclass, rdtype, algorithm, fp_type, fingerprint)
-
+
from_text = classmethod(from_text)
def to_wire(self, file, compress = None, origin = None):
header = struct.pack("!BB", self.algorithm, self.fp_type)
file.write(header)
file.write(self.fingerprint)
-
+
def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
header = struct.unpack("!BB", wire[current : current + 2])
current += 2
rdlen -= 2
- fingerprint = wire[current : current + rdlen]
+ fingerprint = wire[current : current + rdlen].unwrap()
return cls(rdclass, rdtype, header[0], header[1], fingerprint)
from_wire = classmethod(from_wire)
diff --git a/lib/dnspython/dns/rdtypes/ANY/TXT.py b/lib/dnspython/dns/rdtypes/ANY/TXT.py
index 23f4f3b7c6..604fd0f4de 100644
--- a/lib/dnspython/dns/rdtypes/ANY/TXT.py
+++ b/lib/dnspython/dns/rdtypes/ANY/TXT.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdtypes/ANY/X25.py b/lib/dnspython/dns/rdtypes/ANY/X25.py
index c3632f7fc4..ae91295f8c 100644
--- a/lib/dnspython/dns/rdtypes/ANY/X25.py
+++ b/lib/dnspython/dns/rdtypes/ANY/X25.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -25,19 +25,19 @@ class X25(dns.rdata.Rdata):
@see: RFC 1183"""
__slots__ = ['address']
-
+
def __init__(self, rdclass, rdtype, address):
super(X25, self).__init__(rdclass, rdtype)
self.address = address
def to_text(self, origin=None, relativize=True, **kw):
return '"%s"' % dns.rdata._escapify(self.address)
-
+
def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
address = tok.get_string()
tok.get_eol()
return cls(rdclass, rdtype, address)
-
+
from_text = classmethod(from_text)
def to_wire(self, file, compress = None, origin = None):
@@ -46,14 +46,14 @@ class X25(dns.rdata.Rdata):
byte = chr(l)
file.write(byte)
file.write(self.address)
-
+
def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
l = ord(wire[current])
current += 1
rdlen -= 1
if l != rdlen:
raise dns.exception.FormError
- address = wire[current : current + l]
+ address = wire[current : current + l].unwrap()
return cls(rdclass, rdtype, address)
from_wire = classmethod(from_wire)
diff --git a/lib/dnspython/dns/rdtypes/ANY/__init__.py b/lib/dnspython/dns/rdtypes/ANY/__init__.py
index 0815dd5450..721e9dd60b 100644
--- a/lib/dnspython/dns/rdtypes/ANY/__init__.py
+++ b/lib/dnspython/dns/rdtypes/ANY/__init__.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -27,19 +27,16 @@ __all__ = [
'HINFO',
'HIP',
'ISDN',
- 'KEY',
'LOC',
'MX',
'NS',
'NSEC',
'NSEC3',
'NSEC3PARAM',
- 'NXT',
'PTR',
'RP',
'RRSIG',
'RT',
- 'SIG',
'SOA',
'SPF',
'SSHFP',
diff --git a/lib/dnspython/dns/rdtypes/IN/A.py b/lib/dnspython/dns/rdtypes/IN/A.py
index e05f204a2f..372d333226 100644
--- a/lib/dnspython/dns/rdtypes/IN/A.py
+++ b/lib/dnspython/dns/rdtypes/IN/A.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdtypes/IN/AAAA.py b/lib/dnspython/dns/rdtypes/IN/AAAA.py
index 2d812d39eb..e131bd5070 100644
--- a/lib/dnspython/dns/rdtypes/IN/AAAA.py
+++ b/lib/dnspython/dns/rdtypes/IN/AAAA.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdtypes/IN/APL.py b/lib/dnspython/dns/rdtypes/IN/APL.py
index 7412c02d30..260fd6f39f 100644
--- a/lib/dnspython/dns/rdtypes/IN/APL.py
+++ b/lib/dnspython/dns/rdtypes/IN/APL.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -131,7 +131,7 @@ class APL(dns.rdata.Rdata):
rdlen -= 4
if rdlen < afdlen:
raise dns.exception.FormError
- address = wire[current : current + afdlen]
+ address = wire[current : current + afdlen].unwrap()
l = len(address)
if header[0] == 1:
if l < 4:
diff --git a/lib/dnspython/dns/rdtypes/IN/DHCID.py b/lib/dnspython/dns/rdtypes/IN/DHCID.py
index 2d35234bf0..5524beadd1 100644
--- a/lib/dnspython/dns/rdtypes/IN/DHCID.py
+++ b/lib/dnspython/dns/rdtypes/IN/DHCID.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2006, 2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2006, 2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -51,7 +51,7 @@ class DHCID(dns.rdata.Rdata):
file.write(self.data)
def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
- data = wire[current : current + rdlen]
+ data = wire[current : current + rdlen].unwrap()
return cls(rdclass, rdtype, data)
from_wire = classmethod(from_wire)
diff --git a/lib/dnspython/dns/rdtypes/IN/IPSECKEY.py b/lib/dnspython/dns/rdtypes/IN/IPSECKEY.py
index 9ab08d881c..d85b6fe993 100644
--- a/lib/dnspython/dns/rdtypes/IN/IPSECKEY.py
+++ b/lib/dnspython/dns/rdtypes/IN/IPSECKEY.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2006, 2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2006, 2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -140,7 +140,7 @@ class IPSECKEY(dns.rdata.Rdata):
rdlen -= cused
else:
raise dns.exception.FormError('invalid IPSECKEY gateway type')
- key = wire[current : current + rdlen]
+ key = wire[current : current + rdlen].unwrap()
return cls(rdclass, rdtype, header[0], gateway_type, header[2],
gateway, key)
diff --git a/lib/dnspython/dns/rdtypes/IN/KX.py b/lib/dnspython/dns/rdtypes/IN/KX.py
index 4d8a3a7d6b..c7bd5bbe65 100644
--- a/lib/dnspython/dns/rdtypes/IN/KX.py
+++ b/lib/dnspython/dns/rdtypes/IN/KX.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdtypes/IN/NAPTR.py b/lib/dnspython/dns/rdtypes/IN/NAPTR.py
index a3cca55e1c..7fe043082b 100644
--- a/lib/dnspython/dns/rdtypes/IN/NAPTR.py
+++ b/lib/dnspython/dns/rdtypes/IN/NAPTR.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -45,7 +45,7 @@ class NAPTR(dns.rdata.Rdata):
__slots__ = ['order', 'preference', 'flags', 'service', 'regexp',
'replacement']
-
+
def __init__(self, rdclass, rdtype, order, preference, flags, service,
regexp, replacement):
super(NAPTR, self).__init__(rdclass, rdtype)
@@ -76,7 +76,7 @@ class NAPTR(dns.rdata.Rdata):
tok.get_eol()
return cls(rdclass, rdtype, order, preference, flags, service,
regexp, replacement)
-
+
from_text = classmethod(from_text)
def to_wire(self, file, compress = None, origin = None):
@@ -86,7 +86,7 @@ class NAPTR(dns.rdata.Rdata):
_write_string(file, self.service)
_write_string(file, self.regexp)
self.replacement.to_wire(file, compress, origin)
-
+
def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
(order, preference) = struct.unpack('!HH', wire[current : current + 4])
current += 4
@@ -98,7 +98,7 @@ class NAPTR(dns.rdata.Rdata):
rdlen -= 1
if l > rdlen or rdlen < 0:
raise dns.exception.FormError
- s = wire[current : current + l]
+ s = wire[current : current + l].unwrap()
current += l
rdlen -= l
strings.append(s)
@@ -116,7 +116,7 @@ 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)
diff --git a/lib/dnspython/dns/rdtypes/IN/NSAP.py b/lib/dnspython/dns/rdtypes/IN/NSAP.py
index 22b9131ccf..216cb0a81a 100644
--- a/lib/dnspython/dns/rdtypes/IN/NSAP.py
+++ b/lib/dnspython/dns/rdtypes/IN/NSAP.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -50,7 +50,7 @@ class NSAP(dns.rdata.Rdata):
file.write(self.address)
def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
- address = wire[current : current + rdlen]
+ address = wire[current : current + rdlen].unwrap()
return cls(rdclass, rdtype, address)
from_wire = classmethod(from_wire)
diff --git a/lib/dnspython/dns/rdtypes/IN/NSAP_PTR.py b/lib/dnspython/dns/rdtypes/IN/NSAP_PTR.py
index 6f591f4ec0..df5b989ac8 100644
--- a/lib/dnspython/dns/rdtypes/IN/NSAP_PTR.py
+++ b/lib/dnspython/dns/rdtypes/IN/NSAP_PTR.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdtypes/IN/PX.py b/lib/dnspython/dns/rdtypes/IN/PX.py
index 0f11290724..1422b83487 100644
--- a/lib/dnspython/dns/rdtypes/IN/PX.py
+++ b/lib/dnspython/dns/rdtypes/IN/PX.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -31,7 +31,7 @@ class PX(dns.rdata.Rdata):
@see: RFC 2163"""
__slots__ = ['preference', 'map822', 'mapx400']
-
+
def __init__(self, rdclass, rdtype, preference, map822, mapx400):
super(PX, self).__init__(rdclass, rdtype)
self.preference = preference
@@ -42,7 +42,7 @@ class PX(dns.rdata.Rdata):
map822 = self.map822.choose_relativity(origin, relativize)
mapx400 = self.mapx400.choose_relativity(origin, relativize)
return '%d %s %s' % (self.preference, map822, mapx400)
-
+
def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
preference = tok.get_uint16()
map822 = tok.get_name()
@@ -51,7 +51,7 @@ class PX(dns.rdata.Rdata):
mapx400 = mapx400.choose_relativity(origin, relativize)
tok.get_eol()
return cls(rdclass, rdtype, preference, map822, mapx400)
-
+
from_text = classmethod(from_text)
def to_wire(self, file, compress = None, origin = None):
@@ -59,7 +59,7 @@ class PX(dns.rdata.Rdata):
file.write(pref)
self.map822.to_wire(file, None, origin)
self.mapx400.to_wire(file, None, origin)
-
+
def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
(preference, ) = struct.unpack('!H', wire[current : current + 2])
current += 2
diff --git a/lib/dnspython/dns/rdtypes/IN/SRV.py b/lib/dnspython/dns/rdtypes/IN/SRV.py
index c9c5823381..e101b26bea 100644
--- a/lib/dnspython/dns/rdtypes/IN/SRV.py
+++ b/lib/dnspython/dns/rdtypes/IN/SRV.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdtypes/IN/WKS.py b/lib/dnspython/dns/rdtypes/IN/WKS.py
index 85aafb3d23..04c3054e44 100644
--- a/lib/dnspython/dns/rdtypes/IN/WKS.py
+++ b/lib/dnspython/dns/rdtypes/IN/WKS.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -95,7 +95,7 @@ class WKS(dns.rdata.Rdata):
protocol, = struct.unpack('!B', wire[current + 4 : current + 5])
current += 5
rdlen -= 5
- bitmap = wire[current : current + rdlen]
+ bitmap = wire[current : current + rdlen].unwrap()
return cls(rdclass, rdtype, address, protocol, bitmap)
from_wire = classmethod(from_wire)
diff --git a/lib/dnspython/dns/rdtypes/IN/__init__.py b/lib/dnspython/dns/rdtypes/IN/__init__.py
index ab931296ec..24cf1ece4e 100644
--- a/lib/dnspython/dns/rdtypes/IN/__init__.py
+++ b/lib/dnspython/dns/rdtypes/IN/__init__.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdtypes/__init__.py b/lib/dnspython/dns/rdtypes/__init__.py
index 13282be73a..49db5a3776 100644
--- a/lib/dnspython/dns/rdtypes/__init__.py
+++ b/lib/dnspython/dns/rdtypes/__init__.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -20,6 +20,4 @@ __all__ = [
'IN',
'mxbase',
'nsbase',
- 'sigbase',
- 'keybase',
]
diff --git a/lib/dnspython/dns/rdtypes/dsbase.py b/lib/dnspython/dns/rdtypes/dsbase.py
index aa46403a5f..6f5559a7e4 100644
--- a/lib/dnspython/dns/rdtypes/dsbase.py
+++ b/lib/dnspython/dns/rdtypes/dsbase.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2010 Nominum, Inc.
+# Copyright (C) 2010, 2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -76,7 +76,7 @@ class DSBase(dns.rdata.Rdata):
header = struct.unpack("!HBB", wire[current : current + 4])
current += 4
rdlen -= 4
- digest = wire[current : current + rdlen]
+ digest = wire[current : current + rdlen].unwrap()
return cls(rdclass, rdtype, header[0], header[1], header[2], digest)
from_wire = classmethod(from_wire)
diff --git a/lib/dnspython/dns/rdtypes/keybase.py b/lib/dnspython/dns/rdtypes/keybase.py
deleted file mode 100644
index 75c9272670..0000000000
--- a/lib/dnspython/dns/rdtypes/keybase.py
+++ /dev/null
@@ -1,149 +0,0 @@
-# Copyright (C) 2004-2007, 2009, 2010 Nominum, Inc.
-#
-# Permission to use, copy, modify, and distribute this software and its
-# documentation for any purpose with or without fee is hereby granted,
-# provided that the above copyright notice and this permission notice
-# appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
-# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-import struct
-
-import dns.exception
-import dns.dnssec
-import dns.rdata
-
-_flags_from_text = {
- 'NOCONF': (0x4000, 0xC000),
- 'NOAUTH': (0x8000, 0xC000),
- 'NOKEY': (0xC000, 0xC000),
- 'FLAG2': (0x2000, 0x2000),
- 'EXTEND': (0x1000, 0x1000),
- 'FLAG4': (0x0800, 0x0800),
- 'FLAG5': (0x0400, 0x0400),
- 'USER': (0x0000, 0x0300),
- 'ZONE': (0x0100, 0x0300),
- 'HOST': (0x0200, 0x0300),
- 'NTYP3': (0x0300, 0x0300),
- 'FLAG8': (0x0080, 0x0080),
- 'FLAG9': (0x0040, 0x0040),
- 'FLAG10': (0x0020, 0x0020),
- 'FLAG11': (0x0010, 0x0010),
- 'SIG0': (0x0000, 0x000f),
- 'SIG1': (0x0001, 0x000f),
- 'SIG2': (0x0002, 0x000f),
- 'SIG3': (0x0003, 0x000f),
- 'SIG4': (0x0004, 0x000f),
- 'SIG5': (0x0005, 0x000f),
- 'SIG6': (0x0006, 0x000f),
- 'SIG7': (0x0007, 0x000f),
- 'SIG8': (0x0008, 0x000f),
- 'SIG9': (0x0009, 0x000f),
- 'SIG10': (0x000a, 0x000f),
- 'SIG11': (0x000b, 0x000f),
- 'SIG12': (0x000c, 0x000f),
- 'SIG13': (0x000d, 0x000f),
- 'SIG14': (0x000e, 0x000f),
- 'SIG15': (0x000f, 0x000f),
- }
-
-_protocol_from_text = {
- 'NONE' : 0,
- 'TLS' : 1,
- 'EMAIL' : 2,
- 'DNSSEC' : 3,
- 'IPSEC' : 4,
- 'ALL' : 255,
- }
-
-class KEYBase(dns.rdata.Rdata):
- """KEY-like record base
-
- @ivar flags: the key flags
- @type flags: int
- @ivar protocol: the protocol for which this key may be used
- @type protocol: int
- @ivar algorithm: the algorithm used for the key
- @type algorithm: int
- @ivar key: the public key
- @type key: string"""
-
- __slots__ = ['flags', 'protocol', 'algorithm', 'key']
-
- def __init__(self, rdclass, rdtype, flags, protocol, algorithm, key):
- super(KEYBase, self).__init__(rdclass, rdtype)
- self.flags = flags
- self.protocol = protocol
- self.algorithm = algorithm
- self.key = key
-
- def to_text(self, origin=None, relativize=True, **kw):
- return '%d %d %d %s' % (self.flags, self.protocol, self.algorithm,
- dns.rdata._base64ify(self.key))
-
- def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
- flags = tok.get_string()
- if flags.isdigit():
- flags = int(flags)
- else:
- flag_names = flags.split('|')
- flags = 0
- for flag in flag_names:
- v = _flags_from_text.get(flag)
- if v is None:
- raise dns.exception.SyntaxError('unknown flag %s' % flag)
- flags &= ~v[1]
- flags |= v[0]
- protocol = tok.get_string()
- if protocol.isdigit():
- protocol = int(protocol)
- else:
- protocol = _protocol_from_text.get(protocol)
- if protocol is None:
- raise dns.exception.SyntaxError('unknown protocol %s' % protocol)
-
- algorithm = dns.dnssec.algorithm_from_text(tok.get_string())
- chunks = []
- while 1:
- t = tok.get().unescape()
- if t.is_eol_or_eof():
- break
- if not t.is_identifier():
- raise dns.exception.SyntaxError
- chunks.append(t.value)
- b64 = ''.join(chunks)
- key = b64.decode('base64_codec')
- return cls(rdclass, rdtype, flags, protocol, algorithm, key)
-
- from_text = classmethod(from_text)
-
- def to_wire(self, file, compress = None, origin = None):
- header = struct.pack("!HBB", self.flags, self.protocol, self.algorithm)
- file.write(header)
- file.write(self.key)
-
- def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
- if rdlen < 4:
- raise dns.exception.FormError
- header = struct.unpack('!HBB', wire[current : current + 4])
- current += 4
- rdlen -= 4
- key = wire[current : current + rdlen]
- return cls(rdclass, rdtype, header[0], header[1], header[2],
- key)
-
- from_wire = classmethod(from_wire)
-
- 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 = cmp(hs, ho)
- if v == 0:
- v = cmp(self.key, other.key)
- return v
diff --git a/lib/dnspython/dns/rdtypes/mxbase.py b/lib/dnspython/dns/rdtypes/mxbase.py
index 5e3515bec4..abc6a9ed5b 100644
--- a/lib/dnspython/dns/rdtypes/mxbase.py
+++ b/lib/dnspython/dns/rdtypes/mxbase.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdtypes/nsbase.py b/lib/dnspython/dns/rdtypes/nsbase.py
index 7cdb2a0289..fbd5ef1e51 100644
--- a/lib/dnspython/dns/rdtypes/nsbase.py
+++ b/lib/dnspython/dns/rdtypes/nsbase.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rdtypes/sigbase.py b/lib/dnspython/dns/rdtypes/sigbase.py
deleted file mode 100644
index ccb6dd69ae..0000000000
--- a/lib/dnspython/dns/rdtypes/sigbase.py
+++ /dev/null
@@ -1,168 +0,0 @@
-# Copyright (C) 2004-2007, 2009, 2010 Nominum, Inc.
-#
-# Permission to use, copy, modify, and distribute this software and its
-# documentation for any purpose with or without fee is hereby granted,
-# provided that the above copyright notice and this permission notice
-# appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
-# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-import calendar
-import struct
-import time
-
-import dns.dnssec
-import dns.exception
-import dns.rdata
-import dns.rdatatype
-
-class BadSigTime(dns.exception.DNSException):
- """Raised when a SIG or RRSIG RR's time cannot be parsed."""
- pass
-
-def sigtime_to_posixtime(what):
- if len(what) != 14:
- raise BadSigTime
- year = int(what[0:4])
- month = int(what[4:6])
- day = int(what[6:8])
- hour = int(what[8:10])
- minute = int(what[10:12])
- second = int(what[12:14])
- return calendar.timegm((year, month, day, hour, minute, second,
- 0, 0, 0))
-
-def posixtime_to_sigtime(what):
- return time.strftime('%Y%m%d%H%M%S', time.gmtime(what))
-
-class SIGBase(dns.rdata.Rdata):
- """SIG-like record base
-
- @ivar type_covered: the rdata type this signature covers
- @type type_covered: int
- @ivar algorithm: the algorithm used for the sig
- @type algorithm: int
- @ivar labels: number of labels
- @type labels: int
- @ivar original_ttl: the original TTL
- @type original_ttl: long
- @ivar expiration: signature expiration time
- @type expiration: long
- @ivar inception: signature inception time
- @type inception: long
- @ivar key_tag: the key tag
- @type key_tag: int
- @ivar signer: the signer
- @type signer: dns.name.Name object
- @ivar signature: the signature
- @type signature: string"""
-
- __slots__ = ['type_covered', 'algorithm', 'labels', 'original_ttl',
- 'expiration', 'inception', 'key_tag', 'signer',
- 'signature']
-
- def __init__(self, rdclass, rdtype, type_covered, algorithm, labels,
- original_ttl, expiration, inception, key_tag, signer,
- signature):
- super(SIGBase, self).__init__(rdclass, rdtype)
- self.type_covered = type_covered
- self.algorithm = algorithm
- self.labels = labels
- self.original_ttl = original_ttl
- self.expiration = expiration
- self.inception = inception
- self.key_tag = key_tag
- self.signer = signer
- self.signature = signature
-
- def covers(self):
- return self.type_covered
-
- def to_text(self, origin=None, relativize=True, **kw):
- return '%s %d %d %d %s %s %d %s %s' % (
- dns.rdatatype.to_text(self.type_covered),
- self.algorithm,
- self.labels,
- self.original_ttl,
- posixtime_to_sigtime(self.expiration),
- posixtime_to_sigtime(self.inception),
- self.key_tag,
- self.signer,
- dns.rdata._base64ify(self.signature)
- )
-
- def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
- type_covered = dns.rdatatype.from_text(tok.get_string())
- algorithm = dns.dnssec.algorithm_from_text(tok.get_string())
- labels = tok.get_int()
- original_ttl = tok.get_ttl()
- expiration = sigtime_to_posixtime(tok.get_string())
- inception = sigtime_to_posixtime(tok.get_string())
- key_tag = tok.get_int()
- signer = tok.get_name()
- signer = signer.choose_relativity(origin, relativize)
- chunks = []
- while 1:
- t = tok.get().unescape()
- if t.is_eol_or_eof():
- break
- if not t.is_identifier():
- raise dns.exception.SyntaxError
- chunks.append(t.value)
- b64 = ''.join(chunks)
- signature = b64.decode('base64_codec')
- return cls(rdclass, rdtype, type_covered, algorithm, labels,
- original_ttl, expiration, inception, key_tag, signer,
- signature)
-
- from_text = classmethod(from_text)
-
- def to_wire(self, file, compress = None, origin = None):
- header = struct.pack('!HBBIIIH', self.type_covered,
- self.algorithm, self.labels,
- self.original_ttl, self.expiration,
- self.inception, self.key_tag)
- file.write(header)
- self.signer.to_wire(file, None, origin)
- file.write(self.signature)
-
- def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
- header = struct.unpack('!HBBIIIH', wire[current : current + 18])
- current += 18
- rdlen -= 18
- (signer, cused) = dns.name.from_wire(wire[: current + rdlen], current)
- current += cused
- rdlen -= cused
- if not origin is None:
- signer = signer.relativize(origin)
- signature = wire[current : current + rdlen]
- return cls(rdclass, rdtype, header[0], header[1], header[2],
- header[3], header[4], header[5], header[6], signer,
- signature)
-
- from_wire = classmethod(from_wire)
-
- 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 = cmp(hs, ho)
- if v == 0:
- v = cmp(self.signer, other.signer)
- if v == 0:
- v = cmp(self.signature, other.signature)
- return v
diff --git a/lib/dnspython/dns/rdtypes/txtbase.py b/lib/dnspython/dns/rdtypes/txtbase.py
index 43db2a48c0..580f056ea0 100644
--- a/lib/dnspython/dns/rdtypes/txtbase.py
+++ b/lib/dnspython/dns/rdtypes/txtbase.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2006, 2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2006, 2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -75,7 +75,7 @@ class TXTBase(dns.rdata.Rdata):
rdlen -= 1
if l > rdlen:
raise dns.exception.FormError
- s = wire[current : current + l]
+ s = wire[current : current + l].unwrap()
current += l
rdlen -= l
strings.append(s)
diff --git a/lib/dnspython/dns/renderer.py b/lib/dnspython/dns/renderer.py
index bb0218ac30..ad3f83d450 100644
--- a/lib/dnspython/dns/renderer.py
+++ b/lib/dnspython/dns/renderer.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2001-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -267,8 +267,9 @@ class Renderer(object):
@type other_data: string
@param request_mac: This message is a response to the request which
had the specified MAC.
- @param algorithm: the TSIG algorithm to use
@type request_mac: string
+ @param algorithm: the TSIG algorithm to use
+ @type algorithm: dns.name.Name object
"""
self._set_section(ADDITIONAL)
diff --git a/lib/dnspython/dns/resolver.py b/lib/dnspython/dns/resolver.py
index 30977f3a8b..90f95e8ed0 100644
--- a/lib/dnspython/dns/resolver.py
+++ b/lib/dnspython/dns/resolver.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -23,12 +23,15 @@ import sys
import time
import dns.exception
+import dns.ipv4
+import dns.ipv6
import dns.message
import dns.name
import dns.query
import dns.rcode
import dns.rdataclass
import dns.rdatatype
+import dns.reversename
if sys.platform == 'win32':
import _winreg
@@ -93,8 +96,11 @@ class Answer(object):
@type rrset: dns.rrset.RRset object
@ivar expiration: The time when the answer expires
@type expiration: float (seconds since the epoch)
+ @ivar canonical_name: The canonical name of the query name
+ @type canonical_name: dns.name.Name object
"""
- def __init__(self, qname, rdtype, rdclass, response):
+ def __init__(self, qname, rdtype, rdclass, response,
+ raise_on_no_answer=True):
self.qname = qname
self.rdtype = rdtype
self.rdclass = rdclass
@@ -122,11 +128,31 @@ class Answer(object):
break
continue
except KeyError:
- raise NoAnswer
- raise NoAnswer
- if rrset is None:
+ if raise_on_no_answer:
+ raise NoAnswer
+ if raise_on_no_answer:
+ raise NoAnswer
+ if rrset is None and raise_on_no_answer:
raise NoAnswer
+ self.canonical_name = qname
self.rrset = rrset
+ if rrset is None:
+ while 1:
+ # Look for a SOA RR whose owner name is a superdomain
+ # of qname.
+ try:
+ srrset = response.find_rrset(response.authority, qname,
+ rdclass, dns.rdatatype.SOA)
+ if min_ttl == -1 or srrset.ttl < min_ttl:
+ min_ttl = srrset.ttl
+ if srrset[0].minimum < min_ttl:
+ min_ttl = srrset[0].minimum
+ break
+ except KeyError:
+ try:
+ qname = qname.parent()
+ except dns.name.NoParent:
+ break
self.expiration = time.time() + min_ttl
def __getattr__(self, attr):
@@ -244,6 +270,127 @@ class Cache(object):
self.data = {}
self.next_cleaning = time.time() + self.cleaning_interval
+class LRUCacheNode(object):
+ """LRUCache node.
+ """
+ def __init__(self, key, value):
+ self.key = key
+ self.value = value
+ self.prev = self
+ self.next = self
+
+ def link_before(self, node):
+ self.prev = node.prev
+ self.next = node
+ node.prev.next = self
+ node.prev = self
+
+ def link_after(self, node):
+ self.prev = node
+ self.next = node.next
+ node.next.prev = self
+ node.next = self
+
+ def unlink(self):
+ self.next.prev = self.prev
+ self.prev.next = self.next
+
+class LRUCache(object):
+ """Bounded least-recently-used DNS answer cache.
+
+ This cache is better than the simple cache (above) if you're
+ running a web crawler or other process that does a lot of
+ resolutions. The LRUCache has a maximum number of nodes, and when
+ it is full, the least-recently used node is removed to make space
+ for a new one.
+
+ @ivar data: A dictionary of cached data
+ @type data: dict
+ @ivar sentinel: sentinel node for circular doubly linked list of nodes
+ @type sentinel: LRUCacheNode object
+ @ivar max_size: The maximum number of nodes
+ @type max_size: int
+ """
+
+ def __init__(self, max_size=100000):
+ """Initialize a DNS cache.
+
+ @param max_size: The maximum number of nodes to cache; the default is
+ 100000. Must be > 1.
+ @type max_size: int
+ """
+ self.data = {}
+ self.set_max_size(max_size)
+ self.sentinel = LRUCacheNode(None, None)
+
+ def set_max_size(self, max_size):
+ if max_size < 1:
+ max_size = 1
+ self.max_size = max_size
+
+ def get(self, key):
+ """Get the answer associated with I{key}. Returns None if
+ no answer is cached for the key.
+ @param key: the key
+ @type key: (dns.name.Name, int, int) tuple whose values are the
+ query name, rdtype, and rdclass.
+ @rtype: dns.resolver.Answer object or None
+ """
+ node = self.data.get(key)
+ if node is None:
+ return None
+ # Unlink because we're either going to move the node to the front
+ # of the LRU list or we're going to free it.
+ node.unlink()
+ if node.value.expiration <= time.time():
+ del self.data[node.key]
+ return None
+ node.link_after(self.sentinel)
+ return node.value
+
+ def put(self, key, value):
+ """Associate key and value in the cache.
+ @param key: the key
+ @type key: (dns.name.Name, int, int) tuple whose values are the
+ query name, rdtype, and rdclass.
+ @param value: The answer being cached
+ @type value: dns.resolver.Answer object
+ """
+ node = self.data.get(key)
+ if not node is None:
+ node.unlink()
+ del self.data[node.key]
+ while len(self.data) >= self.max_size:
+ node = self.sentinel.prev
+ node.unlink()
+ del self.data[node.key]
+ node = LRUCacheNode(key, value)
+ node.link_after(self.sentinel)
+ self.data[key] = node
+
+ def flush(self, key=None):
+ """Flush the cache.
+
+ If I{key} is specified, only that item is flushed. Otherwise
+ the entire cache is flushed.
+
+ @param key: the key to flush
+ @type key: (dns.name.Name, int, int) tuple or None
+ """
+ if not key is None:
+ node = self.data.get(key)
+ if not node is None:
+ node.unlink()
+ del self.data[node.key]
+ else:
+ node = self.sentinel.next
+ while node != self.sentinel:
+ next = node.next
+ node.prev = None
+ node.next = None
+ node = next
+ self.data = {}
+
class Resolver(object):
"""DNS stub resolver
@@ -546,7 +693,7 @@ class Resolver(object):
return min(self.lifetime - duration, self.timeout)
def query(self, qname, rdtype=dns.rdatatype.A, rdclass=dns.rdataclass.IN,
- tcp=False, source=None):
+ tcp=False, source=None, raise_on_no_answer=True):
"""Query nameservers to find the answer to the question.
The I{qname}, I{rdtype}, and I{rdclass} parameters may be objects
@@ -564,10 +711,14 @@ class Resolver(object):
@type tcp: bool
@param source: bind to this IP address (defaults to machine default IP).
@type source: IP address in dotted quad notation
+ @param raise_on_no_answer: raise NoAnswer if there's no answer
+ (defaults is True).
+ @type raise_on_no_answer: bool
@rtype: dns.resolver.Answer instance
@raises Timeout: no answers could be found in the specified lifetime
@raises NXDOMAIN: the query name does not exist
- @raises NoAnswer: the response did not contain an answer
+ @raises NoAnswer: the response did not contain an answer and
+ raise_on_no_answer is True.
@raises NoNameservers: no non-broken nameservers are available to
answer the question."""
@@ -597,8 +748,11 @@ class Resolver(object):
for qname in qnames_to_try:
if self.cache:
answer = self.cache.get((qname, rdtype, rdclass))
- if answer:
- return answer
+ if not answer is None:
+ if answer.rrset is None and raise_on_no_answer:
+ raise NoAnswer
+ else:
+ return answer
request = dns.message.make_query(qname, rdtype, rdclass)
if not self.keyname is None:
request.use_tsig(self.keyring, self.keyname,
@@ -678,7 +832,8 @@ class Resolver(object):
break
if all_nxdomain:
raise NXDOMAIN
- answer = Answer(qname, rdtype, rdclass, response)
+ answer = Answer(qname, rdtype, rdclass, response,
+ raise_on_no_answer)
if self.cache:
self.cache.put((qname, rdtype, rdclass), answer)
return answer
@@ -731,14 +886,15 @@ def get_default_resolver():
return default_resolver
def query(qname, rdtype=dns.rdatatype.A, rdclass=dns.rdataclass.IN,
- tcp=False, source=None):
+ tcp=False, source=None, raise_on_no_answer=True):
"""Query nameservers to find the answer to the question.
This is a convenience function that uses the default resolver
object to make the query.
@see: L{dns.resolver.Resolver.query} for more information on the
parameters."""
- return get_default_resolver().query(qname, rdtype, rdclass, tcp, source)
+ return get_default_resolver().query(qname, rdtype, rdclass, tcp, source,
+ raise_on_no_answer)
def zone_for_name(name, rdclass=dns.rdataclass.IN, tcp=False, resolver=None):
"""Find the name of the zone which contains the specified name.
@@ -771,3 +927,235 @@ def zone_for_name(name, rdclass=dns.rdataclass.IN, tcp=False, resolver=None):
name = name.parent()
except dns.name.NoParent:
raise NoRootSOA
+
+#
+# Support for overriding the system resolver for all python code in the
+# running process.
+#
+
+_protocols_for_socktype = {
+ socket.SOCK_DGRAM : [socket.SOL_UDP],
+ socket.SOCK_STREAM : [socket.SOL_TCP],
+ }
+
+_resolver = None
+_original_getaddrinfo = socket.getaddrinfo
+_original_getnameinfo = socket.getnameinfo
+_original_getfqdn = socket.getfqdn
+_original_gethostbyname = socket.gethostbyname
+_original_gethostbyname_ex = socket.gethostbyname_ex
+_original_gethostbyaddr = socket.gethostbyaddr
+
+def _getaddrinfo(host=None, service=None, family=socket.AF_UNSPEC, socktype=0,
+ proto=0, flags=0):
+ if flags & (socket.AI_ADDRCONFIG|socket.AI_V4MAPPED) != 0:
+ raise NotImplementedError
+ if host is None and service is None:
+ raise socket.gaierror(socket.EAI_NONAME)
+ v6addrs = []
+ v4addrs = []
+ canonical_name = None
+ try:
+ # Is host None or a V6 address literal?
+ if host is None:
+ canonical_name = 'localhost'
+ if flags & socket.AI_PASSIVE != 0:
+ v6addrs.append('::')
+ v4addrs.append('0.0.0.0')
+ else:
+ v6addrs.append('::1')
+ v4addrs.append('127.0.0.1')
+ else:
+ parts = host.split('%')
+ if len(parts) == 2:
+ ahost = parts[0]
+ else:
+ ahost = host
+ addr = dns.ipv6.inet_aton(ahost)
+ v6addrs.append(host)
+ canonical_name = host
+ except:
+ try:
+ # Is it a V4 address literal?
+ addr = dns.ipv4.inet_aton(host)
+ v4addrs.append(host)
+ canonical_name = host
+ except:
+ if flags & socket.AI_NUMERICHOST == 0:
+ try:
+ qname = None
+ if family == socket.AF_INET6 or family == socket.AF_UNSPEC:
+ v6 = _resolver.query(host, dns.rdatatype.AAAA,
+ raise_on_no_answer=False)
+ # Note that setting host ensures we query the same name
+ # for A as we did for AAAA.
+ host = v6.qname
+ canonical_name = v6.canonical_name.to_text(True)
+ if v6.rrset is not None:
+ for rdata in v6.rrset:
+ v6addrs.append(rdata.address)
+ if family == socket.AF_INET or family == socket.AF_UNSPEC:
+ v4 = _resolver.query(host, dns.rdatatype.A,
+ raise_on_no_answer=False)
+ host = v4.qname
+ canonical_name = v4.canonical_name.to_text(True)
+ if v4.rrset is not None:
+ for rdata in v4.rrset:
+ v4addrs.append(rdata.address)
+ except dns.resolver.NXDOMAIN:
+ raise socket.gaierror(socket.EAI_NONAME)
+ except:
+ raise socket.gaierror(socket.EAI_SYSTEM)
+ port = None
+ try:
+ # Is it a port literal?
+ if service is None:
+ port = 0
+ else:
+ port = int(service)
+ except:
+ if flags & socket.AI_NUMERICSERV == 0:
+ try:
+ port = socket.getservbyname(service)
+ except:
+ pass
+ if port is None:
+ raise socket.gaierror(socket.EAI_NONAME)
+ tuples = []
+ if socktype == 0:
+ socktypes = [socket.SOCK_DGRAM, socket.SOCK_STREAM]
+ else:
+ socktypes = [socktype]
+ if flags & socket.AI_CANONNAME != 0:
+ cname = canonical_name
+ else:
+ cname = ''
+ if family == socket.AF_INET6 or family == socket.AF_UNSPEC:
+ for addr in v6addrs:
+ for socktype in socktypes:
+ for proto in _protocols_for_socktype[socktype]:
+ tuples.append((socket.AF_INET6, socktype, proto,
+ cname, (addr, port, 0, 0)))
+ if family == socket.AF_INET or family == socket.AF_UNSPEC:
+ for addr in v4addrs:
+ for socktype in socktypes:
+ for proto in _protocols_for_socktype[socktype]:
+ tuples.append((socket.AF_INET, socktype, proto,
+ cname, (addr, port)))
+ if len(tuples) == 0:
+ raise socket.gaierror(socket.EAI_NONAME)
+ return tuples
+
+def _getnameinfo(sockaddr, flags=0):
+ host = sockaddr[0]
+ port = sockaddr[1]
+ if len(sockaddr) == 4:
+ scope = sockaddr[3]
+ family = socket.AF_INET6
+ else:
+ scope = None
+ family = socket.AF_INET
+ tuples = _getaddrinfo(host, port, family, socket.SOCK_STREAM,
+ socket.SOL_TCP, 0)
+ if len(tuples) > 1:
+ raise socket.error('sockaddr resolved to multiple addresses')
+ addr = tuples[0][4][0]
+ if flags & socket.NI_DGRAM:
+ pname = 'udp'
+ else:
+ pname = 'tcp'
+ qname = dns.reversename.from_address(addr)
+ if flags & socket.NI_NUMERICHOST == 0:
+ try:
+ answer = _resolver.query(qname, 'PTR')
+ hostname = answer.rrset[0].target.to_text(True)
+ except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
+ if flags & socket.NI_NAMEREQD:
+ raise socket.gaierror(socket.EAI_NONAME)
+ hostname = addr
+ if scope is not None:
+ hostname += '%' + str(scope)
+ else:
+ hostname = addr
+ if scope is not None:
+ hostname += '%' + str(scope)
+ if flags & socket.NI_NUMERICSERV:
+ service = str(port)
+ else:
+ service = socket.getservbyport(port, pname)
+ return (hostname, service)
+
+def _getfqdn(name=None):
+ if name is None:
+ name = socket.gethostname()
+ return _getnameinfo(_getaddrinfo(name, 80)[0][4])[0]
+
+def _gethostbyname(name):
+ return _gethostbyname_ex(name)[2][0]
+
+def _gethostbyname_ex(name):
+ aliases = []
+ addresses = []
+ tuples = _getaddrinfo(name, 0, socket.AF_INET, socket.SOCK_STREAM,
+ socket.SOL_TCP, socket.AI_CANONNAME)
+ canonical = tuples[0][3]
+ for item in tuples:
+ addresses.append(item[4][0])
+ # XXX we just ignore aliases
+ return (canonical, aliases, addresses)
+
+def _gethostbyaddr(ip):
+ try:
+ addr = dns.ipv6.inet_aton(ip)
+ sockaddr = (ip, 80, 0, 0)
+ family = socket.AF_INET6
+ except:
+ sockaddr = (ip, 80)
+ family = socket.AF_INET
+ (name, port) = _getnameinfo(sockaddr, socket.NI_NAMEREQD)
+ aliases = []
+ addresses = []
+ tuples = _getaddrinfo(name, 0, family, socket.SOCK_STREAM, socket.SOL_TCP,
+ socket.AI_CANONNAME)
+ canonical = tuples[0][3]
+ for item in tuples:
+ addresses.append(item[4][0])
+ # XXX we just ignore aliases
+ return (canonical, aliases, addresses)
+
+def override_system_resolver(resolver=None):
+ """Override the system resolver routines in the socket module with
+ versions which use dnspython's resolver.
+
+ This can be useful in testing situations where you want to control
+ the resolution behavior of python code without having to change
+ the system's resolver settings (e.g. /etc/resolv.conf).
+
+ The resolver to use may be specified; if it's not, the default
+ resolver will be used.
+
+ @param resolver: the resolver to use
+ @type resolver: dns.resolver.Resolver object or None
+ """
+ if resolver is None:
+ resolver = get_default_resolver()
+ global _resolver
+ _resolver = resolver
+ socket.getaddrinfo = _getaddrinfo
+ socket.getnameinfo = _getnameinfo
+ socket.getfqdn = _getfqdn
+ socket.gethostbyname = _gethostbyname
+ socket.gethostbyname_ex = _gethostbyname_ex
+ socket.gethostbyaddr = _gethostbyaddr
+
+def restore_system_resolver():
+ """Undo the effects of override_system_resolver().
+ """
+ global _resolver
+ _resolver = None
+ socket.getaddrinfo = _original_getaddrinfo
+ socket.getnameinfo = _original_getnameinfo
+ socket.getfqdn = _original_getfqdn
+ socket.gethostbyname = _original_gethostbyname
+ socket.gethostbyname_ex = _original_gethostbyname_ex
+ socket.gethostbyaddr = _original_gethostbyaddr
diff --git a/lib/dnspython/dns/reversename.py b/lib/dnspython/dns/reversename.py
index 0a61b827b0..4925cfd6ff 100644
--- a/lib/dnspython/dns/reversename.py
+++ b/lib/dnspython/dns/reversename.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2006, 2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2006, 2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/rrset.py b/lib/dnspython/dns/rrset.py
index 21468174d4..f6051fea4f 100644
--- a/lib/dnspython/dns/rrset.py
+++ b/lib/dnspython/dns/rrset.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/set.py b/lib/dnspython/dns/set.py
index 91f9fb8766..14c76a05c4 100644
--- a/lib/dnspython/dns/set.py
+++ b/lib/dnspython/dns/set.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/tokenizer.py b/lib/dnspython/dns/tokenizer.py
index 4f68a2a495..4bff7b6c72 100644
--- a/lib/dnspython/dns/tokenizer.py
+++ b/lib/dnspython/dns/tokenizer.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/tsig.py b/lib/dnspython/dns/tsig.py
index 5e58ea8841..63b925afbb 100644
--- a/lib/dnspython/dns/tsig.py
+++ b/lib/dnspython/dns/tsig.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2001-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/tsigkeyring.py b/lib/dnspython/dns/tsigkeyring.py
index cbd1a27bbf..0ddd93410f 100644
--- a/lib/dnspython/dns/tsigkeyring.py
+++ b/lib/dnspython/dns/tsigkeyring.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/ttl.py b/lib/dnspython/dns/ttl.py
index f295300517..ab6ddf4e66 100644
--- a/lib/dnspython/dns/ttl.py
+++ b/lib/dnspython/dns/ttl.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/update.py b/lib/dnspython/dns/update.py
index e67acafec9..e692226918 100644
--- a/lib/dnspython/dns/update.py
+++ b/lib/dnspython/dns/update.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
diff --git a/lib/dnspython/dns/version.py b/lib/dnspython/dns/version.py
index 46799a77d9..7de430b638 100644
--- a/lib/dnspython/dns/version.py
+++ b/lib/dnspython/dns/version.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,
@@ -16,8 +16,8 @@
"""dnspython release version information."""
MAJOR = 1
-MINOR = 9
-MICRO = 3
+MINOR = 10
+MICRO = 0
RELEASELEVEL = 0x0f
SERIAL = 0
diff --git a/lib/dnspython/dns/wiredata.py b/lib/dnspython/dns/wiredata.py
new file mode 100644
index 0000000000..86d954a90a
--- /dev/null
+++ b/lib/dnspython/dns/wiredata.py
@@ -0,0 +1,59 @@
+# Copyright (C) 2011 Nominum, Inc.
+#
+# Permission to use, copy, modify, and distribute this software and its
+# documentation for any purpose with or without fee is hereby granted,
+# provided that the above copyright notice and this permission notice
+# appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+"""DNS Wire Data Helper"""
+
+import sys
+
+import dns.exception
+
+class WireData(str):
+ # WireData is a string with stricter slicing
+ def __getitem__(self, key):
+ try:
+ return WireData(super(WireData, self).__getitem__(key))
+ except IndexError:
+ raise dns.exception.FormError
+ def __getslice__(self, i, j):
+ try:
+ if j == sys.maxint:
+ # handle the case where the right bound is unspecified
+ j = len(self)
+ if i < 0 or j < 0:
+ raise dns.exception.FormError
+ # If it's not an empty slice, access left and right bounds
+ # to make sure they're valid
+ if i != j:
+ super(WireData, self).__getitem__(i)
+ super(WireData, self).__getitem__(j - 1)
+ return WireData(super(WireData, self).__getslice__(i, j))
+ except IndexError:
+ raise dns.exception.FormError
+ def __iter__(self):
+ i = 0
+ while 1:
+ try:
+ yield self[i]
+ i += 1
+ except dns.exception.FormError:
+ raise StopIteration
+ def unwrap(self):
+ return str(self)
+
+def maybe_wrap(wire):
+ if not isinstance(wire, WireData):
+ return WireData(wire)
+ else:
+ return wire
diff --git a/lib/dnspython/dns/zone.py b/lib/dnspython/dns/zone.py
index db5fd5df85..67c952d3cc 100644
--- a/lib/dnspython/dns/zone.py
+++ b/lib/dnspython/dns/zone.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2003-2007, 2009, 2010 Nominum, Inc.
+# Copyright (C) 2003-2007, 2009-2011 Nominum, Inc.
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose with or without fee is hereby granted,