當前位置: 首頁>>代碼示例>>Python>>正文


Python resolver.Resolver方法代碼示例

本文整理匯總了Python中dns.resolver.Resolver方法的典型用法代碼示例。如果您正苦於以下問題:Python resolver.Resolver方法的具體用法?Python resolver.Resolver怎麽用?Python resolver.Resolver使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dns.resolver的用法示例。


在下文中一共展示了resolver.Resolver方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: process

# 需要導入模塊: from dns import resolver [as 別名]
# 或者: from dns.resolver import Resolver [as 別名]
def process(self, headers, content):
        request = Services.get("request_factory")
        hostname = urlparse(request.url).hostname
        try:
            resolver = Resolver(configure=False)
            resolver.nameservers = [settings.dns_resolver]
            resolver.timeout = 2
            resolver.lifetime = 2

            dns_query = resolver.query(hostname + ".edgekey.net", "A")

            if len(dns_query) > 0:
                return "Akamai CDN"

        except NXDOMAIN:
            pass
        except NoAnswer:
            pass
        except Timeout:
            pass 
開發者ID:shenril,項目名稱:Sitadel,代碼行數:22,代碼來源:akamai.py

示例2: process

# 需要導入模塊: from dns import resolver [as 別名]
# 或者: from dns.resolver import Resolver [as 別名]
def process(self, headers, content):
        request = Services.get("request_factory")
        hostname = urlparse(request.url).hostname
        _ = False
        try:
            resolver = Resolver(configure=False)
            resolver.nameservers = [settings.dns_resolver]
            resolver.timeout = 2
            resolver.lifetime = 2

            dns_query = resolver.query(hostname, "CNAME")

            if len(dns_query) > 0:
                for answer in dns_query:
                    _ |= re.search(r"cloudfront\.net", str(answer), re.I) is not None
            if _:
                return "CloudFront CDN (Amazon)"
        except NoAnswer:
            pass
        except NXDOMAIN:
            pass
        except Timeout:
            pass 
開發者ID:shenril,項目名稱:Sitadel,代碼行數:25,代碼來源:cloudfront.py

示例3: process

# 需要導入模塊: from dns import resolver [as 別名]
# 或者: from dns.resolver import Resolver [as 別名]
def process(self, headers, content):
        request = Services.get("request_factory")
        hostname = urlparse(request.url).hostname
        _ = False

        try:
            resolver = Resolver(configure=False)
            resolver.nameservers = [settings.dns_resolver]
            resolver.timeout = 2
            resolver.lifetime = 2

            dns_query = resolver.query(hostname, "CNAME")
            if len(dns_query) > 0:
                for answer in dns_query:
                    _ |= re.search(r"azureedge\.net", str(answer), re.I) is not None
            if _:
                return "Azure CDN"
        except NoAnswer:
            pass
        except NXDOMAIN:
            pass
        except Timeout:
            pass 
開發者ID:shenril,項目名稱:Sitadel,代碼行數:25,代碼來源:azure.py

示例4: process

# 需要導入模塊: from dns import resolver [as 別名]
# 或者: from dns.resolver import Resolver [as 別名]
def process(self, headers, content):
        request = Services.get("request_factory")
        hostname = urlparse(request.url).hostname
        try:
            resolver = Resolver(configure=False)
            resolver.nameservers = [settings.dns_resolver]
            resolver.timeout = 2
            resolver.lifetime = 2
            dns_query = resolver.query(hostname + ".cdn.cloudflare.net", "A")

            if len(dns_query) > 0:
                return "Cloudflare CDN"

        except NXDOMAIN:
            pass
        except NoAnswer:
            pass
        except Timeout:
            pass 
開發者ID:shenril,項目名稱:Sitadel,代碼行數:21,代碼來源:cloudflare.py

示例5: process

# 需要導入模塊: from dns import resolver [as 別名]
# 或者: from dns.resolver import Resolver [as 別名]
def process(self, headers, content):
        request = Services.get("request_factory")
        hostname = urlparse(request.url).hostname
        _ = False
        try:
            resolver = Resolver(configure=False)
            resolver.nameservers = [settings.dns_resolver]
            resolver.timeout = 2
            resolver.lifetime = 2

            dns_query = resolver.query(hostname, "CNAME")
            if len(dns_query) > 0:
                for answer in dns_query:
                    _ |= re.search(r"fastly\.net", str(answer), re.I) is not None
            if _:
                return "Fastly CDN"
        except NoAnswer:
            pass
        except NXDOMAIN:
            pass
        except Timeout:
            pass 
