本文整理汇总了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
示例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
示例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