• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python client.createResolver函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中twisted.names.client.createResolver函数的典型用法代码示例。如果您正苦于以下问题:Python createResolver函数的具体用法?Python createResolver怎么用?Python createResolver使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了createResolver函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, loc_stats, minute_breakdowns=(1, 5, 15, 60)):
     self.loc_stats = loc_stats
     self.seen_ips = Counter()
     self.bot_ips = Counter()
     self.non_bot_ips = MultiIntervalCounter(multiples=minute_breakdowns)
     self.rdns = MultiIntervalCounter(multiples=minute_breakdowns)
     self.resolver = createResolver()
开发者ID:nightfly19,项目名称:GeoIPAnalytics,代码行数:7,代码来源:server.py


示例2: buildHostMap

def buildHostMap(ipFile, outFilename):

    reactor.installResolver(client.createResolver(servers=[('127.0.0.1', 53), ('8.8.8.8', 53), ('8.8.4.4', 53)]))
    CHUNK_SIZE = 20000
    
    ipList = []
    with open(ipFile, 'r') as f:
        for line in f:
            if line[0].isdigit():
                ipList.append(line.split(',')[0])

    outFile = open(outFilename, 'w')

    def ret(dummy, chunk, outFile):
        return defer.DeferredList([reverseLookup(ip, outFile) for ip in chunk])

    ipList = [ipList[i:i+CHUNK_SIZE] for i in xrange(0, len(ipList), CHUNK_SIZE-1)]

    d = defer.Deferred()
    for chunk in ipList:
        d.addCallback(ret, chunk, outFile)
    # cleanup after ourselves
    d.addCallback(die, outFile)
    d.callback(None)

    reactor.run()
开发者ID:Ames-Laboratory-Cyber-Group,项目名称:Cydime,代码行数:26,代码来源:HostMap.py


示例3: __init__

 def __init__(self, loc_stats):
     self.loc_stats = loc_stats
     self.seen_ips = Counter()
     self.bot_ips = Counter()
     self.non_bot_ips = MultiIntervalCounter()
     self.rdns = MultiIntervalCounter()
     self.resolver = createResolver()
开发者ID:nibalizer,项目名称:GeoIPAnalytics,代码行数:7,代码来源:server.py


示例4: test_lookup

    def test_lookup(self):
        """
        We perform an A lookup on the DNS test servers for the domains to be
        tested and an A lookup on the known good DNS server.

        We then compare the results from test_resolvers and that from
        control_resolver and see if the match up.
        If they match up then no censorship is happening (tampering: false).

        If they do not we do a reverse lookup (PTR) on the test_resolvers and
        the control resolver for every IP address we got back and check to see
        if anyone of them matches the control ones.

        If they do then we take not of the fact that censorship is probably not
        happening (tampering: reverse-match).

        If they do not match then censorship is probably going on (tampering:
        true).
        """
        log.msg("Doing the test lookups on %s" % self.input)
        list_of_ds = []
        hostname = self.input

        resolver = [(self.localOptions['controlresolver'], 53)]
        res = client.createResolver(servers=resolver, resolvconf='')

        control_r = res.lookupAddress(hostname, timeout=self.lookupTimeout)
        control_r.addCallback(self.process_a_answers, 'control')
        control_r.addErrback(self.a_lookup_error, 'control')

        for test_resolver in self.test_resolvers:
            log.msg("Going for %s" % test_resolver)
            resolver = [(test_resolver, 53)]
            res = client.createResolver(servers=resolver, resolvconf='')
            #res = self.createResolver(servers=resolver)

            d = res.lookupAddress(hostname, timeout=self.lookupTimeout)
            d.addCallback(self.process_a_answers, test_resolver)
            d.addErrback(self.a_lookup_error, test_resolver)
            list_of_ds.append(d)

        list_of_ds.append(control_r)
        dl = defer.DeferredList(list_of_ds)
        dl.addCallback(self.do_reverse_lookups)
        dl.addBoth(self.compare_results)
        return dl
开发者ID:hackerberry,项目名称:ooni-probe,代码行数:46,代码来源:dnstamper.py


示例5: test_defaultResolvConf

 def test_defaultResolvConf(self):
     """
     L{client.createResolver} returns a L{resolve.ResolverChain} including a
     L{client.Resolver} using I{/etc/resolv.conf} if no alternate resolver
     configuration file is specified.
     """
     with AlternateReactor(Clock()):
         resolver = client.createResolver()
     self._resolvConfTest(resolver, b"/etc/resolv.conf")
开发者ID:ali-hallaji,项目名称:twisted,代码行数:9,代码来源:test_client.py


示例6: test_defaultHosts

 def test_defaultHosts(self):
     """
     L{client.createResolver} returns a L{resolve.ResolverChain} including a
     L{hosts.Resolver} using I{/etc/hosts} if no alternate hosts file is
     specified.
     """
     with AlternateReactor(Clock()):
         resolver = client.createResolver()
     self._hostsTest(resolver, b"/etc/hosts")
开发者ID:ali-hallaji,项目名称:twisted,代码行数:9,代码来源:test_client.py


