__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
# -*- test-case-name: twisted.names.test.test_resolve -*-
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.
"""
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?)
"""
from zope.interface import implementer
from twisted.internet import defer, interfaces
from twisted.names import common, dns, error
class FailureHandler:
def __init__(self, resolver, query, timeout):
self.resolver = resolver
self.query = query
self.timeout = timeout
def __call__(self, failure):
# AuthoritativeDomainErrors should halt resolution attempts
failure.trap(dns.DomainError, defer.TimeoutError, NotImplementedError)
return self.resolver(self.query, self.timeout)
@implementer(interfaces.IResolver)
class ResolverChain(common.ResolverBase):
"""
Lookup an address using multiple L{IResolver}s
"""
def __init__(self, resolvers):
"""
@type resolvers: L{list}
@param resolvers: A L{list} of L{IResolver} providers.
"""
common.ResolverBase.__init__(self)
self.resolvers = resolvers
def _lookup(self, name, cls, type, timeout):
"""
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}.
"""
if not self.resolvers:
return defer.fail(error.DomainError())
q = dns.Query(name, type, cls)
d = self.resolvers[0].query(q, timeout)
for r in self.resolvers[1:]:
d = d.addErrback(FailureHandler(r.query, q, timeout))
return d
def lookupAllRecords(self, name, timeout=None):
# XXX: Why is this necessary? dns.ALL_RECORDS queries should
# be handled just the same as any other type by _lookup
# above. If I remove this method all names tests still
# pass. See #6604 -rwall
if not self.resolvers:
return defer.fail(error.DomainError())
d = self.resolvers[0].lookupAllRecords(name, timeout)
for r in self.resolvers[1:]:
d = d.addErrback(FailureHandler(r.lookupAllRecords, name, timeout))
return d
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __pycache__ | Folder | 0755 |
|
|
| newsfragments | Folder | 0755 |
|
|
| test | Folder | 0755 |
|
|
| __init__.py | File | 135 B | 0644 |
|
| _rfc1982.py | File | 8.98 KB | 0644 |
|
| authority.py | File | 16.29 KB | 0644 |
|
| cache.py | File | 3.94 KB | 0644 |
|
| client.py | File | 23.94 KB | 0644 |
|
| common.py | File | 9.14 KB | 0644 |
|
| dns.py | File | 97.51 KB | 0644 |
|
| error.py | File | 1.98 KB | 0644 |
|
| hosts.py | File | 4.69 KB | 0644 |
|
| resolve.py | File | 3.17 KB | 0644 |
|
| root.py | File | 12.13 KB | 0644 |
|
| secondary.py | File | 6.97 KB | 0644 |
|
| server.py | File | 21.66 KB | 0644 |
|
| srvconnect.py | File | 8.98 KB | 0644 |
|
| tap.py | File | 4.69 KB | 0644 |
|