diff --git a/libmproxy/console/__init__.py b/libmproxy/console/__init__.py index 196e71c70..69a50f182 100644 --- a/libmproxy/console/__init__.py +++ b/libmproxy/console/__init__.py @@ -372,11 +372,13 @@ class ConsoleMaster(flow.FlowMaster): sys.exit(1) def run_script_once(self, path, f): + if not path: + return ret = self.get_script(path) if ret[0]: self.statusbar.message(ret[0]) + return s = ret[1] - if f.request: s.run("request", f) if f.response: @@ -781,16 +783,6 @@ class ConsoleMaster(flow.FlowMaster): self.set_intercept ) self.sync_list_view() - elif k == "m": - self.prompt_onekey( - "View", - ( - ("raw", "r"), - ("pretty", "p"), - ("hex", "h"), - ), - self.changeview - ) elif k == "Q": raise Stop elif k == "q": diff --git a/libmproxy/console/connlist.py b/libmproxy/console/connlist.py index 1d34fba9e..d9ef258bd 100644 --- a/libmproxy/console/connlist.py +++ b/libmproxy/console/connlist.py @@ -4,12 +4,15 @@ import common def _mkhelp(): text = [] keys = [ + ("A", "accept all intercepted connections"), + ("a", "accept this intercepted connection"), ("C", "clear connection list or eventlog"), ("d", "delete connection from view"), ("v", "toggle eventlog"), ("X", "kill and delete connection, even if it's mid-intercept"), ("tab", "tab between eventlog and connection list"), ("enter", "view connection"), + ("|", "run script on this flow"), ] text.extend(common.format_keyvals(keys, key="key", val="text", indent=4)) return text @@ -117,10 +120,13 @@ class ConnectionItem(common.WWrap): self.master.view_flow(self.flow) elif key == "|": self.master.path_prompt( - "Send flow to script: ", self.state.last_script, - self.master.run_script_once, self.flow + "Send flow to script: ", + self.state.last_script, + self.master.run_script_once, + self.flow ) - return key + else: + return key class ConnectionListView(urwid.ListWalker): diff --git a/libmproxy/console/connview.py b/libmproxy/console/connview.py index f6d24d5e9..49418d01a 100644 --- a/libmproxy/console/connview.py +++ b/libmproxy/console/connview.py @@ -5,13 +5,29 @@ from .. import utils, encoding, flow def _mkhelp(): text = [] keys = [ + ("A", "accept all intercepted connections"), + ("a", "accept this intercepted connection"), ("b", "save request/response body"), ("e", "edit request/response"), + ("m", "change body display mode"), + (None, + common.highlight_key("raw", "r") + + [("text", ": raw data")] + ), + (None, + common.highlight_key("pretty", "p") + + [("text", ": pretty-print XML, HTML and JSON")] + ), + (None, + common.highlight_key("hex", "h") + + [("text", ": hex dump")] + ), ("p", "previous flow"), ("v", "view body in external viewer"), ("z", "encode/decode a request/response"), ("tab", "toggle request/response view"), ("space", "next flow"), + ("|", "run script on this flow"), ] text.extend(common.format_keyvals(keys, key="key", val="text", indent=4)) return text @@ -433,6 +449,17 @@ class ConnectionView(common.WWrap): self.edit ) key = None + elif key == "m": + self.master.prompt_onekey( + "View", + ( + ("raw", "r"), + ("pretty", "p"), + ("hex", "h"), + ), + self.master.changeview + ) + key = None elif key == "p": self.view_prev_flow(self.flow) elif key == "r": @@ -490,7 +517,8 @@ class ConnectionView(common.WWrap): conn ) self.master.refresh_connection(self.flow) - return key + else: + return key def encode_callback(self, key, conn): encoding_map = { diff --git a/libmproxy/console/help.py b/libmproxy/console/help.py index b2eafbf0e..0c710c7b4 100644 --- a/libmproxy/console/help.py +++ b/libmproxy/console/help.py @@ -28,28 +28,12 @@ class HelpView(urwid.ListBox): text.append(("head", "\n\nGlobal keys:\n")) keys = [ - ("A", "accept all intercepted connections"), - ("a", "accept this intercepted connection"), ("c", "client replay"), ("i", "set interception pattern"), ("j, k", "up, down"), ("l", "set limit filter pattern"), ("L", "load saved flows"), - ("m", "change body display mode"), - (None, - common.highlight_key("raw", "r") + - [("text", ": raw data")] - ), - (None, - common.highlight_key("pretty", "p") + - [("text", ": pretty-print XML, HTML and JSON")] - ), - (None, - common.highlight_key("hex", "h") + - [("text", ": hex dump")] - ), - ("o", "toggle options:"), (None, common.highlight_key("anticache", "a") + @@ -78,7 +62,6 @@ class HelpView(urwid.ListBox): ("u", "set sticky auth expression"), ("w", "save all flows matching current limit"), ("W", "save this flow"), - ("|", "run script on this flow"), ("space", "page down"), ("pg up/down", "page up/down"), ]