示例7: __init__

 def __init__(self, resolver=None, clock=None):
     self.badMXs = {}
     if resolver is None:
         from twisted.names.client import createResolver
         resolver = createResolver()
     self.resolver = resolver
     if clock is None:
         from twisted.internet import reactor as clock
     self.clock = clock
开发者ID:Almad,项目名称:twisted,代码行数:9,代码来源:relaymanager.py


示例8: test_overrideHosts

 def test_overrideHosts(self):
     """
     The I{hosts} parameter to L{client.createResolver} overrides the hosts
     file used by the L{hosts.Resolver} in the L{resolve.ResolverChain} it
     returns.
     """
     with AlternateReactor(Clock()):
         resolver = client.createResolver(hosts=b"/foo/bar")
     self._hostsTest(resolver, b"/foo/bar")
开发者ID:ali-hallaji,项目名称:twisted,代码行数:9,代码来源:test_client.py


示例9: test_cache

 def test_cache(self):
     """
     L{client.createResolver} returns a L{resolve.ResolverChain} including a
     L{cache.CacheResolver}.
     """
     with AlternateReactor(Clock()):
         resolver = client.createResolver()
     res = [r for r in resolver.resolvers if isinstance(r, cache.CacheResolver)]
     self.assertEqual(1, len(res))
开发者ID:ali-hallaji,项目名称:twisted,代码行数:9,代码来源:test_client.py


示例10: test_overrideResolvConf

 def test_overrideResolvConf(self):
     """
     The I{resolvconf} parameter to L{client.createResolver} overrides the
     resolver configuration file used by the L{client.Resolver} in the
     L{resolve.ResolverChain} it returns.
     """
     with AlternateReactor(Clock()):
         resolver = client.createResolver(resolvconf=b"/foo/bar")
     self._resolvConfTest(resolver, b"/foo/bar")
开发者ID:ali-hallaji,项目名称:twisted,代码行数:9,代码来源:test_client.py


示例11: run

    def run(self):
        """Start the monitoring"""

        super(DNSQueryMonitoringProtocol, self).run()

        # Create a resolver
        self.resolver = client.createResolver([(self.server.ip, 53)])

        if not self.checkCall or not self.checkCall.active():
            self.checkCall = reactor.callLater(self.intvCheck, self.check)
开发者ID:mayson,项目名称:wikimedia-pybal,代码行数:10,代码来源:dnsquery.py


示例12: test_reactor

 def test_reactor(self):
     """
     The L{client.Resolver} included in the L{resolve.ResolverChain} returned
     by L{client.createResolver} uses the global reactor.
     """
     reactor = Clock()
     with AlternateReactor(reactor):
         resolver = client.createResolver()
     res = [r for r in resolver.resolvers if isinstance(r, client.Resolver)]
     self.assertEqual(1, len(res))
     self.assertIs(reactor, res[0]._reactor)
开发者ID:ali-hallaji,项目名称:twisted,代码行数:11,代码来源:test_client.py


示例13: __init__

    def __init__(self, args):
        server.DNSServerFactory.__init__(self)

        # Create the resolvers
        dns_resolver = client.createResolver(resolvconf='/etc/resolv.conf')
        filter_resolver = resolvers.FilterResolver(dns_resolver, 
            self._get_filter(args))

        # Override the default resolver for the parent factory
        self.resolver = filter_resolver
        self.canRecurse = True
开发者ID:deanydean,项目名称:dnsfilter,代码行数:11,代码来源:server.py


示例14: fight_thread

def fight_thread(control):
    el = ExitList(filename = config.export_file_prefix + ".csv",
                  status_filename = config.export_file_prefix + ".status")
    log.info("Initialized exit list.")
    dnsel  = client.createResolver()
    torbel = client.createResolver(servers = [("localhost", 53)])
    log.info("Initialized resolvers.")

    def makeResultChecker(router):
        return lambda rlist: printResult(router, rlist)

    def printResult((source, dest, dest_port, qstr, dnsel_ok2), result_list):
        global match, mismatch
        dnsel_ok  = False
        torbel_ok = False
        torbel_el_ok = el.tor_exit_search(source, dest, dest_port) is not None
        
        query = ""
        for (success, value) in result_list:
            if success:
                (a_names, auth, cnames) = value
                assert len(a_names) == 1
                for rec in a_names:
                    dnsel_ok  = dnsel_zone in str(rec.name)
                    torbel_ok = local_zone in str(rec.name)

        q = "%-15s -> %-15s:%-5d - " % (IPAddress(source), IPAddress(dest), dest_port)
        
        if dnsel_ok2 and torbel_el_ok:
            log.info(q + "DNSEL and TorBEL agree on YES.")
            match += 1
        elif not (dnsel_ok2 or torbel_el_ok):
            log.info(q + "DNSEL and TorBEL agree on NO.")
            match += 1
        else:
            log.info(q + "mismatch: DNSEL = %s, TorBEL DNS = %s, TorBEL query = %s, q = %s",
                     "yes" if dnsel_ok2 else "no",
                     "yes" if torbel_ok else "no",
                     "yes" if torbel_el_ok else "no",
                     qstr)
            mismatch += 1
