From c9a0fe6a0e6d70fa2aea1b8dc337609a9439ade1 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Wed, 13 Jul 2016 19:05:32 +1200 Subject: [PATCH] Show how options integrates with console This is not functional at the moment, because all mutable options are still on master. --- mitmproxy/console/master.py | 8 ++++++++ mitmproxy/console/options.py | 1 + mitmproxy/console/statusbar.py | 1 + mitmproxy/web/master.py | 1 + 4 files changed, 11 insertions(+) diff --git a/mitmproxy/console/master.py b/mitmproxy/console/master.py index 99af07225..1daf11270 100644 --- a/mitmproxy/console/master.py +++ b/mitmproxy/console/master.py @@ -217,8 +217,10 @@ class ConsoleMaster(flow.FlowMaster): def __init__(self, server, options): flow.FlowMaster.__init__(self, server, ConsoleState()) + self.stream_path = None self.options = options + self.options.errored.connect(self.options_error) if options.replacements: for i in options.replacements: @@ -298,6 +300,12 @@ class ConsoleMaster(flow.FlowMaster): self.__dict__[name] = value signals.update_settings.send(self) + def options_error(self, opts, exc): + signals.status_message.send( + message=str(exc), + expire=1 + ) + def load_script(self, command, use_reloader=True): # We default to using the reloader in the console ui. return super(ConsoleMaster, self).load_script(command, use_reloader) diff --git a/mitmproxy/console/options.py b/mitmproxy/console/options.py index 5a01c9d54..6a4b8dd6d 100644 --- a/mitmproxy/console/options.py +++ b/mitmproxy/console/options.py @@ -140,6 +140,7 @@ class Options(urwid.WidgetWrap): ) self.master.loop.widget.footer.update("") signals.update_settings.connect(self.sig_update_settings) + master.options.changed.connect(self.sig_update_settings) def sig_update_settings(self, sender): self.lb.walker._modified() diff --git a/mitmproxy/console/statusbar.py b/mitmproxy/console/statusbar.py index e576b5656..d1ab5906f 100644 --- a/mitmproxy/console/statusbar.py +++ b/mitmproxy/console/statusbar.py @@ -122,6 +122,7 @@ class StatusBar(urwid.WidgetWrap): self._w = urwid.Pile([self.ib, self.ab]) signals.update_settings.connect(self.sig_update_settings) signals.flowlist_change.connect(self.sig_update_settings) + master.options.changed.connect(self.sig_update_settings) self.redraw() def sig_update_settings(self, sender): diff --git a/mitmproxy/web/master.py b/mitmproxy/web/master.py index 2b55e74e4..008b74f83 100644 --- a/mitmproxy/web/master.py +++ b/mitmproxy/web/master.py @@ -125,6 +125,7 @@ class Options(options.Options): "wsingleuser", "whtpasswd", ] + def process_web_options(self, parser): if self.wsingleuser or self.whtpasswd: if self.wsingleuser: