diff options
author | Roald de Vries <rdevries@thoughtworks.com> | 2016-09-15 14:30:41 +0200 |
---|---|---|
committer | Roald de Vries <rdevries@thoughtworks.com> | 2016-09-21 14:43:32 +0200 |
commit | 553c228924f1c9d2524765d46ec326e6f5eae082 (patch) | |
tree | 7d857dfe30d1620edc2c4f33caf5847ad5ad041c /service | |
parent | fc4fe7f3efc69a04a7cd11d2a8ec98a68ec76e4d (diff) |
add manhole option to user agent
Diffstat (limited to 'service')
-rw-r--r-- | service/pixelated/application.py | 16 | ||||
-rw-r--r-- | service/pixelated/config/arguments.py | 1 |
2 files changed, 17 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) diff --git a/service/pixelated/config/arguments.py b/service/pixelated/config/arguments.py index b6b3ce43..b5f2101a 100644 --- a/service/pixelated/config/arguments.py +++ b/service/pixelated/config/arguments.py @@ -30,6 +30,7 @@ def parse_user_agent_args(): parser.add_argument('--multi-user', help='Run user agent in multi user mode', action='store_false', default=True, dest='single_user') parser.add_argument('-p', '--provider', help='specify a provider for mutli-user mode', metavar='<provider host>', default=None, dest='provider') parser.add_argument('--banner', help='banner file to show on login screen') + parser.add_argument('--manhole', help='Run an interactive Python shell on port 8008', action='store_true', default=False, dest='manhole') args = parser.parse_args() |