+2009-03-30 Bob Halley <halley@dnspython.org>
+
+ * Add "one_rr_per_rrset" mode switch to methods which parse
+ messages from wire format (e.g. dns.message.from_wire(),
+ dns.query.udp(), dns.query.tcp()). If set, each RR read is
+ placed in its own RRset (instead of being coalesced).
+
2009-03-30 Bob Halley <halley@dnspython.org>
* Added EDNS option support.
@type current: int
@ivar updating: Is the message a dynamic update?
@type updating: bool
+ @ivar one_rr_per_rrset: Put each RR into its own RRset?
+ @type one_rr_per_rrset: bool
@ivar zone_rdclass: The class of the zone in messages which are
DNS dynamic updates.
@type zone_rdclass: int
"""
- def __init__(self, wire, message, question_only=False):
+ def __init__(self, wire, message, question_only=False,
+ one_rr_per_rrset=False):
self.wire = wire
self.message = message
self.current = 0
self.updating = False
self.zone_rdclass = dns.rdataclass.IN
self.question_only = question_only
+ self.one_rr_per_rrset = one_rr_per_rrset
def _get_question(self, qcount):
"""Read the next I{qcount} records from the wire data and add them to
@param count: the number of records to read
@type count: int"""
- if self.updating:
+ if self.updating or self.one_rr_per_rrset:
force_unique = True
else:
force_unique = False
def from_wire(wire, keyring=None, request_mac='', xfr=False, origin=None,
tsig_ctx = None, multi = False, first = True,
- question_only = False):
+ question_only = False, one_rr_per_rrset = False):
"""Convert a DNS wire format message into a message
object.
@type first: bool
@param question_only: Read only up to the end of the question section?
@type question_only: bool
+ @param one_rr_per_rrset: Put each RR into its own RRset
+ @type one_rr_per_rrset: bool
@raises ShortHeader: The message is less than 12 octets long.
@raises TrailingJunk: There were octets in the message past the end
of the proper DNS message.
m.multi = multi
m.first = first
- reader = _WireReader(wire, m, question_only)
+ reader = _WireReader(wire, m, question_only, one_rr_per_rrset)
reader.read()
return m
_wait_for([], [s], [s], expiration)
def udp(q, where, timeout=None, port=53, af=None, source=None, source_port=0,
- ignore_unexpected=False):
+ ignore_unexpected=False, one_rr_per_rrset=False):
"""Return the response obtained after sending a query via UDP.
@param q: the query
@type source_port: int
@param ignore_unexpected: If True, ignore responses from unexpected
sources. The default is False.
- @type ignore_unexpected: bool"""
+ @type ignore_unexpected: bool
+ @param one_rr_per_rrset: Put each RR into its own RRset
+ @type one_rr_per_rrset: bool
+ """
wire = q.to_wire()
if af is None:
destination)
finally:
s.close()
- r = dns.message.from_wire(wire, keyring=q.keyring, request_mac=q.mac)
+ r = dns.message.from_wire(wire, keyring=q.keyring, request_mac=q.mac,
+ one_rr_per_rrset=one_rr_per_rrset)
if not q.is_response(r):
raise BadResponse
return r
v[0] != errno.EALREADY:
raise ty, v
-def tcp(q, where, timeout=None, port=53, af=None, source=None, source_port=0):
+def tcp(q, where, timeout=None, port=53, af=None, source=None, source_port=0,
+ one_rr_per_rrset=False):
"""Return the response obtained after sending a query via TCP.
@param q: the query
@type source: string
@param source_port: The port from which to send the message.
The default is 0.
- @type source_port: int"""
+ @type source_port: int
+ @param one_rr_per_rrset: Put each RR into its own RRset
+ @type one_rr_per_rrset: bool
+ """
wire = q.to_wire()
if af is None:
wire = _net_read(s, l, expiration)
finally:
s.close()
- r = dns.message.from_wire(wire, keyring=q.keyring, request_mac=q.mac)
+ r = dns.message.from_wire(wire, keyring=q.keyring, request_mac=q.mac,
+ one_rr_per_rrset=one_rr_per_rrset)
if not q.is_response(r):
raise BadResponse
return r