diff options
author | Jurriaan Bremer <jbr@cuckoo.sh> | 2018-04-29 16:53:11 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2019-11-15 16:15:13 +0100 |
commit | a5412ab1366205cb1a2000993cb6b2c9dca28246 (patch) | |
tree | b6b5d35daea30dc1422143703ffb0f829d25c988 | |
parent | be2865cd7972ed0bdb5e902ae4284f86d773bf31 (diff) | |
download | mitmproxy-a5412ab1366205cb1a2000993cb6b2c9dca28246.tar.gz mitmproxy-a5412ab1366205cb1a2000993cb6b2c9dca28246.tar.bz2 mitmproxy-a5412ab1366205cb1a2000993cb6b2c9dca28246.zip |
allow server replay functionality to run on a different port
By providing the "server_replay_ignore_port" configuration value we're
able to run mitmproxy in server replay mode on a different port than
the web server in the flows was originally running. This is also useful
in case multiple ports are present in a flow (I suspect).
-rw-r--r-- | mitmproxy/addons/serverplayback.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/mitmproxy/addons/serverplayback.py b/mitmproxy/addons/serverplayback.py index 51ba60b4..0818696f 100644 --- a/mitmproxy/addons/serverplayback.py +++ b/mitmproxy/addons/serverplayback.py @@ -68,6 +68,13 @@ class ServerPlayback: to replay. """ ) + loader.add_option( + "server_replay_ignore_port", bool, False, + """ + Ignore request's destination port while searching for a saved flow + to replay. + """ + ) @command.command("replay.server") def load_flows(self, flows: typing.Sequence[flow.Flow]) -> None: @@ -110,7 +117,7 @@ class ServerPlayback: _, _, path, _, query, _ = urllib.parse.urlparse(r.url) queriesArray = urllib.parse.parse_qsl(query, keep_blank_values=True) - key: typing.List[typing.Any] = [str(r.port), str(r.scheme), str(r.method), str(path)] + key: typing.List[typing.Any] = [str(r.scheme), str(r.method), str(path)] if not ctx.options.server_replay_ignore_content: if ctx.options.server_replay_ignore_payload_params and r.multipart_form: key.extend( @@ -129,6 +136,8 @@ class ServerPlayback: if not ctx.options.server_replay_ignore_host: key.append(r.host) + if not ctx.options.server_replay_ignore_port: + key.append(r.port) filtered = [] ignore_params = ctx.options.server_replay_ignore_params or [] |