mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
dnspython: Update to latest upstream snapshot.
Autobuild-User: Jelmer Vernooij <jelmer@samba.org> Autobuild-Date: Sat Aug 27 17:40:39 CEST 2011 on sn-devel-104
This commit is contained in:
parent
bd01a8e79f
commit
8bd71350ab
@ -1,3 +1,74 @@
|
||||
2011-08-22 Robert Halley <halley@dnspython.org>
|
||||
|
||||
* dns/resolver.py: Added LRUCache, which allows a maximum number
|
||||
of nodes to be cached, and removes the least-recently used node
|
||||
when adding a new node to a full cache.
|
||||
|
||||
2011-07-13 Bob Halley <halley@dnspython.org>
|
||||
|
||||
* dns/resolver.py: dns.resolver.override_system_resolver()
|
||||
overrides the socket module's versions of getaddrinfo(),
|
||||
getnameinfo(), getfqdn(), gethostbyname(), gethostbyname_ex() and
|
||||
gethostbyaddr() with an implementation which uses a dnspython stub
|
||||
resolver instead of the system's stub 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).
|
||||
dns.resolver.restore_system_resolver() undoes the change.
|
||||
|
||||
2011-07-08 Bob Halley <halley@dnspython.org>
|
||||
|
||||
* dns/ipv4.py: dnspython now provides its own, stricter, versions
|
||||
of IPv4 inet_ntoa() and inet_aton() instead of using the OS's
|
||||
versions.
|
||||
|
||||
* dns/ipv6.py: inet_aton() now bounds checks embedded IPv4 addresses
|
||||
more strictly. Also, now only dns.exception.SyntaxError can be
|
||||
raised on bad input.
|
||||
|
||||
2011-04-05 Bob Halley <halley@dnspython.org>
|
||||
|
||||
* Old DNSSEC types (KEY, NXT, and SIG) have been removed.
|
||||
|
||||
* Bounds checking of slices in rdata wire processing is now more
|
||||
strict, and bounds errors (e.g. we got less data than was
|
||||
expected) now raise dns.exception.FormError rather than
|
||||
IndexError.
|
||||
|
||||
2011-03-28 Bob Halley <halley@dnspython.org>
|
||||
|
||||
* (Version 1.9.4 released)
|
||||
|
||||
2011-03-24 Bob Halley <halley@dnspython.org>
|
||||
|
||||
* dns/rdata.py (Rdata._wire_cmp): We need to specify no
|
||||
compression and an origin to _wire_cmp() in case names in the
|
||||
rdata are relative names.
|
||||
|
||||
* dns/rdtypes/ANY/SIG.py (SIG._cmp): Add missing 'import struct'.
|
||||
Thanks to Arfrever Frehtes Taifersar Arahesis for reporting the
|
||||
problem.
|
||||
|
||||
2011-03-24 Bob Halley <halley@dnspython.org>
|
||||
|
||||
* (Version 1.9.3 released)
|
||||
|
||||
2011-03-22 Bob Halley <halley@dnspython.org>
|
||||
|
||||
* dns/resolver.py: a boolean parameter, 'raise_on_no_answer', has
|
||||
been added to the query() methods. In no-error, no-data
|
||||
situations, this parameter determines whether NoAnswer should be
|
||||
raised or not. If True, NoAnswer is raised. If False, then an
|
||||
Answer() object with a None rrset will be returned.
|
||||
|
||||
* dns/resolver.py: Answer() objects now have a canonical_name field.
|
||||
|
||||
2011-01-11 Bob Halley <halley@dnspython.org>
|
||||
|
||||
* Dnspython was erroneously doing case-insensitive comparisons
|
||||
of the names in NSEC and RRSIG RRs. Thanks to Casey Deccio for
|
||||
reporting this bug.
|
||||
|
||||
2010-12-17 Bob Halley <halley@dnspython.org>
|
||||
|
||||
* dns/message.py (_WireReader._get_section): use "is" and not "=="
|
||||
|
@ -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,
|
||||
|
@ -22,7 +22,47 @@ development by continuing to employ the author :).
|
||||
|
||||
ABOUT THIS RELEASE
|
||||
|
||||
This is dnspython 1.9.2
|
||||
This is dnspython 1.10.0
|
||||
|
||||
New since 1.9.4:
|
||||
|
||||
XXX TBS.
|
||||
|
||||
Bugs fixed since 1.9.4:
|
||||
|
||||
XXX TBS.
|
||||
|
||||
New since 1.9.3:
|
||||
|
||||
Nothing.
|
||||
|
||||
Bugs fixed since 1.9.3:
|
||||
|
||||
The rdata _wire_cmp() routine now handles relative names.
|
||||
|
||||
The SIG RR implementation was missing 'import struct'.
|
||||
|
||||
New since 1.9.2:
|
||||
|
||||
A boolean parameter, 'raise_on_no_answer', has been added to
|
||||
the query() methods. In no-error, no-data situations, this
|
||||
parameter determines whether NoAnswer should be raised or not.
|
||||
If True, NoAnswer is raised. If False, then an Answer()
|
||||
object with a None rrset will be returned.
|
||||
|
||||
Resolver Answer() objects now have a canonical_name field.
|
||||
|
||||
Rdata now have a __hash__ method.
|
||||
|
||||
Bugs fixed since 1.9.2:
|
||||
|
||||
Dnspython was erroneously doing case-insensitive comparisons
|
||||
of the names in NSEC and RRSIG RRs.
|
||||
|
||||
We now use "is" and not "==" when testing what section an RR
|
||||
is in.
|
||||
|
||||
The resolver now disallows metaqueries.
|
||||
|
||||
New since 1.9.1:
|
||||
|
||||
|
@ -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',
|
||||
]
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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>:'
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
"""
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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 = []
|
||||
|
@ -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)
|
||||
|
@ -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
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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))
|
||||
|
@ -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:
|
||||
|
@ -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
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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
|
@ -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):
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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',
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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',
|
||||
]
|
||||
|
@ -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)
|
||||
|
@ -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
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
||||
|
59
lib/dnspython/dns/wiredata.py
Normal file
59
lib/dnspython/dns/wiredata.py
Normal file
@ -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
|
@ -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,
|
||||
|
@ -1,9 +1,13 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import dns.query
|
||||
import dns.resolver
|
||||
import dns.zone
|
||||
|
||||
z = dns.zone.from_xfr(dns.query.xfr('204.152.189.147', 'dnspython.org'))
|
||||
soa_answer = dns.resolver.query('dnspython.org', 'SOA')
|
||||
master_answer = dns.resolver.query(soa_answer[0].mname, 'A')
|
||||
|
||||
z = dns.zone.from_xfr(dns.query.xfr(master_answer[0].address, 'dnspython.org'))
|
||||
names = z.nodes.keys()
|
||||
names.sort()
|
||||
for n in names:
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# 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,
|
||||
@ -18,7 +18,7 @@
|
||||
import sys
|
||||
from distutils.core import setup
|
||||
|
||||
version = '1.9.3'
|
||||
version = '1.10.0'
|
||||
|
||||
kwargs = {
|
||||
'name' : 'dnspython',
|
||||
@ -38,13 +38,9 @@ direct manipulation of DNS zones, messages, names, and records.""",
|
||||
'license' : 'BSD-like',
|
||||
'url' : 'http://www.dnspython.org',
|
||||
'packages' : ['dns', 'dns.rdtypes', 'dns.rdtypes.IN', 'dns.rdtypes.ANY'],
|
||||
}
|
||||
|
||||
if sys.hexversion >= 0x02020300:
|
||||
kwargs['download_url'] = \
|
||||
'http://www.dnspython.org/kits/%s/dnspython-%s.tar.gz' % (version,
|
||||
version)
|
||||
kwargs['classifiers'] = [
|
||||
'download_url' : \
|
||||
'http://www.dnspython.org/kits/%s/dnspython-%s.tar.gz' % (version, version),
|
||||
'classifiers' : [
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Intended Audience :: Developers",
|
||||
"Intended Audience :: System Administrators",
|
||||
@ -54,7 +50,8 @@ if sys.hexversion >= 0x02020300:
|
||||
"Programming Language :: Python",
|
||||
"Topic :: Internet :: Name Service (DNS)",
|
||||
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||
]
|
||||
],
|
||||
}
|
||||
|
||||
if sys.hexversion >= 0x02050000:
|
||||
kwargs['requires'] = []
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -101,16 +101,17 @@ isdn01 ISDN "isdn-address"
|
||||
isdn02 ISDN "isdn-address" "subaddress"
|
||||
isdn03 ISDN "isdn-address"
|
||||
isdn04 ISDN "isdn-address" "subaddress"
|
||||
key01 KEY 512 255 1 (
|
||||
AQMFD5raczCJHViKtLYhWGz8hMY9UGRuniJDBzC7w0aR
|
||||
yzWZriO6i2odGWWQVucZqKVsENW91IOW4vqudngPZsY3
|
||||
GvQ/xVA8/7pyFj6b7Esga60zyGW6LFe9r8n6paHrlG5o
|
||||
jqf0BaqHT+8= )
|
||||
key02 KEY HOST|FLAG4 DNSSEC RSAMD5 (
|
||||
AQMFD5raczCJHViKtLYhWGz8hMY9UGRuniJDBzC7w0aR
|
||||
yzWZriO6i2odGWWQVucZqKVsENW91IOW4vqudngPZsY3
|
||||
GvQ/xVA8/7pyFj6b7Esga60zyGW6LFe9r8n6paHrlG5o
|
||||
jqf0BaqHT+8= )
|
||||
;; dnspython no longer supports old DNSSEC
|
||||
;;key01 KEY 512 255 1 (
|
||||
;; AQMFD5raczCJHViKtLYhWGz8hMY9UGRuniJDBzC7w0aR
|
||||
;; yzWZriO6i2odGWWQVucZqKVsENW91IOW4vqudngPZsY3
|
||||
;; GvQ/xVA8/7pyFj6b7Esga60zyGW6LFe9r8n6paHrlG5o
|
||||
;; jqf0BaqHT+8= )
|
||||
;;key02 KEY HOST|FLAG4 DNSSEC RSAMD5 (
|
||||
;; AQMFD5raczCJHViKtLYhWGz8hMY9UGRuniJDBzC7w0aR
|
||||
;; yzWZriO6i2odGWWQVucZqKVsENW91IOW4vqudngPZsY3
|
||||
;; GvQ/xVA8/7pyFj6b7Esga60zyGW6LFe9r8n6paHrlG5o
|
||||
;; jqf0BaqHT+8= )
|
||||
kx01 KX 10 kdc
|
||||
kx02 KX 10 .
|
||||
loc01 LOC 60 9 0.000 N 24 39 0.000 E 10.00m 20m 2000m 20m
|
||||
@ -137,10 +138,10 @@ nsap-ptr01 NSAP-PTR foo.
|
||||
NSAP-PTR .
|
||||
nsap01 NSAP 0x47000580005a0000000001e133ffffff00016100
|
||||
nsap02 NSAP 0x47.000580005a0000000001e133ffffff000161.00
|
||||
nxt01 NXT a.secure ( NS SOA MX SIG KEY LOC NXT )
|
||||
nxt02 NXT . ( NSAP-PTR NXT )
|
||||
nxt03 NXT . ( A )
|
||||
nxt04 NXT . ( 127 )
|
||||
;;nxt01 NXT a.secure ( NS SOA MX SIG KEY LOC NXT )
|
||||
;;nxt02 NXT . ( NSAP-PTR NXT )
|
||||
;;nxt03 NXT . ( A )
|
||||
;;nxt04 NXT . ( 127 )
|
||||
ptr01 PTR example.
|
||||
px01 PX 65535 foo. bar.
|
||||
px02 PX 65535 . .
|
||||
@ -154,11 +155,11 @@ $ORIGIN s.example.
|
||||
ns A 73.80.65.49
|
||||
$ORIGIN example.
|
||||
$TTL 3600 ; 1 hour
|
||||
sig01 SIG NXT 1 3 3600 (
|
||||
20200101000000 20030101000000 2143 foo
|
||||
MxFcby9k/yvedMfQgKzhH5er0Mu/vILz45IkskceFGgi
|
||||
WCn/GxHhai6VAuHAoNUz4YoU1tVfSCSqQYn6//11U6Nl
|
||||
d80jEeC8aTrO+KKmCaY= )
|
||||
;;sig01 SIG NXT 1 3 3600 (
|
||||
;; 20200101000000 20030101000000 2143 foo
|
||||
;; MxFcby9k/yvedMfQgKzhH5er0Mu/vILz45IkskceFGgi
|
||||
;; WCn/GxHhai6VAuHAoNUz4YoU1tVfSCSqQYn6//11U6Nl
|
||||
;; d80jEeC8aTrO+KKmCaY= )
|
||||
srv01 SRV 0 0 0 .
|
||||
srv02 SRV 65535 65535 65535 old-slow-box.example.com.
|
||||
$TTL 301 ; 5 minutes 1 second
|
||||
@ -202,7 +203,7 @@ dnskey01 DNSKEY 512 255 1 (
|
||||
yzWZriO6i2odGWWQVucZqKVsENW91IOW4vqudngPZsY3
|
||||
GvQ/xVA8/7pyFj6b7Esga60zyGW6LFe9r8n6paHrlG5o
|
||||
jqf0BaqHT+8= )
|
||||
dnskey02 DNSKEY HOST|FLAG4 DNSSEC RSAMD5 (
|
||||
dnskey02 DNSKEY 257 3 RSAMD5 (
|
||||
AQMFD5raczCJHViKtLYhWGz8hMY9UGRuniJDBzC7w0aR
|
||||
yzWZriO6i2odGWWQVucZqKVsENW91IOW4vqudngPZsY3
|
||||
GvQ/xVA8/7pyFj6b7Esga60zyGW6LFe9r8n6paHrlG5o
|
||||
|
@ -27,7 +27,7 @@ dname01 3600 IN DNAME dname-target.
|
||||
dname02 3600 IN DNAME dname-target
|
||||
dname03 3600 IN DNAME .
|
||||
dnskey01 3600 IN DNSKEY 512 255 1 AQMFD5raczCJHViKtLYhWGz8hMY9UGRu niJDBzC7w0aRyzWZriO6i2odGWWQVucZ qKVsENW91IOW4vqudngPZsY3GvQ/xVA8 /7pyFj6b7Esga60zyGW6LFe9r8n6paHr lG5ojqf0BaqHT+8=
|
||||
dnskey02 3600 IN DNSKEY 2560 3 1 AQMFD5raczCJHViKtLYhWGz8hMY9UGRu niJDBzC7w0aRyzWZriO6i2odGWWQVucZ qKVsENW91IOW4vqudngPZsY3GvQ/xVA8 /7pyFj6b7Esga60zyGW6LFe9r8n6paHr lG5ojqf0BaqHT+8=
|
||||
dnskey02 3600 IN DNSKEY 257 3 1 AQMFD5raczCJHViKtLYhWGz8hMY9UGRu niJDBzC7w0aRyzWZriO6i2odGWWQVucZ qKVsENW91IOW4vqudngPZsY3GvQ/xVA8 /7pyFj6b7Esga60zyGW6LFe9r8n6paHr lG5ojqf0BaqHT+8=
|
||||
ds01 3600 IN DS 12345 3 1 123456789abcdef67890123456789abcdef67890
|
||||
e 300 IN MX 10 mail
|
||||
e 300 IN TXT "one"
|
||||
@ -51,8 +51,6 @@ isdn01 3600 IN ISDN "isdn-address"
|
||||
isdn02 3600 IN ISDN "isdn-address" "subaddress"
|
||||
isdn03 3600 IN ISDN "isdn-address"
|
||||
isdn04 3600 IN ISDN "isdn-address" "subaddress"
|
||||
key01 3600 IN KEY 512 255 1 AQMFD5raczCJHViKtLYhWGz8hMY9UGRu niJDBzC7w0aRyzWZriO6i2odGWWQVucZ qKVsENW91IOW4vqudngPZsY3GvQ/xVA8 /7pyFj6b7Esga60zyGW6LFe9r8n6paHr lG5ojqf0BaqHT+8=
|
||||
key02 3600 IN KEY 2560 3 1 AQMFD5raczCJHViKtLYhWGz8hMY9UGRu niJDBzC7w0aRyzWZriO6i2odGWWQVucZ qKVsENW91IOW4vqudngPZsY3GvQ/xVA8 /7pyFj6b7Esga60zyGW6LFe9r8n6paHr lG5ojqf0BaqHT+8=
|
||||
kx01 3600 IN KX 10 kdc
|
||||
kx02 3600 IN KX 10 .
|
||||
loc01 3600 IN LOC 60 9 0.000 N 24 39 0.000 E 10.00m 20.00m 2000.00m 20.00m
|
||||
@ -77,10 +75,6 @@ nsec301 3600 IN NSEC3 1 1 12 aabbccdd 2t7b4g4vsa5smi47k61mv5bv1a22bojr NS SOA MX
|
||||
nsec302 3600 IN NSEC3 1 1 12 - 2t7b4g4vsa5smi47k61mv5bv1a22bojr NS SOA MX RRSIG DNSKEY NSEC3PARAM
|
||||
nsec3param01 3600 IN NSEC3PARAM 1 1 12 aabbccdd
|
||||
nsec3param02 3600 IN NSEC3PARAM 1 1 12 -
|
||||
nxt01 3600 IN NXT a.secure NS SOA MX SIG KEY LOC NXT
|
||||
nxt02 3600 IN NXT . NSAP-PTR NXT
|
||||
nxt03 3600 IN NXT . A
|
||||
nxt04 3600 IN NXT . TYPE127
|
||||
ptr01 3600 IN PTR @
|
||||
px01 3600 IN PX 65535 foo. bar.
|
||||
px02 3600 IN PX 65535 . .
|
||||
@ -91,7 +85,6 @@ rt01 3600 IN RT 0 intermediate-host
|
||||
rt02 3600 IN RT 65535 .
|
||||
s 300 IN NS ns.s
|
||||
ns.s 300 IN A 73.80.65.49
|
||||
sig01 3600 IN SIG NXT 1 3 3600 20200101000000 20030101000000 2143 foo MxFcby9k/yvedMfQgKzhH5er0Mu/vILz 45IkskceFGgiWCn/GxHhai6VAuHAoNUz 4YoU1tVfSCSqQYn6//11U6Nld80jEeC8 aTrO+KKmCaY=
|
||||
spf 3600 IN SPF "v=spf1 mx -all"
|
||||
srv01 3600 IN SRV 0 0 0 .
|
||||
srv02 3600 IN SRV 65535 65535 65535 old-slow-box.example.com.
|
||||
|
@ -27,7 +27,7 @@ dname01.example. 3600 IN DNAME dname-target.
|
||||
dname02.example. 3600 IN DNAME dname-target.example.
|
||||
dname03.example. 3600 IN DNAME .
|
||||
dnskey01.example. 3600 IN DNSKEY 512 255 1 AQMFD5raczCJHViKtLYhWGz8hMY9UGRu niJDBzC7w0aRyzWZriO6i2odGWWQVucZ qKVsENW91IOW4vqudngPZsY3GvQ/xVA8 /7pyFj6b7Esga60zyGW6LFe9r8n6paHr lG5ojqf0BaqHT+8=
|
||||
dnskey02.example. 3600 IN DNSKEY 2560 3 1 AQMFD5raczCJHViKtLYhWGz8hMY9UGRu niJDBzC7w0aRyzWZriO6i2odGWWQVucZ qKVsENW91IOW4vqudngPZsY3GvQ/xVA8 /7pyFj6b7Esga60zyGW6LFe9r8n6paHr lG5ojqf0BaqHT+8=
|
||||
dnskey02.example. 3600 IN DNSKEY 257 3 1 AQMFD5raczCJHViKtLYhWGz8hMY9UGRu niJDBzC7w0aRyzWZriO6i2odGWWQVucZ qKVsENW91IOW4vqudngPZsY3GvQ/xVA8 /7pyFj6b7Esga60zyGW6LFe9r8n6paHr lG5ojqf0BaqHT+8=
|
||||
ds01.example. 3600 IN DS 12345 3 1 123456789abcdef67890123456789abcdef67890
|
||||
e.example. 300 IN MX 10 mail.example.
|
||||
e.example. 300 IN TXT "one"
|
||||
@ -51,8 +51,6 @@ isdn01.example. 3600 IN ISDN "isdn-address"
|
||||
isdn02.example. 3600 IN ISDN "isdn-address" "subaddress"
|
||||
isdn03.example. 3600 IN ISDN "isdn-address"
|
||||
isdn04.example. 3600 IN ISDN "isdn-address" "subaddress"
|
||||
key01.example. 3600 IN KEY 512 255 1 AQMFD5raczCJHViKtLYhWGz8hMY9UGRu niJDBzC7w0aRyzWZriO6i2odGWWQVucZ qKVsENW91IOW4vqudngPZsY3GvQ/xVA8 /7pyFj6b7Esga60zyGW6LFe9r8n6paHr lG5ojqf0BaqHT+8=
|
||||
key02.example. 3600 IN KEY 2560 3 1 AQMFD5raczCJHViKtLYhWGz8hMY9UGRu niJDBzC7w0aRyzWZriO6i2odGWWQVucZ qKVsENW91IOW4vqudngPZsY3GvQ/xVA8 /7pyFj6b7Esga60zyGW6LFe9r8n6paHr lG5ojqf0BaqHT+8=
|
||||
kx01.example. 3600 IN KX 10 kdc.example.
|
||||
kx02.example. 3600 IN KX 10 .
|
||||
loc01.example. 3600 IN LOC 60 9 0.000 N 24 39 0.000 E 10.00m 20.00m 2000.00m 20.00m
|
||||
@ -77,10 +75,6 @@ nsec301.example. 3600 IN NSEC3 1 1 12 aabbccdd 2t7b4g4vsa5smi47k61mv5bv1a22bojr
|
||||
nsec302.example. 3600 IN NSEC3 1 1 12 - 2t7b4g4vsa5smi47k61mv5bv1a22bojr NS SOA MX RRSIG DNSKEY NSEC3PARAM
|
||||
nsec3param01.example. 3600 IN NSEC3PARAM 1 1 12 aabbccdd
|
||||
nsec3param02.example. 3600 IN NSEC3PARAM 1 1 12 -
|
||||
nxt01.example. 3600 IN NXT a.secure.example. NS SOA MX SIG KEY LOC NXT
|
||||
nxt02.example. 3600 IN NXT . NSAP-PTR NXT
|
||||
nxt03.example. 3600 IN NXT . A
|
||||
nxt04.example. 3600 IN NXT . TYPE127
|
||||
ptr01.example. 3600 IN PTR example.
|
||||
px01.example. 3600 IN PX 65535 foo. bar.
|
||||
px02.example. 3600 IN PX 65535 . .
|
||||
@ -91,7 +85,6 @@ rt01.example. 3600 IN RT 0 intermediate-host.example.
|
||||
rt02.example. 3600 IN RT 65535 .
|
||||
s.example. 300 IN NS ns.s.example.
|
||||
ns.s.example. 300 IN A 73.80.65.49
|
||||
sig01.example. 3600 IN SIG NXT 1 3 3600 20200101000000 20030101000000 2143 foo.example. MxFcby9k/yvedMfQgKzhH5er0Mu/vILz 45IkskceFGgiWCn/GxHhai6VAuHAoNUz 4YoU1tVfSCSqQYn6//11U6Nld80jEeC8 aTrO+KKmCaY=
|
||||
spf.example. 3600 IN SPF "v=spf1 mx -all"
|
||||
srv01.example. 3600 IN SRV 0 0 0 .
|
||||
srv02.example. 3600 IN SRV 65535 65535 65535 old-slow-box.example.com.
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
@ -662,12 +662,12 @@ class NameTestCase(unittest.TestCase):
|
||||
def testBadReverseIPv4(self):
|
||||
def bad():
|
||||
n = dns.reversename.from_address('127.0.foo.1')
|
||||
self.failUnlessRaises(socket.error, bad)
|
||||
self.failUnlessRaises(dns.exception.SyntaxError, bad)
|
||||
|
||||
def testBadReverseIPv6(self):
|
||||
def bad():
|
||||
n = dns.reversename.from_address('::1::1')
|
||||
self.failUnlessRaises(socket.error, bad)
|
||||
self.failUnlessRaises(dns.exception.SyntaxError, bad)
|
||||
|
||||
def testForwardIPv4(self):
|
||||
n = dns.name.from_text('1.0.0.127.in-addr.arpa.')
|
||||
|
@ -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,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user