From b0213a2c0ed33c9acc62ef3673d5c5cd8e068761 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sat, 10 Sep 2016 09:48:41 +1200 Subject: [PATCH] options.kill -> options.replay_kill_extra --- mitmproxy/builtins/serverplayback.py | 3 +-- mitmproxy/cmdline.py | 6 +++--- mitmproxy/console/flowlist.py | 4 ++-- mitmproxy/console/options.py | 4 ++-- mitmproxy/console/statusbar.py | 2 +- mitmproxy/options.py | 4 ++-- test/mitmproxy/builtins/test_serverplayback.py | 2 +- test/mitmproxy/console/test_master.py | 2 +- test/mitmproxy/test_dump.py | 8 ++++---- 9 files changed, 17 insertions(+), 18 deletions(-) diff --git a/mitmproxy/builtins/serverplayback.py b/mitmproxy/builtins/serverplayback.py index be82cad95..1cbb9e15c 100644 --- a/mitmproxy/builtins/serverplayback.py +++ b/mitmproxy/builtins/serverplayback.py @@ -101,7 +101,6 @@ class ServerPlayback(object): # prefixed with serverplayback_ where appropriate, and playback_ where # they're shared with client playback. # - # options.kill # options.rheaders, # options.nopop, # options.replay_ignore_params, @@ -125,7 +124,7 @@ class ServerPlayback(object): if not self.flowmap and not self.options.keepserving: self.final_flow = f self.stop = True - elif self.options.kill: + elif self.options.replay_kill_extra: ctx.log.warn( "server_playback: killed non-replay request {}".format( f.request.url diff --git a/mitmproxy/cmdline.py b/mitmproxy/cmdline.py index d888b93f0..2c29344fa 100644 --- a/mitmproxy/cmdline.py +++ b/mitmproxy/cmdline.py @@ -218,7 +218,7 @@ def get_common_options(args): anticache=args.anticache, anticomp=args.anticomp, client_replay=args.client_replay, - kill=args.kill, + replay_kill_extra=args.replay_kill_extra, no_server=args.no_server, refresh_server_playback=not args.norefresh, rheaders=args.rheaders, @@ -594,8 +594,8 @@ def server_replay(parser): help="Replay server responses from a saved file." ) group.add_argument( - "-k", "--kill", - action="store_true", dest="kill", default=False, + "-k", "--replay-kill-extra", + action="store_true", dest="replay_kill_extra", default=False, help="Kill extra requests during replay." ) group.add_argument( diff --git a/mitmproxy/console/flowlist.py b/mitmproxy/console/flowlist.py index 11e8fc994..1358495d2 100644 --- a/mitmproxy/console/flowlist.py +++ b/mitmproxy/console/flowlist.py @@ -148,7 +148,7 @@ class ConnectionItem(urwid.WidgetWrap): if k == "a": self.master.start_server_playback( [i.copy() for i in self.master.state.view], - self.master.options.kill, self.master.options.rheaders, + self.master.options.replay_kill_extra, self.master.options.rheaders, False, self.master.options.nopop, self.master.options.replay_ignore_params, self.master.options.replay_ignore_content, @@ -158,7 +158,7 @@ class ConnectionItem(urwid.WidgetWrap): elif k == "t": self.master.start_server_playback( [self.flow.copy()], - self.master.options.kill, self.master.options.rheaders, + self.master.options.replay_kill_extra, self.master.options.rheaders, False, self.master.options.nopop, self.master.options.replay_ignore_params, self.master.options.replay_ignore_content, diff --git a/mitmproxy/console/options.py b/mitmproxy/console/options.py index f7fb2f904..1c59870b5 100644 --- a/mitmproxy/console/options.py +++ b/mitmproxy/console/options.py @@ -114,7 +114,7 @@ class Options(urwid.WidgetWrap): select.Option( "Kill Extra", "x", - lambda: master.options.kill, + lambda: master.options.replay_kill_extra, master.options.toggler("kill") ), select.Option( @@ -165,7 +165,7 @@ class Options(urwid.WidgetWrap): anticomp = False, ignore_hosts = (), tcp_hosts = (), - kill = False, + replay_kill_extra = False, no_upstream_cert = False, refresh_server_playback = True, replacements = [], diff --git a/mitmproxy/console/statusbar.py b/mitmproxy/console/statusbar.py index 6c4cc8b52..28f29f03d 100644 --- a/mitmproxy/console/statusbar.py +++ b/mitmproxy/console/statusbar.py @@ -191,7 +191,7 @@ class StatusBar(urwid.WidgetWrap): opts.append("showhost") if not self.master.options.refresh_server_playback: opts.append("norefresh") - if self.master.options.kill: + if self.master.options.replay_kill_extra: opts.append("killextra") if self.master.options.no_upstream_cert: opts.append("no-upstream-cert") diff --git a/mitmproxy/options.py b/mitmproxy/options.py index c49748393..3a1831936 100644 --- a/mitmproxy/options.py +++ b/mitmproxy/options.py @@ -30,7 +30,7 @@ class Options(optmanager.OptManager): anticache=False, # type: bool anticomp=False, # type: bool client_replay=None, # type: Optional[str] - kill=False, # type: bool + replay_kill_extra=False, # type: bool keepserving=True, # type: bool no_server=False, # type: bool nopop=False, # type: bool @@ -89,7 +89,7 @@ class Options(optmanager.OptManager): self.anticomp = anticomp self.client_replay = client_replay self.keepserving = keepserving - self.kill = kill + self.replay_kill_extra = replay_kill_extra self.no_server = no_server self.nopop = nopop self.refresh_server_playback = refresh_server_playback diff --git a/test/mitmproxy/builtins/test_serverplayback.py b/test/mitmproxy/builtins/test_serverplayback.py index 72070c7a6..58c788fd3 100644 --- a/test/mitmproxy/builtins/test_serverplayback.py +++ b/test/mitmproxy/builtins/test_serverplayback.py @@ -270,7 +270,7 @@ class TestServerPlayback: def test_server_playback_kill(self): state = flow.State() s = serverplayback.ServerPlayback() - o = options.Options(refresh_server_playback = True, kill=True) + o = options.Options(refresh_server_playback = True, replay_kill_extra=True) m = mastertest.RecordingMaster(o, None, state) m.addons.add(o, s) diff --git a/test/mitmproxy/console/test_master.py b/test/mitmproxy/console/test_master.py index fcb87e1b4..8388a6bdd 100644 --- a/test/mitmproxy/console/test_master.py +++ b/test/mitmproxy/console/test_master.py @@ -107,7 +107,7 @@ def test_format_keyvals(): def test_options(): - assert console.master.Options(kill=True) + assert console.master.Options(replay_kill_extra=True) class TestMaster(mastertest.MasterTest): diff --git a/test/mitmproxy/test_dump.py b/test/mitmproxy/test_dump.py index 40beeb0dc..9fd5ff57a 100644 --- a/test/mitmproxy/test_dump.py +++ b/test/mitmproxy/test_dump.py @@ -49,14 +49,14 @@ class TestDumpMaster(mastertest.MasterTest): assert "error" in o.tfile.getvalue() def test_replay(self): - o = dump.Options(server_replay=["nonexistent"], kill=True) + o = dump.Options(server_replay=["nonexistent"], replay_kill_extra=True) tutils.raises(exceptions.OptionsError, dump.DumpMaster, None, o) with tutils.tmpdir() as t: p = os.path.join(t, "rep") self.flowfile(p) - o = dump.Options(server_replay=[p], kill=True) + o = dump.Options(server_replay=[p], replay_kill_extra=True) o.verbosity = 0 o.flow_detail = 0 m = dump.DumpMaster(None, o) @@ -64,13 +64,13 @@ class TestDumpMaster(mastertest.MasterTest): self.cycle(m, b"content") self.cycle(m, b"content") - o = dump.Options(server_replay=[p], kill=False) + o = dump.Options(server_replay=[p], replay_kill_extra=False) o.verbosity = 0 o.flow_detail = 0 m = dump.DumpMaster(None, o) self.cycle(m, b"nonexistent") - o = dump.Options(client_replay=[p], kill=False) + o = dump.Options(client_replay=[p], replay_kill_extra=False) o.verbosity = 0 o.flow_detail = 0 m = dump.DumpMaster(None, o)