From f97c144869fa4cb8123d0a12ec9503ee0a8cf485 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Fri, 18 Mar 2011 09:38:51 +1300 Subject: [PATCH] Client playback shortcut in mitmproxy can now be used to interrupt a current client playback. --- libmproxy/console.py | 25 ++++++++++++++++++++----- libmproxy/flow.py | 3 +++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/libmproxy/console.py b/libmproxy/console.py index 78e810357..4c53ef011 100644 --- a/libmproxy/console.py +++ b/libmproxy/console.py @@ -1298,11 +1298,22 @@ class ConsoleMaster(flow.FlowMaster): if k == "?": self.view_help() elif k == "c": - self.path_prompt( - "Client replay: ", - self.state.last_saveload, - self.client_playback_path - ) + if not self.client_playback: + self.path_prompt( + "Client replay: ", + self.state.last_saveload, + self.client_playback_path + ) + else: + self.prompt_onekey( + "Stop current client replay?", + ( + ("yes", "y"), + ("no", "n"), + ), + self.stop_client_playback_prompt, + ) + k = None elif k == "l": self.prompt("Limit: ", self.state.limit_txt, self.set_limit) @@ -1384,6 +1395,10 @@ class ConsoleMaster(flow.FlowMaster): except (Stop, KeyboardInterrupt): pass + def stop_client_playback_prompt(self, a): + if a != "n": + self.stop_client_playback() + def quit(self, a): if a != "n": raise Stop diff --git a/libmproxy/flow.py b/libmproxy/flow.py index 62fba6abb..ea5e6cb87 100644 --- a/libmproxy/flow.py +++ b/libmproxy/flow.py @@ -464,6 +464,9 @@ class FlowMaster(controller.Master): """ self.client_playback = ClientPlaybackState(flows, exit) + def stop_client_playback(self): + self.client_playback = None + def start_server_playback(self, flows, kill, headers, exit): """ flows: A list of flows.