�
Ϫ�f�0 � � � d Z ddlmZ ddlmZmZmZ ddlmZ G d� d� Z G d� dej � Zd � Z G d
� 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 � � e Zd ZdZd� 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.messageReceived s � �� N)�__name__�
__module__�__qualname__�__doc__r r r r r r s � ��
r r c �6 � e Zd ZdZd 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 � � t j j | � || _ || _ || _ |�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 r r zResolver.__init__+ s? � �* ���$�$�T�*���
�-�����
��"�H� /��r c �` � | j D �cg c] }|t j f�� c}S c c}w )z�
Return a list of two-tuples representing the addresses of the root
servers, as defined by C{self.hints}.
)r r �PORT)r
�ips r �_rootszResolver._rootsH s$ � �
*.���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" |