当前位置: 首页>>代码示例>>Python>>正文


Python client.createResolver函数代码示例

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


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


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