�
Ϫ�f� � � � d Z ddlmZ ddlmZmZ ddlmZmZm Z G d� d� Z
eej � G d� dej � � Z
y )
z�
Lookup a name using multiple resolvers.
Future Plans: This needs someway to specify which resolver answered
the query, or someway to specify (authority|ttl|cache behavior|more?)
� )�implementer)�defer�
interfaces)�common�dns�errorc � � e Zd Zd� Zd� Zy)�FailureHandlerc �. � || _ || _ || _ y �N)�resolver�query�timeout)�selfr
r r s �7/usr/lib/python3/dist-packages/twisted/names/resolve.py�__init__zFailureHandler.__init__ s � � ��
���
���� c � � |j t j t j t
� | j
| j | j � S r ) �trapr �DomainErrorr �TimeoutError�NotImplementedErrorr
r r )r �failures r �__call__zFailureHandler.__call__ s6 � ����S�_�_�e�&8�&8�:M�N��}�}�T�Z�Z����6�6r N)�__name__�
__module__�__qualname__r r � r r r
r
s � ��
7r r
c �$ � e Zd ZdZd� Zd� Zdd�Zy)�
ResolverChainz8
Lookup an address using multiple L{IResolver}s
c �P � t j j | � || _ y)zi
@type resolvers: L{list}
@param resolvers: A L{list} of L{IResolver} providers.
N)r �ResolverBaser � resolvers)r r# s r r zResolverChain.__init__% s � �
���$�$�T�*�"��r c �L � | j s't j t j � � S t j |||� }| j d j ||� }| j dd D ]( }|j t |j ||� � }�* |S )aN
Build a L{dns.Query} for the given parameters and dispatch it
to each L{IResolver} in C{self.resolvers} until an answer or
L{error.AuthoritativeDomainError} is returned.
@type name: C{str}
@param name: DNS name to resolve.
@type type: C{int}
@param type: DNS record type.
@type cls: C{int}
@param cls: DNS record class.
@type timeout: Sequence of C{int}
@param timeout: Number of seconds after which to reissue the query.
When the last timeout expires, the query is considered failed.
@rtype: L{Deferred}
@return: A L{Deferred} which fires with a three-tuple of lists of
L{twisted.names.dns.RRHeader} instances. The first element of the
tuple gives answers. The second element of the tuple gives
authorities. The third element of the tuple gives additional
information. The L{Deferred} may instead fail with one of the
exceptions defined in L{twisted.names.error} or with
C{NotImplementedError}.
r � N)
r# r �failr r r �Queryr �
addErrbackr
)r �name�cls�typer �q�d�rs r �_lookupzResolverChain._lookup- s� � �8 �~�~��:�:�e�/�/�1�2�2��I�I�d�D�#�&���N�N�1��#�#�A�w�/�������#� B�A����^�A�G�G�Q��@�A�A� B��r Nc � � | j s't j t j � � S | j d j ||� }| j dd D ]( }|j
t |j
||� � }�* |S )Nr r% )r# r r& |