aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2018-02-24 15:45:12 +1300
committerAldo Cortesi <aldo@nullcube.com>2018-02-24 15:45:12 +1300
commit704c1db1b7aa25c4ee6371bec811e92409b92398 (patch)
treec0cb32622569af0e0dc56e85e7c20486e6eaa05b /mitmproxy
parent12633adeb9cbe3a81df2f6dfd9b739eae26bdcba (diff)
downloadmitmproxy-704c1db1b7aa25c4ee6371bec811e92409b92398.tar.gz
mitmproxy-704c1db1b7aa25c4ee6371bec811e92409b92398.tar.bz2
mitmproxy-704c1db1b7aa25c4ee6371bec811e92409b92398.zip
addon options: setheaders, stickyauth
Diffstat (limited to 'mitmproxy')
-rw-r--r--mitmproxy/addons/setheaders.py11
-rw-r--r--mitmproxy/addons/stickyauth.py8
-rw-r--r--mitmproxy/options.py12
-rw-r--r--mitmproxy/test/taddons.py2
4 files changed, 20 insertions, 13 deletions
diff --git a/mitmproxy/addons/setheaders.py b/mitmproxy/addons/setheaders.py
index d4d16e40..3517f70f 100644
--- a/mitmproxy/addons/setheaders.py
+++ b/mitmproxy/addons/setheaders.py
@@ -1,3 +1,5 @@
+import typing
+
from mitmproxy import exceptions
from mitmproxy import flowfilter
from mitmproxy import ctx
@@ -44,6 +46,15 @@ class SetHeaders:
def __init__(self):
self.lst = []
+ def load(self, loader):
+ loader.add_option(
+ "setheaders", typing.Sequence[str], [],
+ """
+ Header set pattern of the form "/pattern/header/value", where the
+ separator can be any character.
+ """
+ )
+
def configure(self, updated):
if "setheaders" in updated:
self.lst = []
diff --git a/mitmproxy/addons/stickyauth.py b/mitmproxy/addons/stickyauth.py
index 24831d5b..ab0599ee 100644
--- a/mitmproxy/addons/stickyauth.py
+++ b/mitmproxy/addons/stickyauth.py
@@ -1,3 +1,5 @@
+import typing
+
from mitmproxy import exceptions
from mitmproxy import flowfilter
from mitmproxy import ctx
@@ -8,6 +10,12 @@ class StickyAuth:
self.flt = None
self.hosts = {}
+ def load(self, loader):
+ loader.add_option(
+ "stickyauth", typing.Optional[str], None,
+ "Set sticky auth filter. Matched against requests."
+ )
+
def configure(self, updated):
if "stickyauth" in updated:
if ctx.options.stickyauth:
diff --git a/mitmproxy/options.py b/mitmproxy/options.py
index e42ff0e9..bf2012d7 100644
--- a/mitmproxy/options.py
+++ b/mitmproxy/options.py
@@ -67,7 +67,6 @@ class Options(optmanager.OptManager):
view_filter = None # type: Optional[str]
# FIXME: Options that should be uncomplicated to migrate to addons
- setheaders = None # type: Sequence[str]
stickyauth = None # type: Optional[str]
stickycookie = None # type: Optional[str]
stream_large_bodies = None # type: Optional[str]
@@ -91,21 +90,10 @@ class Options(optmanager.OptManager):
"Use the Host header to construct URLs for display."
)
self.add_option(
- "setheaders", Sequence[str], [],
- """
- Header set pattern of the form "/pattern/header/value", where the
- separator can be any character.
- """
- )
- self.add_option(
"stickycookie", Optional[str], None,
"Set sticky cookie filter. Matched against requests."
)
self.add_option(
- "stickyauth", Optional[str], None,
- "Set sticky auth filter. Matched against requests."
- )
- self.add_option(
"stream_large_bodies", Optional[str], None,
"""
Stream data to the client if response body exceeds the given
diff --git a/mitmproxy/test/taddons.py b/mitmproxy/test/taddons.py
index 7efa2eaf..5930e414 100644
--- a/mitmproxy/test/taddons.py
+++ b/mitmproxy/test/taddons.py
@@ -68,7 +68,7 @@ class context:
self.wrapped = None
for a in addons:
- self.master.addons.register(a)
+ self.master.addons.add(a)
def ctx(self):
"""