%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/dns/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/dns/__pycache__/renderer.cpython-312.pyc

�

5��e�+���dZddlZddlZddlZddlZddlZddlZddlZdZ	dZ
dZdZejd��ZGd�d�Zy)	z*Help for building DNS wire format messages�N���c#�K�|jd|z�|j�}d��|j�}||z
}|dkDrJ	|j||z
�	|j|j|d��	|j|�yy#t$rt
jj�wxYw#|j|�wxYw�w)N�r�big)�write�tell�seek�to_bytes�
OverflowError�dns�	exception�	FormError)�output�
length_length�start�end�lengths     �./usr/lib/python3/dist-packages/dns/renderer.py�prefixed_lengthr#s�����
�L�L��-�'�(��K�K�M�E�	�
�+�+�-�C�
�5�[�F�
��z�	��K�K��
�-�.�
.����V�_�_�]�E�B�C�
�K�K�����
!�
.��m�m�-�-�-�
.��
�K�K���s0�AC
�B7�!B�=C
�$B4�4B7�7C
�
C
c�H�eZdZdZdd�Zd�Zd�Zejd��Z	ejd��Z
ejjfd�Zd	�Zd
�Zdd�Zdd�Zej&j(fd
�Zej&j(fd�Zd�Zd�Zd�Zdeddfd�Zdd�Zy)�Renderera�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_rrset(dns.renderer.ADDITIONAL, ad_rrset_1)
        r.add_rrset(dns.renderer.ADDITIONAL, ad_rrset_2)
        r.add_edns(0, 0, 4096)
        r.write_header()
        r.add_tsig(keyname, secret, 300, 1, 0, '', request_mac)
        wire = r.get_wire()

    If padding is going to be used, then the OPT record MUST be
    written after everything else in the additional section except for
    the TSIG (if any).

    output, an io.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)
    Nc�@�tj�|_|�tjdd�|_n||_||_||_||_i|_	t|_gd�|_|jjd�d|_d|_d|_y)zInitialize a new renderer.Nr�)rrrrs�F)�io�BytesIOr�random�randint�id�flags�max_size�origin�compress�QUESTION�section�countsr	�mac�reserved�
was_padded)�selfr!r"r#r$s     r�__init__zRenderer.__init__bs����j�j�l���
�:��n�n�Q��.�D�G��D�G���
� ��
������
����"��������,�'������
����c��|jj|�|jj�g}|jj	�D]\}}||k\s�|j|��|D]}|j|=�y)z�Truncate the output buffer at offset *where*, and remove any
        compression table entries that pointed beyond the truncation
        point.
        N)rr�truncater%�items�append)r,�where�keys_to_delete�k�vs     r�	_rollbackzRenderer._rollbackus}��	
����������������M�M�'�'�)�	)�D�A�q��E�z��%�%�a�(�	)� �	!�A��
�
�a� �	!r.c��|j|k7r1|j|kDrtjj�||_yy)aSet 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)r'rrr)r,r's  r�_set_sectionzRenderer._set_section�s8���<�<�7�"��|�|�g�%��m�m�-�-�-�"�D�L�#r.c#��K�|jj�}|��|jj�|jkDr+|j|�tj
j�y�w�N)rr
r#r7rr�TooBig)r,rs  r�_track_sizezRenderer._track_size�sW������� � �"�����;�;�����
�
�-��N�N�5�!��-�-�&�&�&�.�s�A2A4c#�K�|jj�}	|jj|�d��|jj|�y#|jj|�wxYw�wr;)rr
r)r,r3�currents   r�_temporarily_seek_tozRenderer._temporarily_seek_to�sV�����+�+�"�"�$��	&��K�K���U�#���K�K���W�%��D�K�K���W�%�s�A9�A�A9�A6�6A9c�p�|jt�|j�5|j|j|j
|j�|jjtjd||��ddd�|jtxxdz
cc<y#1swY�%xYw)zAdd a question to the message.z!HHNr)r9r&r=�to_wirerr%r$r	�struct�packr()r,�qname�rdtype�rdclasss    r�add_questionzRenderer.add_question�s���	
���(�#�
�
�
�
�	C��M�M�$�+�+�t�}�}�d�k�k�B��K�K���f�k�k�%���A�B�	C�	
���H���"��	C�	C�s�A"B,�,B5c��|j|�|j�5|j|j|j|j
fi|��}ddd�|j|xxz
cc<y#1swY�!xYw)z�Add the rrset to the specified section.

        Any keyword arguments are passed on to the rdataset's to_wire()
        routine.
        N�r9r=rBrr%r$r()r,r'�rrset�kw�ns     r�	add_rrsetzRenderer.add_rrset�sp��	
���'�"�
�
�
�
�	M���
�
�d�k�k�4�=�=�$�+�+�L��L�A�	M����G���!��	M�	M�s�4A6�6A?c��|j|�|j�5|j||j|j|j
fi|��}ddd�|j|xxz
cc<y#1swY�!xYw)z�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.
        NrJ)r,r'�name�rdatasetrLrMs      r�add_rdatasetzRenderer.add_rdataset�su��	
���'�"�
�
�
�
�	V� �� � ��t�{�{�D�M�M�4�;�;�U�RT�U�A�	V����G���!��	V�	V�s�5A7�7Bc��|r�|j}|dk\sJ�|d}|jj�|z|z}||z}|r	d||z
z}nd}t|j�}	|	jtjjtjjj|��tjjj||j|	�}d|_|j!t"|�y)aMAdd *opt* to the additional section, applying padding if desired.  The
        padding will take the specified precomputed OPT size and TSIG size into
        account.

        Note that we don't have reliable way of knowing how big a GSS-TSIG digest
        might be, so we we might not get an even multiple of the pad in that case.�rrr.TN)�ttlrr
