aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2018-02-24 17:19:42 +1300
committerAldo Cortesi <aldo@nullcube.com>2018-02-24 18:33:15 +1300
commitf49aae312fb0df3c4dd484c6790c8a558fe540e8 (patch)
treefd9ea9513b09ed8c62eedc47e380ba051af0fd58 /mitmproxy
parent93c49c47ae42a89c3c6b30988ea553df4ff19ab4 (diff)
downloadmitmproxy-f49aae312fb0df3c4dd484c6790c8a558fe540e8.tar.gz
mitmproxy-f49aae312fb0df3c4dd484c6790c8a558fe540e8.tar.bz2
mitmproxy-f49aae312fb0df3c4dd484c6790c8a558fe540e8.zip
Move intercept options to addon
As part of this, we zap an un-needed console command and use a boolean toggle setter instead. Also remove an ancient regression test that breaks encapsulation.
Diffstat (limited to 'mitmproxy')
-rw-r--r--mitmproxy/addons/intercept.py13
-rw-r--r--mitmproxy/options.py12
-rw-r--r--mitmproxy/tools/console/consoleaddons.py9
-rw-r--r--mitmproxy/tools/console/defaultkeys.py2
4 files changed, 14 insertions, 22 deletions
diff --git a/mitmproxy/addons/intercept.py b/mitmproxy/addons/intercept.py
index 9e1a283e..d39d1962 100644
--- a/mitmproxy/addons/intercept.py
+++ b/mitmproxy/addons/intercept.py
@@ -1,3 +1,5 @@
+import typing
+
from mitmproxy import flowfilter
from mitmproxy import exceptions
from mitmproxy import ctx
@@ -7,6 +9,17 @@ class Intercept:
def __init__(self):
self.filt = None
+ def load(self, loader):
+ loader.add_option(
+ "intercept_active", bool, False,
+ "Intercept toggle"
+ )
+
+ loader.add_option(
+ "intercept", typing.Optional[str], None,
+ "Intercept filter expression."
+ )
+
def configure(self, updated):
if "intercept" in updated:
if not ctx.options.intercept:
diff --git a/mitmproxy/options.py b/mitmproxy/options.py
index 139b197f..05332b3f 100644
--- a/mitmproxy/options.py
+++ b/mitmproxy/options.py
@@ -58,8 +58,6 @@ class Options(optmanager.OptManager):
# because they're used by more than one addon, or because they're
# embedded in the core code somehow.
default_contentview = None # type: str
- intercept = None # type: Optional[str]
- intercept_active = None # type: bool
proxyauth = None # type: Optional[str]
showhost = None # type: bool
verbosity = None # type: str
@@ -252,16 +250,6 @@ class Options(optmanager.OptManager):
)
self.add_option(
- "intercept_active", bool, False,
- "Intercept toggle"
- )
-
- self.add_option(
- "intercept", Optional[str], None,
- "Intercept filter expression."
- )
-
- self.add_option(
"view_filter", Optional[str], None,
"Limit which flows are displayed."
)
diff --git a/mitmproxy/tools/console/consoleaddons.py b/mitmproxy/tools/console/consoleaddons.py
index c73eda42..9856e80f 100644
--- a/mitmproxy/tools/console/consoleaddons.py
+++ b/mitmproxy/tools/console/consoleaddons.py
@@ -110,15 +110,6 @@ class ConsoleAddon:
"""
return ["single", "vertical", "horizontal"]
- @command.command("console.intercept.toggle")
- def intercept_toggle(self) -> None:
- """
- Toggles interception on/off leaving intercept filters intact.
- """
- ctx.options.update(
- 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 c7876288..7f65c1f7 100644
--- a/mitmproxy/tools/console/defaultkeys.py
+++ b/mitmproxy/tools/console/defaultkeys.py
@@ -26,7 +26,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.intercept.toggle", ["global"], "Toggle intercept")
+ km.add("I", "set intercept_active=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")