开发者ID:codarrenvelvindron,项目名称:torbel,代码行数:41,代码来源:tests.py


示例15: test_overrideServers

 def test_overrideServers(self):
     """
     Servers passed to L{client.createResolver} are used in addition to any
     found in the file given by the I{resolvconf} parameter.
     """
     resolvconf = self.path()
     resolvconf.setContent(b"nameserver 127.1.2.3\n")
     with AlternateReactor(Clock()):
         resolver = client.createResolver(servers=[("127.3.2.1", 53)], resolvconf=resolvconf.path)
     res = [r for r in resolver.resolvers if isinstance(r, client.Resolver)]
     self.assertEqual(1, len(res))
     self.assertEqual([("127.3.2.1", 53)], res[0].servers)
     self.assertEqual([("127.1.2.3", 53)], res[0].dynServers)
开发者ID:pelluch,项目名称:VTK,代码行数:13,代码来源:test_client.py


示例16: test_defaultServers

 def test_defaultServers(self):
     """
     If no servers are given, addresses are taken from the file given by the
     I{resolvconf} parameter to L{client.createResolver}.
     """
     resolvconf = self.path()
     resolvconf.setContent(b"nameserver 127.1.2.3\n")
     with AlternateReactor(Clock()):
         resolver = client.createResolver(resolvconf=resolvconf.path)
     res = [r for r in resolver.resolvers if isinstance(r, client.Resolver)]
     self.assertEqual(1, len(res))
     self.assertEqual([], res[0].servers)
     self.assertEqual([("127.1.2.3", 53)], res[0].dynServers)
开发者ID:ali-hallaji,项目名称:twisted,代码行数:13,代码来源:test_client.py


示例17: __init__

 def __init__(self, forwarders, savedir):
     self.canRecurse = True
     self.connections = []
     self.forwarders = forwarders
     forward_resolver = createResolver(servers=[(x, 53) for x in forwarders])
     self.savedir = savedir
     if self.savedir is not None:
         self.savedir = os.path.expanduser(self.savedir)
         if not os.path.exists(self.savedir):
             log.msg("Setting up save directory " + savedir)
             os.mkdir(self.savedir)
     self.resolver = MiniDNSResolverChain([forward_resolver], self.savedir)
     self.verbose = False
     self.load()
开发者ID:zenweasel,项目名称:minidns,代码行数:14,代码来源:dns.py


示例18: __init__

    def __init__(self, resolver=None, clock=None):
        """
        @type resolver: L{IResolver <twisted.internet.interfaces.IResolver>}
            provider or L{None}
        @param: A resolver.

        @type clock: L{IReactorTime <twisted.internet.interfaces.IReactorTime>}
            provider or L{None}
        @param clock: A reactor which will be used to schedule timeouts.
        """
        self.badMXs = {}
        if resolver is None:
            from twisted.names.client import createResolver
            resolver = createResolver()
        self.resolver = resolver
        if clock is None:
            from twisted.internet import reactor as clock
        self.clock = clock
开发者ID:alfonsjose,项目名称:international-orders-app,代码行数:18,代码来源:relaymanager.py


示例19: lookup_name6

def lookup_name6(name, server=None):
    """ This function performs the lookup for ipv6 """
    if server != None:
        resolver = client.Resolver(servers=[(server, 53)])
    else:
        resolver = client.createResolver()
    outer_deferred = defer.Deferred()

    def wrap_result(result):
        """ Wrap result returned by Twisted """
        outer_deferred.callback(LookupAnswer(result))

    def wrap_error(err):
        """ Wrap error returned by Twisted """
        outer_deferred.errback(LookupErrors(err))

    inner_deferred = resolver.lookupIPV6Address(name=name, timeout=[5, 10, 20])
    inner_deferred.addCallbacks(wrap_result, wrap_error)
    return outer_deferred
开发者ID:danink91,项目名称:Neubot_cdn_test,代码行数:19,代码来源:lookup_name.py


示例20: _buildResolvers

    def _buildResolvers(self, config):
        """
        Build DNS resolver instances in an order which leaves recursive
        resolving as a last resort.

        @type config: L{Options} instance
        @param config: Parsed command-line configuration

        @return: Two-item tuple of a list of cache resovers and a list of client
            resolvers
        """
        from twisted.names import client, cache, hosts

        ca, cl = [], []
        if config['cache']:
            ca.append(cache.CacheResolver(verbose=config['verbose']))
        if config['hosts-file']:
            cl.append(hosts.Resolver(file=config['hosts-file']))
        if config['recursive']:
            cl.append(client.createResolver(resolvconf=config['resolv-conf']))
        return ca, cl
开发者ID:Navaneethsen,项目名称:elijah-cloudlet,代码行数:21,代码来源:cloudlet_dns.py



注:本文中的twisted.names.client.createResolver函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python client.Resolver类代码示例发布时间:2022-05-27
下一篇:
Python tap.Options类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap