/
container_run
executable file
·52 lines (34 loc) · 1.16 KB
/
container_run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
## see README
## this runs in the container, and sets up the testcase
import os
import sys
import tempfile
import functools
from twisted.internet import reactor, defer, task
from twisted.internet.endpoints import TCP4ServerEndpoint
from twisted.web import server, resource
from twisted.python import log
log.startLogging(sys.stdout)
print(sys.argv[0])
sys.path.insert(0, '/txtorcon')
import txtorcon
class Simple(resource.Resource):
isLeaf = True
def render_GET(self, request):
return "<html>Hello, world! I'm a hidden service!</html>"
def updates(prog, tag, summary):
p = ('#' * int(10*(prog/100.0))) + ('.'*(10 - int(10*(prog/100.0))))
print("%s %s" % (p, summary))
@defer.inlineCallbacks
def main(reactor):
print("Launching Tor")
tor = yield txtorcon.launch(reactor, socks_port=0, progress_updates=updates)
hs_endpoint = tor.create_onion_endpoint(80)
print("Starting site")
site = server.Site(Simple())
port = yield hs_endpoint.listen(site)
print(port.getHost().onion_uri, port.getHost().onion_port, port.local_address)
print("liftoff")
os.system("netstat -pltn")
task.react(main)