o ¯b± ã@sbdZddlmZddlmZmZddlmZmZm Z Gdd„dƒZ eej ƒGdd„dej ƒƒZ d S) 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@seZdZdd„Zdd„ZdS)ÚFailureHandlercCs||_||_||_dS©N)ÚresolverÚqueryÚtimeout)Úselfr r r ©rú7/usr/lib/python3/dist-packages/twisted/names/resolve.pyÚ__init__s zFailureHandler.__init__cCs"| tjtjt¡| |j|j¡Sr ) ÚtraprÚ DomainErrorrÚ TimeoutErrorÚNotImplementedErrorr r r )r ÚfailurerrrÚ__call__szFailureHandler.__call__N)Ú__name__Ú __module__Ú __qualname__rrrrrrrs rc@s*eZdZdZdd„Zdd„Zd dd„ZdS) Ú ResolverChainz8 Lookup an address using multiple L{IResolver}s cCstj |¡||_dS)zi @type resolvers: L{list} @param resolvers: A L{list} of L{IResolver} providers. N)rÚ ResolverBaserÚ resolvers)r rrrrr%s  zResolverChain.__init__cCs`|js t t ¡¡St |||¡}|jd ||¡}|jdd…D] }| t |j||ƒ¡}q!|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) rrÚfailrrrÚQueryr Ú addErrbackr)r ÚnameÚclsÚtyper ÚqÚdÚrrrrÚ_lookup-szResolverChain._lookupNcCsR|js t t ¡¡S|jd ||¡}|jdd…D] }| t|j||ƒ¡}q|S)Nrr)rrrrrÚlookupAllRecordsr r)r r!r r%r&rrrr(Qs zResolverChain.lookupAllRecordsr )rrrÚ__doc__rr'r(rrrrrs $rN)r)Úzope.interfacerÚtwisted.internetrrÚ twisted.namesrrrrÚ IResolverrrrrrrÚs