%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/names/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/names/__pycache__/root.cpython-312.pyc

�

Ϫ�f�0���dZddlmZddlmZmZmZddlmZGd�d�Z	Gd�dej�Zd	�ZGd
�d�Z
dd
�Zy)z�
Resolver implementation for querying successive authoritative servers to
lookup a record, starting from the root nameservers.

@author: Jp Calderone

todo::
    robustify it
    documentation
�)�defer)�common�dns�error)�Failurec��eZdZdZd�Zy)�_DummyControllerz�
    A do-nothing DNS controller.  This is useful when all messages received
    will be responses to previously issued queries.  Anything else received
    will be ignored.
    c��y�N�)�self�argss  �4/usr/lib/python3/dist-packages/twisted/names/root.py�messageReceivedz _DummyController.messageReceiveds���N)�__name__�
__module__�__qualname__�__doc__rrrrr	r	s���
rr	c�6�eZdZdZd	d�Zd�Zd�Zd�Zd�Zd�Z	y)
�Resolverao
    L{Resolver} implements recursive lookup starting from a specified list of
    root servers.

    @ivar hints: See C{hints} parameter of L{__init__}
    @ivar _maximumQueries: See C{maximumQueries} parameter of L{__init__}
    @ivar _reactor: See C{reactor} parameter of L{__init__}
    @ivar _resolverFactory: See C{resolverFactory} parameter of L{__init__}
    Nc��tjj|�||_||_||_|�ddlm}||_y)a�
        @param hints: A L{list} of L{str} giving the dotted quad
            representation of IP addresses of root servers at which to
            begin resolving names.
        @type hints: L{list} of L{str}

        @param maximumQueries: An optional L{int} giving the maximum
             number of queries which will be attempted to resolve a
             single name.
        @type maximumQueries: L{int}

        @param reactor: An optional L{IReactorTime} and L{IReactorUDP}
             provider to use to bind UDP ports and manage timeouts.
        @type reactor: L{IReactorTime} and L{IReactorUDP} provider

        @param resolverFactory: An optional callable which accepts C{reactor}
             and C{servers} arguments and returns an instance that provides a
             C{queryUDP} method. Defaults to L{twisted.names.client.Resolver}.
        @type resolverFactory: callable
        Nr�r)	r�ResolverBase�__init__�hints�_maximumQueries�_reactor�twisted.names.clientr�_resolverFactory)r
r�maximumQueries�reactor�resolverFactorys     rrzResolver.__init__+s?��*	���$�$�T�*���
�-�����
��"�H� /��rc�`�|jD�cgc]}|tjf��c}Scc}w)z�
        Return a list of two-tuples representing the addresses of the root
        servers, as defined by C{self.hints}.
        )rr�PORT)r
�ips  r�_rootszResolver._rootsHs$��
*.���4�2��S�X�X��4�4��4s�+c��|j||j��}|j|g|�}|r|j|j�|S)a�
        Issue one query and return a L{Deferred} which fires with its response.

        @param query: The query to issue.
        @type query: L{dns.Query}

        @param servers: The servers which might have an answer for this
            query.
        @type servers: L{list} of L{tuple} of L{str} and L{int}

        @param timeout: A timeout on how long to wait for the response.
        @type timeout: L{tuple} of L{int}

        @param filter: A flag indicating whether to filter the results.  If
            C{True}, the returned L{Deferred} will fire with a three-tuple of
            lists of L{twisted.names.dns.RRHeader} (like the return value of
            the I{lookup*} methods of L{IResolver}.  IF C{False}, the result
            will be a L{Message} instance.
        @type filter: L{bool}

        @return: A L{Deferred} which fires with the response or a timeout
            error.
        @rtype: L{Deferred}
        )�serversr")r r�queryUDP�addCallback�
filterAnswers)r
�queryr)�timeout�filter�r�ds       r�_queryzResolver._queryOsG��2
�!�!�'�4�=�=�!�I��
�J�J��w��(���
�M�M�!�/�/�*��rc��|�d}|jtj|||�|j�||j�S)z�
        Implement name lookup by recursively discovering the authoritative
        server for the name and then asking it, starting at one of the servers
        in C{self.hints}.
        )����-)�_discoverAuthorityr�Queryr'r)r
