当前位置: 首页>>代码示例>>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;未经允许,请勿转载。