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


Python TCPHiddenServiceEndpoint.global_tor方法代码示例

本文整理汇总了Python中txtorcon.TCPHiddenServiceEndpoint.global_tor方法的典型用法代码示例。如果您正苦于以下问题:Python TCPHiddenServiceEndpoint.global_tor方法的具体用法?Python TCPHiddenServiceEndpoint.global_tor怎么用?Python TCPHiddenServiceEndpoint.global_tor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在txtorcon.TCPHiddenServiceEndpoint的用法示例。


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

示例1: test_progress_updates_global_tor

# 需要导入模块: from txtorcon import TCPHiddenServiceEndpoint [as 别名]
# 或者: from txtorcon.TCPHiddenServiceEndpoint import global_tor [as 别名]
 def test_progress_updates_global_tor(self, tor):
     ep = TCPHiddenServiceEndpoint.global_tor(self.reactor, 1234)
     tor.call_args[1]['progress_updates'](40, 'FOO', 'foo to the bar')
     return ep
开发者ID:coffeemakr,项目名称:txtorcon,代码行数:6,代码来源:test_endpoints.py

示例2: run

# 需要导入模块: from txtorcon import TCPHiddenServiceEndpoint [as 别名]
# 或者: from txtorcon.TCPHiddenServiceEndpoint import global_tor [as 别名]
    def run(self, options, mainoptions, connection):
        "ICarmlCommand API"

        to_share = None
        self.progress_dots = 0
        if options['file']:
            to_share = open(options['file'], 'r').read()
        else:
            to_share = sys.stdin.read()

        # stealth auth. keys
        authenticators = []
        if options['keys']:
            for x in xrange(options['keys']):
                authenticators.append('carml_%d' % x)

        if len(authenticators):
            print(len(to_share), "bytes to share with",
                  len(authenticators), "authenticated clients.")
        else:
            print(len(to_share), "bytes to share.")
        sys.stdout.flush()

        if options['dry-run']:
            print('Not launching a Tor, listening on 8899.')
            ep = serverFromString(reactor, 'tcp:8899:interface=127.0.0.1')
        elif True:#connection is None:
            print("Launching Tor.")
            ep = TCPHiddenServiceEndpoint.global_tor(reactor, 80, stealth_auth=authenticators)
            txtorcon.IProgressProvider(ep).add_progress_listener(self.progress)
        else:
            config = yield txtorcon.TorConfig.from_connection(connection)
            ep = txtorcon.TCPEphemeralHiddenServiceEndpoint(reactor, config, 80)

        root = Resource()
        data = Data(to_share, 'text/plain')
        root.putChild('', data)

        count = 1 if options['once'] else options['count']
        port = yield ep.listen(PasteBinSite(root, max_requests=count))

        # FIXME
        clients = port.tor_config.hiddenservices[0].clients

        host = port.getHost()
        if options['dry-run']:
            print("Try it locally via http://127.0.0.1:8899")

        elif len(clients):
            print("You requested stealth authentication.")
            print("Tor has created %d keys; each key should be given to one person." % len(clients))
            print('They can set one using the "HidServAuth" torrc option, like so:')
            print("")
            for client in clients:
                print("  HidServAuth %s %s" % (client[0], client[1]))
            print("")
            print("Alternatively, any Twisted endpoint-aware client can be given")
            print("the following string as an endpoint:")
            print("")
            for client in clients:
                print("  tor:%s:authCookie=%s" % (client[0], client[1]))
            print("")
            print("For example, using carml:")
            print("")
            for client in clients:
                print("  carml copybin --service tor:%s:authCookie=%s" % (client[0], client[1]))

        else:
            print("People using Tor Browser Bundle can find your paste at (once the descriptor uploads):")
            print("\n   http://{0}\n".format(host.onion_uri))
            if not count:
                print("Type Control-C to stop serving and shut down the Tor we launched.")
            print("If you wish to keep the hidden-service keys, they're in (until we shut down):")
            print(ep.hidden_service_dir)

        reactor.addSystemEventTrigger('before', 'shutdown',
                                      lambda: print(util.colors.red('Shutting down.')))
        # we never callback() on this, so we serve forever
        d = defer.Deferred()
        yield d
开发者ID:david415,项目名称:carml,代码行数:82,代码来源:pastebin.py

示例3: test_progress_updates_global_tor

# 需要导入模块: from txtorcon import TCPHiddenServiceEndpoint [as 别名]
# 或者: from txtorcon.TCPHiddenServiceEndpoint import global_tor [as 别名]
 def test_progress_updates_global_tor(self, ftb):
     with patch('txtorcon.endpoints.get_global_tor') as tor:
         ep = TCPHiddenServiceEndpoint.global_tor(self.reactor, 1234)
         tor.call_args[1]['progress_updates'](40, 'FOO', 'foo to the bar')
         return ep
开发者ID:felipedau,项目名称:txtorcon,代码行数:7,代码来源:test_endpoints.py


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