%PDF- %PDF-
Mini Shell

Mini Shell

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

�

5��e�;�
��UdZddlZddlZddlZddlZddlmZmZmZm	Z	ddl
ZddlZddl
ZddlZGd�dejj �ZGd�d�ZGd�d	e�ZGd
�de�ZGd�d
ejj �ZGd�de�ZGd�de�Zej0eej2eej4eiZeeefed<dedefd�Zde	eefdddefd�Zde	eefde de!de!def
d�Z"dededdfd�Z#ej4ZejHZ$ejJZ%ejLZ&ej0ZejNZ'ejPZ(ejRZ)ejTZ*ejVZ+ej2Zy)zEDNS Options�N)�Any�Dict�Optional�Unionc�H�eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
ed��Zy
)�
OptionType������	�
���
�c��y�Ni�����clss �*/usr/lib/python3/dist-packages/dns/edns.py�_maximumzOptionType._maximum8����N)�__name__�
__module__�__qualname__�NSID�DAU�DHU�N3U�ECS�EXPIRE�COOKIE�	KEEPALIVE�PADDING�CHAIN�EDE�classmethodrrrrrr sK���D�
�C�
�C�
�C�
�C�
�F�
�F��I��G��E�
�C����rrc��eZdZdZdeeeffd�Zddee	dee
fd�Zdefd�Ze
ded	d
ddfd��Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�Optionz%Base class for all EDNS option types.�otypec�8�tj|�|_y)z_Initialize an option.

        *otype*, a ``dns.edns.OptionType``, is the option type.
        N)r�maker.)�selfr.s  r�__init__zOption.__init__@s��
 �_�_�U�+��
rN�file�returnc��t�)zUConvert an option to wire format.

        Returns a ``bytes`` or ``None``.

        ��NotImplementedError�r1r3s  r�to_wirezOption.to_wireGs
��"�!rc��t��Nr6�r1s r�to_textzOption.to_textOs��!�!r�parser�dns.wire.Parserc��t�)aBuild an EDNS option object from wire format.

        *otype*, a ``dns.edns.OptionType``, is the option type.

        *parser*, a ``dns.wire.Parser``, the parser, which should be
        restructed to the option length.

        Returns a ``dns.edns.Option``.
        r6�rr.r>s   r�from_wire_parserzOption.from_wire_parserRs
��"�!rc�\�|j�}|j�}||k(ry||kDryy)z�Compare an EDNS option with another option of the same type.

        Returns < 0 if < *other*, 0 if == *other*, and > 0 if > *other*.
        r����)r9)r1�other�wire�owires    r�_cmpzOption._cmp_s1��
�|�|�~���
�
����5�=���%�<��rc��t|t�sy|j|jk7ry|j|�dk(S)NFr��
isinstancer-r.rI�r1rFs  r�__eq__z
Option.__eq__ls6���%��(���:�:����$���y�y���1�$�$rc��t|t�sy|j|jk7ry|j|�dk7S)NTrrKrMs  r�__ne__z
Option.__ne__ss6���%��(���:�:����$���y�y���1�$�$rc��t|t�r|j|jk7rtS|j	|�dkS�Nr�rLr-r.�NotImplementedrIrMs  r�__lt__z
Option.__lt__z�5���%��(�D�J�J�%�+�+�,E�!�!��y�y���!�#�#rc��t|t�r|j|jk7rtS|j	|�dkSrRrSrMs  r�__le__z
Option.__le__�5���%��(�D�J�J�%�+�+�,E�!�!��y�y���1�$�$rc��t|t�r|j|jk7rtS|j	|�dk\SrRrSrMs  r�__ge__z
Option.__ge__�rYrc��t|t�r|j|jk7rtS|j	|�dkDSrRrSrMs  r�__gt__z
Option.__gt__�rVrc�"�|j�Sr;)r=r<s r�__str__zOption.__str__�s���|�|�~�rr;)rrr�__doc__rr�strr2rr�bytesr9r=r+rBrIrNrPrUrXr[r]r_rrrr-r-=s���/�,�e�J��O�4�,�"�H�S�M�"�X�e�_�"�"��"��
"�Z�
"�9J�
"�x�
"��
"��%�%�$�
%�
%�
$�
rr-c���eZdZdZdeeefdeeeff�fd�Zdde	e
de	efd�Zdefd�Ze
deeefd	d
defd��Z�xZS)
�
GenericOptionzwGeneric Option Class

    This class is used for EDNS option types for which we have no better
    implementation.
    r.�datac���t�|�|�tjjj|d�|_y)NT)�superr2�dns�rdata�Rdata�	_as_bytesre)r1r.re�	__class__s   �rr2zGenericOption.__init__�s,���
