-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
1,234 additions
and
455 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env python | ||
|
||
# This shows how to leverage the endpoints API to get a new hidden | ||
# service up and running quickly. You can pass along this API to your | ||
# users by accepting endpoint strings as per Twisted recommendations. | ||
# | ||
# http://twistedmatrix.com/documents/current/core/howto/endpoints.html#maximizing-the-return-on-your-endpoint-investment | ||
# | ||
# note that only the progress-updates needs the "import txtorcon" -- | ||
# you do still need it installed so that Twisted finds the endpoint | ||
# parser plugin but code without knowledge of txtorcon can still | ||
# launch a Tor instance using it. cool! | ||
|
||
from __future__ import print_function | ||
from twisted.internet import reactor, endpoints | ||
from twisted.web import server, static | ||
import txtorcon | ||
|
||
res = static.Data("<html>Hello, hidden-service world!</html>", 'text/html') | ||
ep = endpoints.serverFromString(reactor, "onion:80") | ||
txtorcon.IProgressProvider(ep).add_progress_listener(lambda p, tag, msg: print(msg)) | ||
ep.listen(server.Site(res)).addCallback(lambda port: print(str(port.getHost()))).addErrback(print) | ||
|
||
reactor.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env python | ||
|
||
## | ||
## Here we set up a Twisted Web server and then launch a slave tor | ||
## with a configured hidden service directed at the Web server we set | ||
## up. This uses serverFromString to translate the "onion" endpoint descriptor | ||
## into a TCPHiddenServiceEndpoint object... | ||
## | ||
|
||
import shutil | ||
|
||
from twisted.internet import reactor | ||
from twisted.web import server, resource | ||
from twisted.internet.endpoints import serverFromString | ||
|
||
import txtorcon | ||
|
||
|
||
class Simple(resource.Resource): | ||
isLeaf = True | ||
|
||
def render_GET(self, request): | ||
return "<html>Hello, world! I'm a hidden service!</html>" | ||
|
||
site = server.Site(Simple()) | ||
|
||
|
||
def setup_failed(arg): | ||
print "SETUP FAILED", arg | ||
|
||
|
||
def setup_complete(port): | ||
print "Hidden serivce:", port.getHost() | ||
print " locally at:", txtorcon.IHiddenService(port).local_address.getHost() | ||
|
||
def progress(percent, tag, message): | ||
bar = int(percent / 10) | ||
print '[%s%s] %s' % ('#' * bar, '.' * (10 - bar), message) | ||
|
||
hs_endpoint1 = serverFromString(reactor, "onion:80") | ||
hs_endpoint2 = serverFromString(reactor, "onion:80") | ||
|
||
txtorcon.IProgressProvider(hs_endpoint1).add_progress_listener(progress) | ||
txtorcon.IProgressProvider(hs_endpoint2).add_progress_listener(progress) | ||
|
||
d1 = hs_endpoint1.listen(site) | ||
d2 = hs_endpoint2.listen(site) | ||
|
||
d1.addCallback(setup_complete).addErrback(setup_failed) | ||
d2.addCallback(setup_complete).addErrback(setup_failed) | ||
|
||
reactor.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env python | ||
|
||
from __future__ import print_function | ||
from twisted.internet import reactor | ||
from twisted.internet.endpoints import serverFromString | ||
from twisted.web import server, static | ||
|
||
serverFromString(reactor, "onion:80").listen(server.Site(static.Data("Hello, world!", "text/plain"))).addCallback(print) | ||
reactor.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.