diff options
| author | Aldo Cortesi <aldo@nullcube.com> | 2018-02-24 15:28:43 +1300 |
|---|---|---|
| committer | Aldo Cortesi <aldo@nullcube.com> | 2018-02-24 15:28:43 +1300 |
| commit | 12633adeb9cbe3a81df2f6dfd9b739eae26bdcba (patch) | |
| tree | 43b266fbdc6e6aae904aef67fc6ea32596f44500 /mitmproxy | |
| parent | 144b559b468ac2c67e0d79fae8754ae3385f1958 (diff) | |
| download | mitmproxy-12633adeb9cbe3a81df2f6dfd9b739eae26bdcba.tar.gz mitmproxy-12633adeb9cbe3a81df2f6dfd9b739eae26bdcba.tar.bz2 mitmproxy-12633adeb9cbe3a81df2f6dfd9b739eae26bdcba.zip | |
addon options: readfile, save, script
Diffstat (limited to 'mitmproxy')
| -rw-r--r-- | mitmproxy/addons/readfile.py | 5 | ||||
| -rw-r--r-- | mitmproxy/addons/save.py | 10 | ||||
| -rw-r--r-- | mitmproxy/addons/script.py | 8 | ||||
| -rw-r--r-- | mitmproxy/options.py | 22 |
4 files changed, 23 insertions, 22 deletions
diff --git a/mitmproxy/addons/readfile.py b/mitmproxy/addons/readfile.py index 05b6c309..aaf02d01 100644 --- a/mitmproxy/addons/readfile.py +++ b/mitmproxy/addons/readfile.py @@ -11,6 +11,11 @@ class ReadFile: """ An addon that handles reading from file on startup. """ + def load(self, loader): + loader.add_option( + "rfile", typing.Optional[str], None, + "Read flows from file." + ) def load_flows(self, fo: typing.IO[bytes]) -> int: cnt = 0 diff --git a/mitmproxy/addons/save.py b/mitmproxy/addons/save.py index 44afef68..e6e98ff8 100644 --- a/mitmproxy/addons/save.py +++ b/mitmproxy/addons/save.py @@ -16,6 +16,16 @@ class Save: self.filt = None self.active_flows = set() # type: Set[flow.Flow] + def load(self, loader): + loader.add_option( + "save_stream_file", typing.Optional[str], None, + "Stream flows to file as they arrive. Prefix path with + to append." + ) + loader.add_option( + "save_stream_filter", typing.Optional[str], None, + "Filter which flows are written to file." + ) + def open_file(self, path): if path.startswith("+"): path = path[1:] diff --git a/mitmproxy/addons/script.py b/mitmproxy/addons/script.py index 0a524359..dcad943a 100644 --- a/mitmproxy/addons/script.py +++ b/mitmproxy/addons/script.py @@ -98,6 +98,14 @@ class ScriptLoader: self.is_running = False self.addons = [] + def load(self, loader): + loader.add_option( + "scripts", typing.Sequence[str], [], + """ + Execute a script. + """ + ) + def running(self): self.is_running = True diff --git a/mitmproxy/options.py b/mitmproxy/options.py index 6db2b907..e42ff0e9 100644 --- a/mitmproxy/options.py +++ b/mitmproxy/options.py @@ -67,10 +67,6 @@ class Options(optmanager.OptManager): view_filter = None # type: Optional[str] # FIXME: Options that should be uncomplicated to migrate to addons - rfile = None # type: Optional[str] - save_stream_file = None # type: Optional[str] - save_stream_filter = None # type: Optional[str] - scripts = None # type: Sequence[str] setheaders = None # type: Sequence[str] stickyauth = None # type: Optional[str] stickycookie = None # type: Optional[str] @@ -91,16 +87,6 @@ class Options(optmanager.OptManager): "Start a proxy server. Enabled by default." ) self.add_option( - "rfile", Optional[str], None, - "Read flows from file." - ) - self.add_option( - "scripts", Sequence[str], [], - """ - Execute a script. - """ - ) - self.add_option( "showhost", bool, False, "Use the Host header to construct URLs for display." ) @@ -144,14 +130,6 @@ class Options(optmanager.OptManager): "The default content view mode.", choices = [i.name.lower() for i in contentviews.views] ) - self.add_option( - "save_stream_file", Optional[str], None, - "Stream flows to file as they arrive. Prefix path with + to append." - ) - self.add_option( - "save_stream_filter", Optional[str], None, - "Filter which flows are written to file." - ) # Proxy options self.add_option( |