������I�I�O�O�-�-�d�D�9��	rr3r4c�V�|r|j|j�y|jSr;)�writerer8s  rr9zGenericOption.to_wire��"����J�J�t�y�y�!���9�9�rc� �d|jzS)Nz
Generic %d)r.r<s rr=zGenericOption.to_text�s���d�j�j�(�(rr>r?c�0�|||j��Sr;��
get_remainingrAs   rrBzGenericOption.from_wire_parser�s���5�&�.�.�0�1�1rr;)rrrr`rrrarbr2rrr9r=r+r-rB�
__classcell__�rls@rrdrd�s�����:�e�J��O�4�:�E�%��*�<M�:��H�S�M��X�e�_��)��)��2��*�c�/�*�2�4E�2�	�2��2rrdc���eZdZdZddedeedef�fd�
Zdefd�Ze	dede
fd	��Zdd
eedee
fd�Zedeeefd
dde
fd��Z�xZS)�	ECSOptionz!EDNS Client Subnet (ECS, RFC7871)�address�srclen�scopelenc���t�	|�tj�tj
j
|�}|tjk(r�d|_	|�d}tjjj|�}tjjj|dd�}tjjj|dd�}n�|tjk(r�d|_	|�d}tjjj|�}tjjj|dd�}tjjj|dd�}nt!d	��|�J�||_||_||_tj
j)||�}t+t-j.|d
z��}|d||_|dz}|dk7rMt3j4dt7|j0d
d�dd|z
zz�}|j0dd
|z|_yy)a�*address*, a ``str``, is the client address information.

        *srclen*, an ``int``, the source prefix length, which is the
        leftmost number of bits of the address to be used for the
        lookup.  The default is 24 for IPv4 and 56 for IPv6.

        *scopelen*, an ``int``, the scope prefix length.  This value
        must be 0 in queries, and should be set in responses.
        �N�8r�rD�� zBad address family� @r
�BrE�)rgr2rr$rh�inet�af_for_address�socket�AF_INET6�familyrirj�_as_ipv6_address�_as_int�AF_INET�_as_ipv4_address�
ValueErrorrxryrz�	inet_pton�int�math�ceil�addrdata�struct�pack�ord)
r1rxryrz�afr��nbytes�nbits�lastrls
         �rr2zECSOption.__init__�s����	������(�
�X�X�
$�
$�W�
-��
���� ��D�K��~����i�i�o�o�6�6�w�?�G��Y�Y�_�_�,�,�V�Q��<�F��y�y���.�.�x��C�@�H�
�6�>�>�
!��D�K��~����i�i�o�o�6�6�w�?�G��Y�Y�_�_�,�,�V�Q��;�F��y�y���.�.�x��B�?�H��1�2�2��!�!�!������� ��
��8�8�%�%�b�'�2���T�Y�Y�v��|�,�-��!��&�)��
���
���A�:��;�;�s�C��
�
�b�c�(:�$;�t��E�	�?R�$S�T�D� �M�M�#�2�.��5�D�M�rr4c�d�dj|j|j|j�S)NzECS {}/{} scope/{})�formatrxryrzr<s rr=zECSOption.to_text�s#��#�*�*�4�<�<����d�m�m�T�Tr�textc��d}|j�}d}t|�dk(r|d}nPt|�dk(r(|d|k7rtdj|���|d}ntdj|���|j	d�}|dk(r|jd�\}}d}n5|dk(r|jd�\}}}ntdj|���	t|�}	t|�}	t
||	|�S#t$rtd	d
j|�z��wxYw#t$rtddj|�z��wxYw)
a�Convert a string into a `dns.edns.ECSOption`

        *text*, a `str`, the text form of the option.

        Returns a `dns.edns.ECSOption`.

        Examples:

        >>> import dns.edns
        >>>
        >>> # basic example
        >>> dns.edns.ECSOption.from_text('1.2.3.4/24')
        >>>
        >>> # also understands scope
        >>> dns.edns.ECSOption.from_text('1.2.3.4/24/32')
        >>>
        >>> # IPv6
        >>> dns.edns.ECSOption.from_text('2001:4b98::1/64/64')
        >>>
        >>> # it understands results from `dns.edns.ECSOption.to_text()`
        >>> dns.edns.ECSOption.from_text('ECS 1.2.3.4/24/32')
        r$NrDrr|zcould not parse ECS from "{}"�/�0zinvalid scope z"{}": scope must be an integerzinvalid srclen z"{}": srclen must be an integer)�split�lenr�r��countr�rw)
r��optional_prefix�tokens�ecs_text�	n_slashesrx�tsrclen�tscope�scoperys
          r�	from_textzECSOption.from_text�sm��0 ����������v�;�!���a�y�H�
��[�A�
��a�y�O�+� �!@�!G�!G��!M�N�N��a�y�H��<�C�C�D�I�J�J��N�N�3�'�	���>�'�~�~�c�2��G�W��F�
�!�^�'/�~�~�c�':�$�G�W�f��<�C�C�D�I�J�J�	���K�E�
	���\�F�
��&�%�0�0���	�� �#C�#J�#J�6�#R�R��
�	���	��!�$E�$L�$L�W�$U�U��
�	�s�D�(D*�'D'�*'Er3c��tjd|j|j|j�|j
z}|r|j
|�y|S)N�!HBB)r�r�r�ryrzr�rn�r1r3�values   rr9zECSOption.to_wiresG���K�K�����T�[�[�$�-�-�H�4�=�=�X�	���J�J�u����Lrr.r>r?c�z�|jd�\}}}ttj|dz��}|j	|�}|dk(r+d|z
}t
jj|d|zz�}	n;|dk(r+d|z
}t
jj|d|zz�}	ntd��||	||�S)	Nr�r�rD��r|�zunsupported family)
�
get_structr�r�r��	get_bytesrh�ipv4�	inet_ntoa�ipv6r�)
rr.r>r��srcr��addrlen�prefix�pad�addrs
          rrBzECSOption.from_wire_parser&s���$�.�.�v�6����U��d�i�i��c�	�*�+���!�!�'�*���Q�;��g�+�C��8�8�%�%�f�w��}�&<�=�D�
�q�[��w�,�C��8�8�%�%�f�w��}�&<�=�D��1�2�2��4��e�$�$rrRr;)rrrr`rarr�r2r=�staticmethodr-r�rrbr9r+rrrBrtrus@rrwrw�s����+�-6��-6�X�c�]�-6�S�-6�^U��U��61��61��61��61�p�H�S�M��X�e�_���%��*�c�/�*�%�4E�%�	�%��%rrwc��eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZdZdZdZed��Zy)�EDECoderrDr|r	r�r
rrr
rrrrr�rr��������rc��yrrrs rrzEDECode._maximumTrrN)rrr�OTHER�UNSUPPORTED_DNSKEY_ALGORITHM�UNSUPPORTED_DS_DIGEST_TYPE�STALE_ANSWER�
FORGED_ANSWER�DNSSEC_INDETERMINATE�DNSSEC_BOGUS�SIGNATURE_EXPIRED�SIGNATURE_NOT_YET_VALID�DNSKEY_MISSING�RRSIGS_MISSING�NO_ZONE_KEY_BIT_SET�NSEC_MISSING�CACHED_ERROR�	NOT_READY�BLOCKED�CENSORED�FILTERED�
PROHIBITED�STALE_NXDOMAIN_ANSWER�NOT_AUTHORITATIVE�
NOT_SUPPORTED�NO_REACHABLE_AUTHORITY�
NETWORK_ERROR�INVALID_DATAr+rrrrr�r�9s���
�E�#$� �!"���L��M����L������N��N����L��L��I��G��H��H��J������M����M��L����rr�c���eZdZdZhd�Zddeeefdeef�fd�
Z	defd�Z
ddeedeefd	�Z
ed
eeefdddefd
��Z�xZS)�	EDEOptionz!Extended DNS Error (EDE, RFC8914)>�DS�NSEC�DNSKEY�DNSSEC�RRSIGs�NXDOMAIN�coder�c���t�|�tj�tj|�|_|�t|t�std��||_
y)z�*code*, a ``dns.edns.EDECode`` or ``str``, the info code of the
        extended error.

        *text*, a ``str`` or ``None``, specifying additional information about
        the error.
        Nztext must be string or None)rgr2rr*r�r0r�rLrar�r�)r1r�r�rls   �rr2zEDEOption.__init__^sH���	������(��L�L��&��	���J�t�S�$9��:�;�;���	rr4c�(��d�j��}�jtvrQtj�j�}dj�fd�|j	d�D��}|d|�d�z
}�j
�|d�j
��z
}|S)NzEDE � c3�^�K�|]$}|�jvr|n|j����&y�wr;)�_preserve_case�title)�.0�wordr1s  �r�	<genexpr>z$EDEOption.to_text.<locals>.<genexpr>qs1��������� 3� 3�3������E��s�*-�_z (�)z: )r�r�r=�joinr�r�)r1�output�descs`  rr=zEDEOption.to_textms������	�	�{�#���9�9����?�?�4�9�9�-�D��8�8�� �J�J�s�O���D�
��4�&��l�"�F��9�9� ���4�9�9�+�&�&�F��
rr3c���tjd|j�}|j�||jj	d�z
}|r|j|�y|S)Nz!H�utf8)r�r�r�r��encodernr�s   rr9zEDEOption.to_wirezsP�����D�$�)�)�,���9�9� ��T�Y�Y�%�%�f�-�-�E���J�J�u����Lrr.r>r?c��tj|j��}|j�}|r|ddk(r|dd}|j	d�}nd}|||�S)NrErr�)r�r0�
get_uint16rs�decode)rr.r>r�r��btexts      rrBzEDEOption.from_wire_parser�sb���|�|�F�-�-�/�0���#�#�%����B�x�1�}��C�R�y���K�K��'�E��E��4���rr;)rrrr`r�rr�rarr2r=rrbr9r+rr-rBrtrus@rr�r�Ys����+�M�N�
�U�7�C�<�0�
���
�
����	�H�S�M�	�X�e�_�	��
 ��*�c�/�*�
 �4E�
 �	�
 ��
 rr�c���eZdZdef�fd�Zd
