From 0434988ade38921caa8b262c1079f58006367a4c Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 19 Feb 2012 00:32:20 +1300 Subject: [PATCH] Add duplicate to connection view, and rename to "D". --- libmproxy/console/__init__.py | 4 +--- libmproxy/console/connlist.py | 9 +++++---- libmproxy/console/connview.py | 6 ++++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/libmproxy/console/__init__.py b/libmproxy/console/__init__.py index 6fc37a471..ca80d013a 100644 --- a/libmproxy/console/__init__.py +++ b/libmproxy/console/__init__.py @@ -516,9 +516,7 @@ class ConsoleMaster(flow.FlowMaster): def focus_current(self): if self.currentflow: try: - ids = [id(i) for i in self.state.view] - idx = ids.index(id(self.currentflow)) - self.conn_list_view.set_focus(idx) + self.conn_list_view.set_focus(self.state.index(self.currentflow)) except (IndexError, ValueError): pass diff --git a/libmproxy/console/connlist.py b/libmproxy/console/connlist.py index 177c64e70..f54b80614 100644 --- a/libmproxy/console/connlist.py +++ b/libmproxy/console/connlist.py @@ -8,10 +8,10 @@ def _mkhelp(): ("a", "accept this intercepted connection"), ("C", "clear connection list or eventlog"), ("d", "delete flow"), + ("D", "duplicate flow"), ("e", "toggle eventlog"), ("l", "set limit filter pattern"), ("L", "load saved flows"), - ("p", "duplicate flow"), ("r", "replay request"), ("R", "revert changes to request"), ("w", "save all flows matching current limit"), @@ -102,6 +102,10 @@ class ConnectionItem(common.WWrap): self.flow.kill(self.master) self.state.delete_flow(self.flow) self.master.sync_list_view() + elif key == "D": + f = self.master.duplicate_flow(self.flow) + self.master.currentflow = f + self.master.focus_current() elif key == "l": self.master.prompt("Limit: ", self.state.limit_txt, self.master.set_limit) self.master.sync_list_view() @@ -111,9 +115,6 @@ class ConnectionItem(common.WWrap): self.state.last_saveload, self.master.load_flows_callback ) - elif key == "p": - f = self.master.duplicate_flow(self.flow) - self.master.conn_list_view.set_focus(self.state.index(f)) elif key == "r": r = self.master.replay_request(self.flow) if r: diff --git a/libmproxy/console/connview.py b/libmproxy/console/connview.py index d668bfe2d..ed038a116 100644 --- a/libmproxy/console/connview.py +++ b/libmproxy/console/connview.py @@ -10,6 +10,7 @@ def _mkhelp(): ("a", "accept this intercepted connection"), ("b", "save request/response body"), ("d", "delete flow"), + ("D", "duplicate flow"), ("e", "edit request/response"), ("m", "change body display mode"), (None, @@ -463,6 +464,11 @@ class ConnectionView(common.WWrap): f = self.flow f.kill(self.master) self.state.delete_flow(f) + elif key == "D": + f = self.master.duplicate_flow(self.flow) + self.master.view_flow(f) + self.master.currentflow = f + self.master.statusbar.message("Duplicated.") elif key == "e": if self.state.view_flow_mode == common.VIEW_FLOW_REQUEST: self.master.prompt_onekey(