dns ::
renderer ::
Renderer ::
Class Renderer
|
|
Class Renderer
source code
object --+
|
Renderer
Helper class for building DNS wire-format messages.
Most applications can use the higher-level dns.message.Message class and its to_wire() method to
generate wire-format messages. This class is for those applications which
need finer control over the generation of messages.
Typical use:
r = dns.renderer.Renderer(id=1, flags=0x80, max_size=512)
r.add_question(qname, qtype, qclass)
r.add_rrset(dns.renderer.ANSWER, rrset_1)
r.add_rrset(dns.renderer.ANSWER, rrset_2)
r.add_rrset(dns.renderer.AUTHORITY, ns_rrset)
r.add_edns(0, 0, 4096)
r.add_rrset(dns.renderer.ADDTIONAL, ad_rrset_1)
r.add_rrset(dns.renderer.ADDTIONAL, ad_rrset_2)
r.write_header()
r.add_tsig(keyname, secret, 300, 1, 0, '', request_mac)
wire = r.get_wire()
output, a BytesIO, where rendering is written
id: the message id
flags: the message flags
max_size: the maximum size of the message
origin: the origin to use when rendering relative names
compress: the compression table
section: an int, the section currently being rendered
counts: list of the number of RRs in each section
mac: the MAC of the rendered message (if TSIG was used)
|
__init__(self,
id=None,
flags=0,
max_size=65535,
origin=None)
Initialize a new renderer. |
source code
|
|
|
_rollback(self,
where)
Truncate the output buffer at offset *where*, and remove any
compression table entries that pointed beyond the truncation point. |
source code
|
|
|
|
|
add_question(self,
qname,
rdtype,
rdclass=1)
Add a question to the message. |
source code
|
|
|
|
|
add_rdataset(self,
section,
name,
rdataset,
**kw)
Add the rdataset to the specified section, using the specified name
as the owner name. |
source code
|
|
|
add_edns(self,
edns,
ednsflags,
payload,
options=None)
Add an EDNS OPT record to the message. |
source code
|
|
|
add_tsig(self,
keyname,
secret,
fudge,
id,
tsig_error,
other_data,
request_mac,
algorithm=<DNS name HMAC-MD5.SIG-ALG.REG.INT.>)
Add a TSIG signature to the message. |
source code
|
|
|
add_multi_tsig(self,
ctx,
keyname,
secret,
fudge,
id,
tsig_error,
other_data,
request_mac,
algorithm=<DNS name HMAC-MD5.SIG-ALG.REG.INT.>)
Add a TSIG signature to the message. |
source code
|
|
|
|
|
|
|
get_wire(self)
Return the wire format message. |
source code
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|
Inherited from object :
__class__
|
__init__(self,
id=None,
flags=0,
max_size=65535,
origin=None)
(Constructor)
| source code
|
Initialize a new renderer.
- Overrides:
object.__init__
|
Set the renderer's current section.
Sections must be rendered order: QUESTION, ANSWER, AUTHORITY,
ADDITIONAL. Sections may be empty.
Raises dns.exception.FormError if an attempt was made to set a section
value less than the current section.
|
Add the rrset to the specified section.
Any keyword arguments are passed on to the rdataset's to_wire()
routine.
|
add_rdataset(self,
section,
name,
rdataset,
**kw)
| source code
|
Add the rdataset to the specified section, using the specified name as
the owner name.
Any keyword arguments are passed on to the rdataset's to_wire()
routine.
|
add_multi_tsig(self,
ctx,
keyname,
secret,
fudge,
id,
tsig_error,
other_data,
request_mac,
algorithm=<DNS name HMAC-MD5.SIG-ALG.REG.INT.>)
| source code
|
Add a TSIG signature to the message. Unlike add_tsig(), this can be
used for a series of consecutive DNS envelopes, e.g. for a zone transfer
over TCP [RFC2845, 4.4].
For the first message in the sequence, give ctx=None. For each
subsequent message, give the ctx that was returned from the
add_multi_tsig() call for the previous message.
|
Write the DNS message header.
Writing the DNS message header is done after all sections have been
rendered, but before the optional TSIG signature is added.
|