summaryrefslogtreecommitdiff
path: root/service/pixelated/application.py
diff options
context:
space:
mode:
authorRoald de Vries <rdevries@thoughtworks.com>2016-09-15 14:30:41 +0200
committerRoald de Vries <rdevries@thoughtworks.com>2016-09-21 14:43:32 +0200
commit553c228924f1c9d2524765d46ec326e6f5eae082 (patch)
tree7d857dfe30d1620edc2c4f33caf5847ad5ad041c /service/pixelated/application.py
parentfc4fe7f3efc69a04a7cd11d2a8ec98a68ec76e4d (diff)
add manhole option to user agent
Diffstat (limited to 'service/pixelated/application.py')
-rw-r--r--service/pixelated/application.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/service/pixelated/application.py b/service/pixelated/application.py
index 178726ef..7e97ee74 100644
--- a/service/pixelated/application.py
+++ b/service/pixelated/application.py
@@ -191,6 +191,22 @@ def _start_in_single_user_mode(args, resource, services_factory):
def start_site(config, resource):
log.info('Starting the API on port %s' % config.port)
+ if config.manhole:
+ MANHOLE_PORT = 8008
+ log.info('Starting the manhole on port %s' % MANHOLE_PORT)
+ from twisted.conch import manhole, manhole_tap, telnet
+ from twisted.conch.insults import insults
+ from twisted.cred import portal, checkers
+ from twisted.internet.protocol import ServerFactory
+ passwdFile, namespace = 'passwd', globals()
+ telnetRealm = manhole_tap._StupidRealm(telnet.TelnetBootstrapProtocol,
+ insults.ServerProtocol,
+ manhole.ColoredManhole,
+ namespace)
+ telnetPortal = portal.Portal(telnetRealm, [checkers.FilePasswordDB(passwdFile)])
+ telnetFactory = ServerFactory()
+ telnetFactory.protocol = manhole_tap.makeTelnetProtocol(telnetPortal)
+ reactor.listenTCP(MANHOLE_PORT, telnetFactory)
if config.sslkey and config.sslcert:
reactor.listenSSL(config.port, PixelatedSite(resource), _ssl_options(config.sslkey, config.sslcert),
interface=config.host)