�name�cls�typer.s     r�_lookupzResolver._lookupnsE���?�%�G��&�&��I�I�d�D�#�&����
�w��@T�@T�
�	
rc��|dkrttjd��S|j|||d�}|j	|j
|||dz
�|S)a#
        Issue a query to a server and follow a delegation if necessary.

        @param query: The query to issue.
        @type query: L{dns.Query}

        @param servers: The servers which might have an answer for this
            query.
        @type servers: L{list} of L{tuple} of L{str} and L{int}

        @param timeout: A C{tuple} of C{int} giving the timeout to use for this
            query.

        @param queriesLeft: A C{int} giving the number of queries which may
            yet be attempted to answer this query before the attempt will be
            abandoned.

        @return: A L{Deferred} which fires with a three-tuple of lists of
            L{twisted.names.dns.RRHeader} giving the response, or with a
            L{Failure} if there is a timeout or response error.
        rz"Query limit reached without resultFr4)rr�
ResolverErrorr2r+�_discoveredAuthority)r
r-r)r.�queriesLeftr1s      rr8zResolver._discoverAuthority|sX��.�!���5�.�.�/S�T�U�U��K�K��w���7��	�
�
�d�/�/����q��Q��rc��������|jtjk7r*t�j	|j�|��Si�|j
D]-}�j
|jg�j|��/�fd�}t�}�j}d}		|j|�|	�||�j�j�}	|	�||�jk(rn�jtjt|��j�j��j!����}
�fd�}|
j#|�|
S|	j�jk(r#|j
|j$|j&fS|	j(j|vrt+j,d��|	j(j}��0i}|j&D]Q}
|
jtj.k(s�!|
j(j1�||
jj<�Sg}g}|j$D]z}
|
jtj2k(s�!|
j(jj}||vr%|j||tj4f��j|j|��||r�j�|���S|rB�j7|d��}
d�}|
j#|�|
j#����fd��|
Stt+j,d��S)	as
        Interpret the response to a query, checking for error codes and
        following delegations if necessary.

        @param response: The L{Message} received in response to issuing C{query}.
        @type response: L{Message}

        @param query: The L{dns.Query} which was issued.
        @type query: L{dns.Query}.

        @param timeout: The timeout to use if another query is indicated by
            this response.
        @type timeout: L{tuple} of L{int}

        @param queriesLeft: A C{int} giving the number of queries which may
            yet be attempted to answer this query before the attempt will be
            abandoned.

        @return: A L{Failure} indicating a response error, a three-tuple of
            lists of L{twisted.names.dns.RRHeader} giving the response to
            C{query} or a L{Deferred} which will fire with one of those.
        c���d}�j|g�D]E}|j|k(s�|j|k(r|cS|jtjk(s�D|}�G|Sr)�getr;r<r�CNAME)r:r<r;�cname�record�recordss     �r�findAnswerOrCNamez8Resolver._discoveredAuthority.<locals>.findAnswerOrCName�s[����E�!�+�+�d�B�/�
'���:�:��$��{�{�d�*�%�
�����	�	�1� &��
'��LrNc�>��|\}}}|jd��|||fS�Nr)�insert)�results�answers�	authority�
additional�previouss    �r�
cbResolvedz1Resolver._discoveredAuthority.<locals>.cbResolved�s*���9@�6���J����q�(�3� '��J�?�?rzCycle in CNAME processingrc�H�|\}}}|djj�SrK)�payload�
dottedQuad)rMrNrOrPs    r�
getOneAddressz4Resolver._discoveredAuthority.<locals>.getOneAddresss'��18�.���J��q�z�)�)�4�4�6�6rc�T���j�|tjfg��dz
�S)Nr4)r8rr%)�hintrAr-r
r.s ����r�<lambda>z/Resolver._discoveredAuthority.<locals>.<lambda>s+���T�4�4��T�3�8�8�,�-�w��a���rz/Stuck at response without answers or delegation)�rCoder�OKr�exceptionForCoderN�
setdefaultr:�append�set�addr<r;r8r9�strr'r+rOrPrTrr?�ArU�NSr%�
lookupAddress)r
�responser-r.rA�answerrI�seenr:rGr1rR�	addresses�rrr�traps�nsrVrQrHs` ```             @@rr@zResolver._discoveredAuthority�s����.�>�>�S�V�V�#��@�4�0�0����@��J�K�K����&�&�	?�F����v�{�{�B�/�6�6�v�>�	?�
	��u���z�z������H�H�T�N��H�&�t�U�Z�Z����C�F��~��5�:�:�%���/�/��	�	�#�d�)�U�Z�Z����C����
��#�	�A�@�
�M�M�*�-��H�����
�
�*� �(�(�(�*<�*<�h�>Q�>Q�R�R��>�>�&�&�$�.��-�-�.I�J�J��~�~�*�*��E�J�	��%�%�	B�B��w�w�#�%�%��*,�*�*�*?�*?�*A�	�"�'�'�,�,�'�	B������$�$�	%�B��w�w�#�&�&� ��Z�Z�_�_�)�)����?��L�L�)�B�-����!:�;��L�L��$�
	%���*�*�5�%��+�N�N�
��"�"�5��8�W�5�A�
7�
�M�M�-�(�
�M�M��
�
�H���#�#�$U�V��
r)�
NN)
rrrrrr'r2r=r8r@rrrrr s&���0�:5��>
��<trrc������fd�}|S)Nc�8�����j���fd���S)Nc�(��t|���i���Sr)�getattr)r0r�kwr:s ���rrYz6makePlaceholder.<locals>.placeholder.<locals>.<lambda>s���'7�w�q�$�'7��'D��'D�r)r+)rrq�deferredr:s``��r�placeholderz$makePlaceholder.<locals>.placeholders������D�E��rr)rrr:rss`` r�makePlaceholderrts�����rc��eZdZd�Zd�Zd�Zy)�DeferredResolverc�H�g|_|j|j�yr)�waitingr+�gotRealResolver)r
�resolverDeferreds  rrzDeferredResolver.__init__s������$�$�T�%9�%9�:rc��|j}|j|_|j|_|D]}|j|��yr)rx�__dict__�	__class__�callback)r
�resolver�wr1s    rryz DeferredResolver.gotRealResolvers@���L�L�� �)�)��
�!�+�+����	!�A�
�J�J�x� �	!rc���|jd�s|dvrF|jjtj��t|jd|�St
|��)N�lookup)�
getHostByNamer-���)�
startswithrxr^r�Deferredrt�AttributeError)r
r:s  r�__getattr__zDeferredResolver.__getattr__%sP���?�?�8�$��0J�(J��L�L������ 0�1�"�4�<�<��#3�T�:�:��T�"�"rN)rrrrryr�rrrrvrvs��;�!�#rrvNc�$��td�D�cgc]}ttd�|z���}}|D�cgc]}|jd|z���}}t	j
|d��}�fd�}|j
|�t|�Scc}wcc}w)a�
    Lookup the root nameserver addresses using the given resolver

    Return a Resolver which will eventually become a C{root.Resolver}
    instance that has references to all the root servers that we were able
    to look up.

    @param resolver: The resolver instance which will be used to
        lookup the root nameserver addresses.
    @type resolver: L{twisted.internet.interfaces.IResolverSimple}

    @param resolverFactory: An optional callable which returns a
        resolver instance. It will passed as the C{resolverFactory}
        argument to L{Resolver.__init__}.
    @type resolverFactory: callable

    @return: A L{DeferredResolver} which will be dynamically replaced
        with L{Resolver} when the root nameservers have been looked up.
    �
�az%s.root-servers.netT)�
consumeErrorsc�V��t|D�cgc]
}|ds�	|d��c}���Scc}w)Nrr4)rr#r)�res�er#s  �r�
buildResolverz bootstrap.<locals>.buildResolverDs-����!$�-�A��!��1�Q�4�-��
�	
��-s�
&�&)�range�chr�ordr�r�DeferredListr+rv)rr#�i�domainsr1�Lr�s `     r�	bootstrapr�,s����(+0��)�4�Q�s�3�s�8�a�<� �4�G�4�DK�L�q��	�	� 5�� 9�	:�L�A�L�
���1�D�1�A�
�
�M�M�-� ��A����5��Ls
�B�B
r)r�twisted.internetr�
twisted.namesrrr�twisted.python.failurerr	rrrtrvr�rrr�<module>r�sK��
	�#�,�,�*�
�
�n�v�"�"�n�b�#�#�&r

Zerion Mini Shell 1.0