�list�optionsr2r�edns�
GenericOption�
OptionType�PADDING�message�Message�	_make_optrGr+rN�
ADDITIONAL)
r,�opt�pad�opt_size�	tsig_sizerU�	opt_rdata�size_without_padding�	remainderrWs
          r�add_optzRenderer.add_opt�s�����'�'�C��r�>�!�>��A��I�#'�;�;�#3�#3�#5��#@�9�#L� �,�s�2�I����y��1�����9�,�,�-�G��N�N�3�8�8�1�1�#�(�(�2E�2E�2M�2M�s�S�T��+�+�%�%�/�/��Y�5F�5F��P�C�"�D�O����z�3�'r.c��|dz}||dzz}tjjj|||�}|j	|�y)z&Add an EDNS OPT record to the message.l�~�N)rr\r]r^rg)r,rX�	ednsflags�payloadrWr`s      r�add_ednszRenderer.add_edns�sF��	�Z��	��T�R�Z��	��k�k�!�!�+�+�I�w��H�����S�r.c	
���|jj�}	t|tjj
�r|}
n!tjj|||�}
tjjj||d|d|||�}tjj|	|
|dttj��|�\}}|j||�y)z$Add a TSIG signature to the message.rr.N�
r�getvalue�
isinstancer�tsig�Keyr\r]�
_make_tsig�sign�int�time�_write_tsig)
r,�keyname�secret�fudger!�
tsig_error�
other_data�request_mac�	algorithm�s�keyrq�_s
             r�add_tsigzRenderer.add_tsig�s���
�K�K� � �"���f�c�h�h�l�l�+��C��(�(�,�,�w��	�:�C��{�{�"�"�-�-��Y��5�#�r�:�z�
���H�H�M�M�!�S�$�q�'�3�t�y�y�{�3C�[�Q�	��q�����w�'r.c

���|jj�}
t|tjj
�r|}n!tjj|||	�}tjjj||	d|d|||�}tjj|
||dttj��||d�\}}|j||�|S)ayAdd 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.rr.Trn)
r,�ctxrxryrzr!r{r|r}r~rr�rqs
             r�add_multi_tsigzRenderer.add_multi_tsig�s���(
�K�K� � �"���f�c�h�h�l�l�+��C��(�(�,�,�w��	�:�C��{�{�"�"�-�-��Y��5�#�r�:�z�
���h�h�m�m�
�s�D��G�S�����-�{�C��
���s�	
����w�'��
r.c	�L�|jrd}n|j}|jt�|j	�5|j|j||j�|jjtjdtjjtjjd��t!|jd�5|j|j�ddd�ddd�|j"txxdz
cc<|j%d�5|jjtjd|j"t��ddd�y#1swY��xYw#1swY��xYw#1swYyxYw)Nz!HHIrrr�
z!H)r+r%r9r_r=rBrr$r	rCrDr�	rdatatype�TSIG�
rdataclass�ANYrr(r@)r,rqrxr%s    rrwzRenderer._write_tsig"s4���?�?��H��}�}�H����*�%�
�
�
�
�	*��O�O�D�K�K��4�;�;�?��K�K������F�C�M�M�$6�$6����8J�8J�A�N�
�!����a�0�
*����T�[�[�)�
*�	*�	
���J��1�$��
�
&�
&�r�
*�	J��K�K���f�k�k�$����J�0G�H�I�	J�	J�	
*�
*��	*�	*��	J�	J�s2�BF� F�<F�8AF�F	�F�F�F#c
�H�|jd�5|jjtjd|j
|j|jd|jd|jd|jd��ddd�y#1swYyxYw)z�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.
        rz!HHHHHHrrrN)r@rr	rCrDr!r"r(�r,s r�write_headerzRenderer.write_header4s����
&�
&�q�
)�	��K�K��������G�G��J�J��K�K��N��K�K��N��K�K��N��K�K��N��

�	�	�	�s�A=B�B!c�6�|jj�S)zReturn the wire format message.)rror�s r�get_wirezRenderer.get_wireIs���{�{�#�#�%�%r.�size�returnc��|dkrtd��||jkDrtd��|xj|z
c_|xj|zc_y)zReserve *size* bytes.rz$reserved amount must be non-negativez)cannot reserve more than the maximum sizeN)�
ValueErrorr#r*)r,r�s  r�reservezRenderer.reserveNsI���!�8��C�D�D��$�-�-���H�I�I��
�
���
��
�
���
r.c�P�|xj|jz
c_d|_y)zRelease the reserved bytes.rN)r#r*r�s r�release_reservedzRenderer.release_reservedWs���
�
����&�
���
r.)NrrN)rrrr;)r�N)�__name__�
__module__�__qualname__�__doc__r-r7r9�
contextlib�contextmanagerr=r@rr��INrHrNrRrgrlrq�default_algorithmr�r�rwr�r�rur�r��r.rrr5s���*�X �&
!�
#����'��'����&��&�36�.�.�2C�2C�#�
"�"�(�.�$�(�(�,�,�(�F�(�(�,�,�!�FJ�$�*&�
�C��D��r.r)r�r�rrrCrv�
dns.exceptionr�dns.tsigr&�ANSWER�	AUTHORITYr_r�rrr�r.r�<module>r�sY��$1��	�
�
������	
��
�	�
�
�������"e�er.

Zerion Mini Shell 1.0