diff options
| -rw-r--r-- | mitmproxy/addons/intercept.py | 4 | ||||
| -rw-r--r-- | mitmproxy/options.py | 5 | ||||
| -rw-r--r-- | mitmproxy/tools/console/consoleaddons.py | 7 | ||||
| -rw-r--r-- | mitmproxy/tools/console/defaultkeys.py | 1 | ||||
| -rw-r--r-- | mitmproxy/tools/console/statusbar.py | 2 | ||||
| -rw-r--r-- | mitmproxy/tools/web/app.py | 1 | 
6 files changed, 19 insertions, 1 deletions
| diff --git a/mitmproxy/addons/intercept.py b/mitmproxy/addons/intercept.py index ac8c4c88..bac07a91 100644 --- a/mitmproxy/addons/intercept.py +++ b/mitmproxy/addons/intercept.py @@ -11,12 +11,14 @@ class Intercept:          if "intercept" in updated:              if not ctx.options.intercept:                  self.filt = None +                ctx.options.intercept_active = False                  return              self.filt = flowfilter.parse(ctx.options.intercept)              if not self.filt:                  raise exceptions.OptionsError(                      "Invalid interception filter: %s" % ctx.options.intercept                  ) +            ctx.options.intercept_active = True      def process_flow(self, f):          if self.filt: @@ -24,7 +26,7 @@ class Intercept:                  self.filt(f),                  not f.request.is_replay,              ]) -            if should_intercept: +            if should_intercept and ctx.options.intercept_active == True:                  f.intercept()      # Handlers diff --git a/mitmproxy/options.py b/mitmproxy/options.py index 954db7e8..8102efe7 100644 --- a/mitmproxy/options.py +++ b/mitmproxy/options.py @@ -377,6 +377,11 @@ class Options(optmanager.OptManager):          )          self.add_option( +                "intercept_active", bool, False, +                "Intercept toggle" +        ) + +        self.add_option(              "intercept", Optional[str], None,              "Intercept filter expression."          ) diff --git a/mitmproxy/tools/console/consoleaddons.py b/mitmproxy/tools/console/consoleaddons.py index a65f0afe..0b0993c8 100644 --- a/mitmproxy/tools/console/consoleaddons.py +++ b/mitmproxy/tools/console/consoleaddons.py @@ -68,6 +68,13 @@ class ConsoleAddon:          """          return ["single", "vertical", "horizontal"] +    @command.command("intercept_toggle") +    def intercept_toggle(self) -> None: +        """ +            Toggles interception on/off leaving intercept filters intact. +        """ +        ctx.options.intercept_active = not ctx.options.intercept_active +      @command.command("console.layout.cycle")      def layout_cycle(self) -> None:          """ diff --git a/mitmproxy/tools/console/defaultkeys.py b/mitmproxy/tools/console/defaultkeys.py index 105be2be..4634b1e2 100644 --- a/mitmproxy/tools/console/defaultkeys.py +++ b/mitmproxy/tools/console/defaultkeys.py @@ -24,6 +24,7 @@ def map(km):      km.add("ctrl f", "console.nav.pagedown", ["global"], "Page down")      km.add("ctrl b", "console.nav.pageup", ["global"], "Page up") +    km.add("I", "console.command intercept_toggle", ["global"], "Toggle intercept")      km.add("i", "console.command set intercept=", ["global"], "Set intercept")      km.add("W", "console.command set save_stream_file=", ["global"], "Stream to file")      km.add("A", "flow.resume @all", ["flowlist", "flowview"], "Resume all intercepted flows") diff --git a/mitmproxy/tools/console/statusbar.py b/mitmproxy/tools/console/statusbar.py index a37ecbd8..f0d59639 100644 --- a/mitmproxy/tools/console/statusbar.py +++ b/mitmproxy/tools/console/statusbar.py @@ -178,6 +178,8 @@ class StatusBar(urwid.WidgetWrap):              r.append(("heading_key", "T"))              r.append("CP:%d]" % len(self.master.options.tcp_hosts))          if self.master.options.intercept: +            if self.master.options.intercept_active: +                r.append("I ")              r.append("[")              r.append(("heading_key", "i"))              r.append(":%s]" % self.master.options.intercept) diff --git a/mitmproxy/tools/web/app.py b/mitmproxy/tools/web/app.py index 9a447fe7..2a6f6c9e 100644 --- a/mitmproxy/tools/web/app.py +++ b/mitmproxy/tools/web/app.py @@ -410,6 +410,7 @@ class Settings(RequestHandler):          self.write(dict(              version=version.VERSION,              mode=str(self.master.options.mode), +            intercept_active=self.master.options.intercept_active,              intercept=self.master.options.intercept,              showhost=self.master.options.showhost,              upstream_cert=self.master.options.upstream_cert, | 
