diff --git a/mitmproxy/console/options.py b/mitmproxy/console/options.py index 2205bf6f1..f7fb2f904 100644 --- a/mitmproxy/console/options.py +++ b/mitmproxy/console/options.py @@ -94,7 +94,7 @@ class Options(urwid.WidgetWrap): select.Option( "Don't Verify SSL/TLS Certificates", "V", - lambda: master.server.config.ssl_insecure, + lambda: master.options.ssl_insecure, master.options.toggler("ssl_insecure") ), @@ -140,15 +140,17 @@ class Options(urwid.WidgetWrap): title = urwid.Text("Options") title = urwid.Padding(title, align="left", width=("relative", 100)) title = urwid.AttrWrap(title, "heading") - self._w = urwid.Frame( + w = urwid.Frame( self.lb, header = title ) + super(Options, self).__init__(w) + self.master.loop.widget.footer.update("") signals.update_settings.connect(self.sig_update_settings) - master.options.changed.connect(lambda sender, updated: self.sig_update_settings(sender)) + master.options.changed.connect(self.sig_update_settings) - def sig_update_settings(self, sender): + def sig_update_settings(self, sender, updated=None): self.lb.walker._modified() def keypress(self, size, key): diff --git a/mitmproxy/console/statusbar.py b/mitmproxy/console/statusbar.py index 9f0dda43a..43d68d51a 100644 --- a/mitmproxy/console/statusbar.py +++ b/mitmproxy/console/statusbar.py @@ -124,10 +124,10 @@ class StatusBar(urwid.WidgetWrap): super(StatusBar, self).__init__(urwid.Pile([self.ib, self.master.ab])) signals.update_settings.connect(self.sig_update_settings) signals.flowlist_change.connect(self.sig_update_settings) - master.options.changed.connect(lambda sender, updated: self.sig_update_settings(sender)) + master.options.changed.connect(self.sig_update_settings) self.redraw() - def sig_update_settings(self, sender): + def sig_update_settings(self, sender, updated=None): self.redraw() def keypress(self, *args, **kwargs): diff --git a/mitmproxy/optmanager.py b/mitmproxy/optmanager.py index 140c7ca8d..92d32b2d4 100644 --- a/mitmproxy/optmanager.py +++ b/mitmproxy/optmanager.py @@ -86,7 +86,10 @@ class OptManager(object): """ if attr not in self._opts: raise KeyError("No such option: %s" % attr) - return lambda x: self.__setattr__(attr, x) + + def setter(x): + setattr(self, attr, x) + return setter def toggler(self, attr): """ @@ -95,7 +98,10 @@ class OptManager(object): """ if attr not in self._opts: raise KeyError("No such option: %s" % attr) - return lambda: self.__setattr__(attr, not getattr(self, attr)) + + def toggle(): + setattr(self, attr, not getattr(self, attr)) + return toggle def __repr__(self): options = pprint.pformat(self._opts, indent=4).strip(" {}")