diff options
Diffstat (limited to 'mitmproxy/tools/web/master.py')
-rw-r--r-- | mitmproxy/tools/web/master.py | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/mitmproxy/tools/web/master.py b/mitmproxy/tools/web/master.py index 4c597f0e..e2c60d94 100644 --- a/mitmproxy/tools/web/master.py +++ b/mitmproxy/tools/web/master.py @@ -2,6 +2,8 @@ import webbrowser import tornado.httpserver import tornado.ioloop +from tornado.platform.asyncio import AsyncIOMainLoop + from mitmproxy import addons from mitmproxy import log from mitmproxy import master @@ -102,36 +104,22 @@ class WebMaster(master.Master): ) def run(self): # pragma: no cover - + AsyncIOMainLoop().install() iol = tornado.ioloop.IOLoop.instance() - http_server = tornado.httpserver.HTTPServer(self.app) http_server.listen(self.options.web_port, self.options.web_iface) - - iol.add_callback(self.start) - tornado.ioloop.PeriodicCallback(lambda: self.tick(timeout=0), 5).start() - web_url = "http://{}:{}/".format(self.options.web_iface, self.options.web_port) - self.add_log( - "Web server listening at {}".format(web_url), - "info" + self.log.info( + "Web server listening at {}".format(web_url), ) - + # FIXME: This should be in an addon hooked to the "running" event, not in master if self.options.web_open_browser: success = open_browser(web_url) if not success: - self.add_log( + self.log.info( "No web browser found. Please open a browser and point it to {}".format(web_url), - "info" ) - try: - iol.start() - except KeyboardInterrupt: - self.shutdown() - - def shutdown(self): - tornado.ioloop.IOLoop.instance().stop() - super().shutdown() + self.run_loop(iol.start) def open_browser(url: str) -> bool: |