開發者ID:shenril,項目名稱:Sitadel,代碼行數:24,代碼來源:fastly.py

示例6: reflush

# 需要導入模塊: from dns import resolver [as 別名]
# 或者: from dns.resolver import Resolver [as 別名]
def reflush(obj, nameserver):
    r = resolver.Resolver()
    r.nameservers = [nameserver]
    try:
        answers = r.query(obj.url, 'CNAME')
        for rdata in answers:
            return rdata.to_text()[:-1]
    except resolver.NoAnswer as e:
        try:
            answer = r.query(obj.url, 'A')
            for rr in answer:
                return rr.address
        except Exception as e:
            pass
    except resolver.NXDOMAIN as e:
        return ''
    return '' 
開發者ID:YoLoveLife,項目名稱:DevOps,代碼行數:19,代碼來源:tasks.py

示例7: dns_lookup

# 需要導入模塊: from dns import resolver [as 別名]
# 或者: from dns.resolver import Resolver [as 別名]
def dns_lookup(input, timeout=3, server=""):
    """Perform a simple DNS lookup, return results in a dictionary"""
    resolver = Resolver()
    resolver.timeout = float(timeout)
    resolver.lifetime = float(timeout)
    if server:
        resolver.nameservers = [server]
    try:
        records = resolver.query(input, "A")
        return {
            "addrs": [ii.address for ii in records],
            "error": "",
            "name": input,
        }
    except DNSException as e:
        return {
            "addrs": [],
            "error": repr(e),
            "name": input,
        } 
開發者ID:mpenning,項目名稱:ciscoconfparse,代碼行數:22,代碼來源:ccp_util.py

示例8: dns6_lookup

# 需要導入模塊: from dns import resolver [as 別名]
# 或者: from dns.resolver import Resolver [as 別名]
def dns6_lookup(input, timeout=3, server=""):
    """Perform a simple DNS lookup, return results in a dictionary"""
    resolver = Resolver()
    resolver.timeout = float(timeout)
    resolver.lifetime = float(timeout)
    if server:
        resolver.nameservers = [server]
    try:
        records = resolver.query(input, "AAAA")
        return {
            "addrs": [ii.address for ii in records],
            "error": "",
            "name": input,
        }
    except DNSException as e:
        return {
            "addrs": [],
            "error": repr(e),
            "name": input,
        } 
開發者ID:mpenning,項目名稱:ciscoconfparse,代碼行數:22,代碼來源:ccp_util.py

示例9: time_resolve

# 需要導入模塊: from dns import resolver [as 別名]
# 或者: from dns.resolver import Resolver [as 別名]
def time_resolve(args, server, name, rectype, tries=3):
    """
    Time how long it takes to resolve a name using the server
    """
    resolver = Resolver()
    resolver.timeout = args.timeout
    resolver.lifetime = args.timeout
    resolver.nameservers = [server]
    results = []

    while tries > 0:
        start = time.time()
        try:
            result = resolver.query(name, rectype)
        except DNSException as ex:
            end = time.time()
            LOG.debug("%s failed in %.2fs", server, end - start)
            result = ex
        else:
            end = time.time()
            LOG.debug("%s resolved %s %s in %.2fs", server, name, rectype, end - start)
        results.append((end - start, result))
        tries -= 1
    return server, check_results(results), results 
開發者ID:XiphosResearch,項目名稱:dnsbrute,代碼行數:26,代碼來源:checkresolvers.py

示例10: check_for_wildcards

