diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2018-02-24 15:45:12 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2018-02-24 15:45:12 +1300 |
commit | 704c1db1b7aa25c4ee6371bec811e92409b92398 (patch) | |
tree | c0cb32622569af0e0dc56e85e7c20486e6eaa05b /mitmproxy | |
parent | 12633adeb9cbe3a81df2f6dfd9b739eae26bdcba (diff) | |
download | mitmproxy-704c1db1b7aa25c4ee6371bec811e92409b92398.tar.gz mitmproxy-704c1db1b7aa25c4ee6371bec811e92409b92398.tar.bz2 mitmproxy-704c1db1b7aa25c4ee6371bec811e92409b92398.zip |
addon options: setheaders, stickyauth
Diffstat (limited to 'mitmproxy')
-rw-r--r-- | mitmproxy/addons/setheaders.py | 11 | ||||
-rw-r--r-- | mitmproxy/addons/stickyauth.py | 8 | ||||
-rw-r--r-- | mitmproxy/options.py | 12 | ||||
-rw-r--r-- | mitmproxy/test/taddons.py | 2 |
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): """ |