dedeefd�Zdefd�Z	e
deeefde
jjdefd	��Z�xZS)�
NSIDOption�nsidc�N��t�|�tj�||_yr;)rgr2rr r)r1rrls  �rr2zNSIDOption.__init__�s���
������)���	rr3r4c�V�|r|j|j�y|jSr;)rnrr8s  rr9zNSIDOption.to_wire�rorc���td�|jD��r|jj�}n-tj|j�j�}d|��S)Nc3�4K�|]}|dk\xr|dk���y�w)r��~Nr)r��cs  rr�z%NSIDOption.to_text.<locals>.<genexpr>�s ����:�1�q�D�y�&�Q�$�Y�&�:�s�zNSID )�allrr��binascii�hexlify)r1r�s  rr=zNSIDOption.to_text�sO���:��	�	�:�:��I�I�$�$�&�E��$�$�T�Y�Y�/�6�6�8�E��u�g��rr.r>c�.�||j��Sr;rrrAs   rrBzNSIDOption.from_wire_parser�s���6�'�'�)�*�*rr;)rrrrbr2rrr9rar=r+rrrhrG�Parserr-rBrtrus@rrr�so����U���C��8�E�?������+��*�c�/�*�+�47�H�H�O�O�+�	�+��+rr�_type_to_classr.r4c�@�tj|�}|�t}|S)z�Return the class for the specified option type.

    The GenericOption class is used if a more specific class is not
    known.
    )r�getrd)r.rs  r�get_option_classr�s#���
�
�U�
#�C�
�{����Jrr>r?c�f�tj|�}t|�}|j||�S)aBuild an EDNS option object from wire format.

    *otype*, an ``int``, is the option type.

    *parser*, a ``dns.wire.Parser``, the parser, which should be
    restricted to the option length.

    Returns an instance of a subclass of ``dns.edns.Option``.
    )rr0rrB)r.r>rs   r�option_from_wire_parserr�s/��
�O�O�E�"�E�
�5�
!�C�����v�.�.rrG�current�olenc��tjj||�}|j|�5t	||�cddd�S#1swYyxYw)arBuild an EDNS option object from wire format.

    *otype*, an ``int``, is the option type.

    *wire*, a ``bytes``, is the wire-format message.

    *current*, an ``int``, is the offset in *wire* of the beginning
    of the rdata.

    *olen*, an ``int``, is the length of the wire-format option data

    Returns an instance of a subclass of ``dns.edns.Option``.
    N)rhrGr
�restrict_tor)r.rGrrr>s     r�option_from_wirer�sE�� �X�X�_�_�T�7�
+�F�	�	�	�D�	!�6�&�u�f�5�6�6�6�s�A�A�implementationc��|t|<y)z�Register the implementation of an option type.

    *implementation*, a ``class``, is a subclass of ``dns.edns.Option``.

    *otype*, an ``int``, is the option type.
    N)r)rr.s  r�
register_typer�s��+�N�5�r),r`r
r�r�r��typingrrrr�dns.enumrh�dns.inet�	dns.rdata�dns.wire�enum�IntEnumrr-rdrwr�r�rr$r*r r�__annotations__rrarrbr�rrr!r"r#r%r&r'r(r)rrr�<module>r$s���$���
�
�-�-���������!�!��:R�R�j2�F�2�8H%��H%�V�c�h�h����@: ��: �z+��+�8�N�N�I��N�N�I��O�O�Z�)���Z��_�%��
�J�
�3�
�/���S��!�/�+<�/��/�"6���S��!�6�).�6�9<�6�DG�6��6�*+�#�+�j�+�T�+������n�n���n�n���n�n���n�n��	�	�	��	�	�	��� � �	�
�
�
�������n�n�r

Zerion Mini Shell 1.0