%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/opt/plesk/python/2.7/lib/python2.7/site-packages/dns/
Upload File :
Create Path :
Current File : //proc/self/root/opt/plesk/python/2.7/lib/python2.7/site-packages/dns/renderer.pyc

�
�ac@s�dZddlmZddlZddlZddlZddlZddlZddl	m
Z
dZdZdZ
dZd	efd
��YZdS(s*Help for building DNS wire format messagesi����(tBytesIONi(tlongiiitRenderercBs�eZdZddddd�Zd�Zd�Zejj	d�Z
d�Zd�Zdd	�Z
ejjd
�Zejjd�Zd�Zd
�Zd�ZRS(s�Helper class for building DNS wire-format messages.

    Most applications can use the higher-level L{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)
    ii��cCs�t�|_|dkr0tjdd�|_n	||_||_||_||_i|_	t
|_ddddg|_|jj
d�d|_dS(sInitialize a new renderer.ii��sitNs(RtoutputtNonetrandomtrandinttidtflagstmax_sizetorigintcompresstQUESTIONtsectiontcountstwritetmac(tselfRR	R
R((sA/opt/plesk/python/2.7/lib/python2.7/site-packages/dns/renderer.pyt__init__Ms						cCs~|jj|�|jj�g}x9|jj�D](\}}||kr3|j|�q3q3Wx|D]}|j|=qfWdS(s�Truncate the output buffer at offset *where*, and remove any
        compression table entries that pointed beyond the truncation
        point.
        N(RtseekttruncateRtitemstappend(Rtwheretkeys_to_deletetktv((sA/opt/plesk/python/2.7/lib/python2.7/site-packages/dns/renderer.pyt	_rollback^s

cCs=|j|kr9|j|kr-tjj�n||_ndS(sSet 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.
        N(Rtdnst	exceptiont	FormError(RR((sA/opt/plesk/python/2.7/lib/python2.7/site-packages/dns/renderer.pyt_set_sectionms
cCs�|jt�|jj�}|j|j|j|j�|jjtj	d||��|jj�}||j
kr�|j|�tj
j�n|jtcd7<dS(sAdd a question to the message.s!HHiN(R R
Rttelltto_wireRRRtstructtpackR
RRRtTooBigR(Rtqnametrdtypetrdclasstbeforetafter((sA/opt/plesk/python/2.7/lib/python2.7/site-packages/dns/renderer.pytadd_question|s

cKs�|j|�|jj�}|j|j|j|j|�}|jj�}||jkrw|j|�tj	j
�n|j|c|7<dS(s�Add the rrset to the specified section.

        Any keyword arguments are passed on to the rdataset's to_wire()
        routine.
        N(R RR!R"RRR
RRRR%R(RRtrrsettkwR)tnR*((sA/opt/plesk/python/2.7/lib/python2.7/site-packages/dns/renderer.pyt	add_rrset�s
!
cKs�|j|�|jj�}|j||j|j|j|�}|jj�}||jkrz|j|�tj	j
�n|j|c|7<dS(s�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.
        N(R RR!R"RRR
RRRR%R(RRtnametrdatasetR-R)R.R*((sA/opt/plesk/python/2.7/lib/python2.7/site-packages/dns/renderer.pytadd_rdataset�s
	
c
Cs|td�M}||d>O}|jt�|jj�}|jjtjddtj	j
||d��|d
k	r�|jj�}x�|D]�}tjd|jd�}|jj|�|jj�}	|j
|j�|jj�}
|
|	dks�t�|jj|	d�tjd|
|	�}|jj|�|jjdd�q�W|jj�}||dksrt�|jj|d�tjd||�}|jj|�|jjdd�n|jj�}||jkr�|j|�tjj�n|jtcd	7<d
S(s&Add an EDNS OPT record to the message.I���is!BHHIHis!HHiis!HiN(RR t
ADDITIONALRR!RR#R$Rt	rdatatypetOPTRtotypeR"tAssertionErrorRR
RRR%R(
Rtednst	ednsflagstpayloadtoptionsR)tlstarttopttstufftstarttendtlendR*((sA/opt/plesk/python/2.7/lib/python2.7/site-packages/dns/renderer.pytadd_edns�s<
!


c	Csk|jj�}	tjj|	||ttj��|||||d|�	\}
|_}|j|
|�dS(s$Add a TSIG signature to the message.t	algorithmN(	RtgetvalueRttsigtsigntintttimeRt_write_tsig(RtkeynametsecrettfudgeRt
tsig_errort
other_datatrequest_macRCtst
tsig_rdatatctx((sA/opt/plesk/python/2.7/lib/python2.7/site-packages/dns/renderer.pytadd_tsig�sc
Cs�|jj�}
tjj|
||ttj��|||||d|d|dkdtd|	�	\}|_	}|j
||�|S(syAdd 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.RRtfirsttmultiRCN(RRDRRERFRGRHRtTrueRRI(RRRRJRKRLRRMRNRORCRPRQ((sA/opt/plesk/python/2.7/lib/python2.7/site-packages/dns/renderer.pytadd_multi_tsig�s cCsi|jt�|jj�}|j|j|j|j�|jjtj	dt
jjt
j
jdd��|jj�}|jj|�|jj�}||dks�t�||jkr�|j|�t
jj�n|jj|d�|jjtj	d||��|jtcd7<|jjd�|jjtj	d|jt��|jjdd�dS(Ns!HHIHiiis!Hii
(R R3RR!R"RRRR#R$RR4tTSIGt
rdataclasstANYR7R
RRR%RR(RRQRJR)trdata_startR*((sA/opt/plesk/python/2.7/lib/python2.7/site-packages/dns/renderer.pyRI�s$

 #c
Cst|jjd�|jjtjd|j|j|jd|jd|jd|jd��|jjdd�dS(s�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.
        is!HHHHHHiiiN(RRRR#R$RR	R(R((sA/opt/plesk/python/2.7/lib/python2.7/site-packages/dns/renderer.pytwrite_headers
cCs
|jj�S(sReturn the wire format message.(RRD(R((sA/opt/plesk/python/2.7/lib/python2.7/site-packages/dns/renderer.pytget_wire sN(t__name__t
__module__t__doc__RRRR RRYtINR+R/R2RBREtdefault_algorithmRSRWRIR\R](((sA/opt/plesk/python/2.7/lib/python2.7/site-packages/dns/renderer.pyR$s'		
		$		(R`tioRR#RRHt
dns.exceptionRtdns.tsigt_compatRR
tANSWERt	AUTHORITYR3tobjectR(((sA/opt/plesk/python/2.7/lib/python2.7/site-packages/dns/renderer.pyt<module>s

Zerion Mini Shell 1.0