diff options
Diffstat (limited to 'libmproxy/web')
-rw-r--r-- | libmproxy/web/__init__.py | 12 | ||||
-rw-r--r-- | libmproxy/web/app.py | 18 |
2 files changed, 30 insertions, 0 deletions
diff --git a/libmproxy/web/__init__.py b/libmproxy/web/__init__.py index 815142bb..99b190aa 100644 --- a/libmproxy/web/__init__.py +++ b/libmproxy/web/__init__.py @@ -2,6 +2,7 @@ import tornado.ioloop import tornado.httpserver from .. import controller, utils, flow, script, proxy +import app class Stop(Exception): @@ -40,6 +41,10 @@ class Options(object): "verbosity", "wfile", "nopop", + + "wdebug", + "wport", + "wiface", ] def __init__(self, **kwargs): @@ -52,6 +57,7 @@ class Options(object): class WebMaster(flow.FlowMaster): def __init__(self, server, options): + self.options = options flow.FlowMaster.__init__(self, server, WebState()) def tick(self): @@ -63,6 +69,12 @@ class WebMaster(flow.FlowMaster): controller.Channel(self.masterq, self.should_exit) ) iol = tornado.ioloop.IOLoop.instance() + + http_server = tornado.httpserver.HTTPServer( + app.Application(self.options.wdebug) + ) + http_server.listen(self.options.wport) + tornado.ioloop.PeriodicCallback(self.tick, 5).start() try: iol.start() diff --git a/libmproxy/web/app.py b/libmproxy/web/app.py new file mode 100644 index 00000000..7c26c29d --- /dev/null +++ b/libmproxy/web/app.py @@ -0,0 +1,18 @@ + +import os.path +import tornado.web + + +class Application(tornado.web.Application): + def __init__(self, debug): + handlers = [ + ] + settings = dict( + template_path=os.path.join(os.path.dirname(__file__), "templates"), + static_path=os.path.join(os.path.dirname(__file__), "static"), + xsrf_cookies=True, + cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__", + debug=debug, + ) + tornado.web.Application.__init__(self, handlers, **settings) + |