# 需要導入模塊: from dns import resolver [as 別名]
# 或者: from dns.resolver import Resolver [as 別名]
def check_for_wildcards(args, server, name, rectype, tries=4):
    """
    Verify that the DNS server doesn't return wildcard results for domains
    which don't exist, it should correctly return NXDOMAIN.
    """
    resolver = Resolver()
    resolver.timeout = args.timeout
    resolver.lifetime = args.timeout
    resolver.nameservers = [server]
    nx_names = [base64.b32encode(
                    os.urandom(
                        random.randint(8, 10))
                ).strip('=').lower() + name
                for _ in range(0, tries)]
    correct_result_count = 0
    for check_nx_name in nx_names:
        try:
            result = resolver.query(check_nx_name, rectype)            
            return False  # Any valid response = immediate fail!
        except (NXDOMAIN, NoNameservers):
            correct_result_count += 1
        except DNSException:
            continue        
    return correct_result_count > (tries / 2.0) 
開發者ID:XiphosResearch,項目名稱:dnsbrute,代碼行數:26,代碼來源:checkresolvers.py

示例11: dns_cache_install

# 需要導入模塊: from dns import resolver [as 別名]
# 或者: from dns.resolver import Resolver [as 別名]
def dns_cache_install():
    try:
        from dns_cache.resolver import ExceptionCachingResolver
        from dns import resolver as dnspython_resolver_module
        if not dnspython_resolver_module.default_resolver:
            dnspython_resolver_module.default_resolver = ExceptionCachingResolver()
        del dnspython_resolver_module
    except ImportError:
        pass

    try:
        from dns.resolver import LRUCache, Resolver, override_system_resolver, _resolver, default_resolver
    except ImportError:
        return

    if default_resolver:
        if not default_resolver.cache:
            default_resolver.cache = LRUCache()
        resolver = default_resolver
    elif _resolver and _resolver.cache:
        resolver = _resolver
    else:
        resolver = Resolver()
        resolver.cache = LRUCache()
    override_system_resolver(resolver) 
開發者ID:lipoja,項目名稱:URLExtract,代碼行數:27,代碼來源:urlextract_core.py

示例12: connect

# 需要導入模塊: from dns import resolver [as 別名]
# 或者: from dns.resolver import Resolver [as 別名]
def connect(self):
		resolver = Resolver()
		resolver.nameservers = self._dnsproxy
		answer = resolver.query(self.host, 'A')
		self.host = answer.rrset.items[0].address
		self.sock = socket.create_connection((self.host, self.port)) 
開發者ID:moneymaker365,項目名稱:plugin.video.ustvvod,代碼行數:8,代碼來源:connection.py

示例13: configure

# 需要導入模塊: from dns import resolver [as 別名]
# 或者: from dns.resolver import Resolver [as 別名]
def configure(self, dns_servers, *, bind_addresses=None, search_domains=()):
        super().configure(dns_servers, bind_addresses=bind_addresses, search_domains=search_domains)

        self.resolver = Resolver(configure=False)
        self.resolver.domain = root
        self.resolver.search = [from_text(d) for d in search_domains]

        self.rectypes = []
        if self.bind_addresses is None or any(a.version == 4 for a in self.bind_addresses):
            self.rectypes.append('A')
        if self.bind_addresses is None or any(a.version == 6 for a in self.bind_addresses):
            self.rectypes.append('AAAA') 
開發者ID:dlenski,項目名稱:vpn-slice,代碼行數:14,代碼來源:dnspython.py

示例14: dns_resolver

# 需要導入模塊: from dns import resolver [as 別名]
# 或者: from dns.resolver import Resolver [as 別名]
def dns_resolver():
    """
    dns解析器
    """
    resolver = Resolver()
    resolver.nameservers = setting.resolver_nameservers
    resolver.timeout = setting.resolver_timeout
    resolver.lifetime = setting.resolver_lifetime
    return resolver 
開發者ID:shmilylty,項目名稱:OneForAll,代碼行數:11,代碼來源:utils.py

示例15: reflush

# 需要導入模塊: from dns import resolver [as 別名]
# 或者: from dns.resolver import Resolver [as 別名]
def reflush(url, nameserver):
    r = resolver.Resolver()
    r.nameservers = [nameserver]
    try:
        answers = r.query(url, 'CNAME')
        for rdata in answers:
            return rdata.to_text()[:-1]
    except resolver.NoAnswer as e:
        return ''
    except resolver.NXDOMAIN as e:
        return ''
    return '' 
開發者ID:YoLoveLife,項目名稱:DevOps,代碼行數:14,代碼來源:tasks.py


注:本文中的dns.resolver.Resolver方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。