From 120c8db8a413018bde60d156f480ade001b492ef Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 22 Mar 2015 16:59:11 +1300 Subject: console: refactor the way we keep global view state --- libmproxy/console/help.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'libmproxy/console/help.py') diff --git a/libmproxy/console/help.py b/libmproxy/console/help.py index 6bb49a92..109a9792 100644 --- a/libmproxy/console/help.py +++ b/libmproxy/console/help.py @@ -180,10 +180,7 @@ class HelpView(urwid.ListBox): def keypress(self, size, key): key = common.shortcuts(key) if key == "q": - self.master.statusbar = self.state[0] - self.master.body = self.state[1] - self.master.header = self.state[2] - self.master.loop.widget = self.master.make_view() + self.master.loop.widget = self.state return None elif key == "?": key = None -- cgit v1.2.3 From 08bb07653306ed0f84932391732391227ee07ba2 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sun, 22 Mar 2015 17:18:53 +1300 Subject: console: signal-based view stack, unifying mechanisms for help, flow views, etc. --- libmproxy/console/help.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libmproxy/console/help.py') diff --git a/libmproxy/console/help.py b/libmproxy/console/help.py index 109a9792..73cd8a50 100644 --- a/libmproxy/console/help.py +++ b/libmproxy/console/help.py @@ -2,7 +2,7 @@ from __future__ import absolute_import import urwid -from . import common +from . import common, signals from .. import filt, version footer = [ @@ -12,8 +12,7 @@ footer = [ class HelpView(urwid.ListBox): - def __init__(self, master, help_context, state): - self.master, self.state = master, state + def __init__(self, help_context): self.help_context = help_context or [] urwid.ListBox.__init__( self, @@ -180,7 +179,7 @@ class HelpView(urwid.ListBox): def keypress(self, size, key): key = common.shortcuts(key) if key == "q": - self.master.loop.widget = self.state + signals.pop_view_state.send(self) return None elif key == "?": key = None -- cgit v1.2.3 From ddc353955d73c83a770b6d35bfe5fc282abe243f Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Fri, 3 Apr 2015 19:10:12 +1300 Subject: Don't list all options shortcuts in help --- libmproxy/console/help.py | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) (limited to 'libmproxy/console/help.py') diff --git a/libmproxy/console/help.py b/libmproxy/console/help.py index 73cd8a50..19f17625 100644 --- a/libmproxy/console/help.py +++ b/libmproxy/console/help.py @@ -89,32 +89,7 @@ class HelpView(urwid.ListBox): common.highlight_key("amf", "f") + [("text", ": AMF (requires PyAMF)")] ), - ("o", "toggle options:"), - (None, - common.highlight_key("anticache", "a") + - [("text", ": prevent cached responses")] - ), - (None, - common.highlight_key("anticomp", "c") + - [("text", ": prevent compressed responses")] - ), - (None, - common.highlight_key("showhost", "h") + - [("text", ": use Host header for URL display")] - ), - (None, - common.highlight_key("killextra", "k") + - [("text", ": kill requests not part of server replay")] - ), - (None, - common.highlight_key("norefresh", "n") + - [("text", ": disable server replay response refresh")] - ), - (None, - common.highlight_key("upstream certs", "u") + - [("text", ": sniff cert info from upstream server")] - ), - + ("o", "options"), ("q", "quit / return to flow list"), ("Q", "quit without confirm prompt"), ("R", "edit replacement patterns"), -- cgit v1.2.3 From 15246c34039ecd1c27da52d1474910cecf6e2061 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 6 Apr 2015 17:02:51 +1200 Subject: console: ignore patterns to new options screen. --- libmproxy/console/help.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'libmproxy/console/help.py') diff --git a/libmproxy/console/help.py b/libmproxy/console/help.py index 19f17625..ea1e469c 100644 --- a/libmproxy/console/help.py +++ b/libmproxy/console/help.py @@ -37,8 +37,6 @@ class HelpView(urwid.ListBox): text.append(urwid.Text([("head", "\n\nGlobal keys:\n")])) keys = [ ("c", "client replay"), - ("H", "edit global header set patterns"), - ("I", "set ignore pattern"), ("i", "set interception pattern"), ("M", "change global default display mode"), (None, -- cgit v1.2.3 From 488adcb79ef2820d1bed59ab51728e59c7924e1f Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 6 Apr 2015 17:05:52 +1200 Subject: console: replacement patterns to new option screen --- libmproxy/console/help.py | 1 - 1 file changed, 1 deletion(-) (limited to 'libmproxy/console/help.py') diff --git a/libmproxy/console/help.py b/libmproxy/console/help.py index ea1e469c..b5f9bff3 100644 --- a/libmproxy/console/help.py +++ b/libmproxy/console/help.py @@ -90,7 +90,6 @@ class HelpView(urwid.ListBox): ("o", "options"), ("q", "quit / return to flow list"), ("Q", "quit without confirm prompt"), - ("R", "edit replacement patterns"), ("s", "add/remove scripts"), ("S", "server replay"), ("t", "set sticky cookie expression"), -- cgit v1.2.3 From acb6b5667cd3dfd972b0229be2e2e7dc62ea01ac Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 6 Apr 2015 17:11:02 +1200 Subject: console: scripts to new options screen --- libmproxy/console/help.py | 1 - 1 file changed, 1 deletion(-) (limited to 'libmproxy/console/help.py') diff --git a/libmproxy/console/help.py b/libmproxy/console/help.py index b5f9bff3..3b8fbd97 100644 --- a/libmproxy/console/help.py +++ b/libmproxy/console/help.py @@ -90,7 +90,6 @@ class HelpView(urwid.ListBox): ("o", "options"), ("q", "quit / return to flow list"), ("Q", "quit without confirm prompt"), - ("s", "add/remove scripts"), ("S", "server replay"), ("t", "set sticky cookie expression"), ("T", "set tcp proxying pattern"), -- cgit v1.2.3 From ec7572697a3877d26a5a05569c71a1487556889e Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 6 Apr 2015 17:14:32 +1200 Subject: console: default display mode to new options screen --- libmproxy/console/help.py | 49 ----------------------------------------------- 1 file changed, 49 deletions(-) (limited to 'libmproxy/console/help.py') diff --git a/libmproxy/console/help.py b/libmproxy/console/help.py index 3b8fbd97..223d2e83 100644 --- a/libmproxy/console/help.py +++ b/libmproxy/console/help.py @@ -38,55 +38,6 @@ class HelpView(urwid.ListBox): keys = [ ("c", "client replay"), ("i", "set interception pattern"), - ("M", "change global default display mode"), - (None, - common.highlight_key("automatic", "a") + - [("text", ": automatic detection")] - ), - (None, - common.highlight_key("hex", "e") + - [("text", ": Hex")] - ), - (None, - common.highlight_key("html", "h") + - [("text", ": HTML")] - ), - (None, - common.highlight_key("image", "i") + - [("text", ": Image")] - ), - (None, - common.highlight_key("javascript", "j") + - [("text", ": JavaScript")] - ), - (None, - common.highlight_key("json", "s") + - [("text", ": JSON")] - ), - (None, - common.highlight_key("css", "c") + - [("text", ": CSS")] - ), - (None, - common.highlight_key("urlencoded", "u") + - [("text", ": URL-encoded data")] - ), - (None, - common.highlight_key("raw", "r") + - [("text", ": raw data")] - ), - (None, - common.highlight_key("xml", "x") + - [("text", ": XML")] - ), - (None, - common.highlight_key("wbxml", "w") + - [("text", ": WBXML")] - ), - (None, - common.highlight_key("amf", "f") + - [("text", ": AMF (requires PyAMF)")] - ), ("o", "options"), ("q", "quit / return to flow list"), ("Q", "quit without confirm prompt"), -- cgit v1.2.3 From c4e0f9d8d77c7306f7af4509250541f4b9ea8524 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 6 Apr 2015 17:19:52 +1200 Subject: console: TCP proxy patterns to new options screen --- libmproxy/console/help.py | 1 - 1 file changed, 1 deletion(-) (limited to 'libmproxy/console/help.py') diff --git a/libmproxy/console/help.py b/libmproxy/console/help.py index 223d2e83..53296df9 100644 --- a/libmproxy/console/help.py +++ b/libmproxy/console/help.py @@ -43,7 +43,6 @@ class HelpView(urwid.ListBox): ("Q", "quit without confirm prompt"), ("S", "server replay"), ("t", "set sticky cookie expression"), - ("T", "set tcp proxying pattern"), ("u", "set sticky auth expression"), ] text.extend( -- cgit v1.2.3 From 0d6de19b070789405ed2713b6d973b06ea7922fc Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Mon, 6 Apr 2015 17:27:46 +1200 Subject: console: sticky cookies and auth to options screen --- libmproxy/console/help.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'libmproxy/console/help.py') diff --git a/libmproxy/console/help.py b/libmproxy/console/help.py index 53296df9..0da29907 100644 --- a/libmproxy/console/help.py +++ b/libmproxy/console/help.py @@ -39,11 +39,9 @@ class HelpView(urwid.ListBox): ("c", "client replay"), ("i", "set interception pattern"), ("o", "options"), - ("q", "quit / return to flow list"), + ("q", "quit / return to previous page"), ("Q", "quit without confirm prompt"), ("S", "server replay"), - ("t", "set sticky cookie expression"), - ("u", "set sticky auth expression"), ] text.extend( common.format_keyvals(keys, key="key", val="text", indent=4) -- cgit v1.2.3 From 1cb1ee411b9c8ffc40f83bcca99770af7f43a521 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Tue, 7 Apr 2015 08:42:40 +1200 Subject: console: palette picker for the options screen --- libmproxy/console/help.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'libmproxy/console/help.py') diff --git a/libmproxy/console/help.py b/libmproxy/console/help.py index 0da29907..44195798 100644 --- a/libmproxy/console/help.py +++ b/libmproxy/console/help.py @@ -103,3 +103,25 @@ class HelpView(urwid.ListBox): elif key == "?": key = None return urwid.ListBox.keypress(self, size, key) + + +class PalettePicker(urwid.WidgetWrap): + def __init__(self, master): + self.master = master + self.lb = select.Select( + [ + select.Heading("Low"), + select.Option( + "One Two", + "O", + ), + ] + ) + title = urwid.Text("Palettes") + title = urwid.Padding(title, align="left", width=("relative", 100)) + title = urwid.AttrWrap(title, "heading") + self._w = urwid.Frame( + self.lb, + header = title + ) + -- cgit v1.2.3 From e76467e977c061d92f88500b23f11bbf3cc365bb Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Tue, 7 Apr 2015 15:59:38 +1200 Subject: Refactor flow list state management - Use signal mechanism for state synchronisation - Move "Copy to clipboard" shortcut to "P" --- libmproxy/console/help.py | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'libmproxy/console/help.py') diff --git a/libmproxy/console/help.py b/libmproxy/console/help.py index 44195798..0da29907 100644 --- a/libmproxy/console/help.py +++ b/libmproxy/console/help.py @@ -103,25 +103,3 @@ class HelpView(urwid.ListBox): elif key == "?": key = None return urwid.ListBox.keypress(self, size, key) - - -class PalettePicker(urwid.WidgetWrap): - def __init__(self, master): - self.master = master - self.lb = select.Select( - [ - select.Heading("Low"), - select.Option( - "One Two", - "O", - ), - ] - ) - title = urwid.Text("Palettes") - title = urwid.Padding(title, align="left", width=("relative", 100)) - title = urwid.AttrWrap(title, "heading") - self._w = urwid.Frame( - self.lb, - header = title - ) - -- cgit v1.2.3 From 8e2e83a3c6d47e52a5398f851b2900dd042f3d6a Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Tue, 7 Apr 2015 16:13:42 +1200 Subject: console: add g/G shortcuts throughout g: go to end G: go to beginning --- libmproxy/console/help.py | 1 + 1 file changed, 1 insertion(+) (limited to 'libmproxy/console/help.py') diff --git a/libmproxy/console/help.py b/libmproxy/console/help.py index 0da29907..6d36ee71 100644 --- a/libmproxy/console/help.py +++ b/libmproxy/console/help.py @@ -28,6 +28,7 @@ class HelpView(urwid.ListBox): keys = [ ("j, k", "down, up"), ("h, l", "left, right (in some contexts)"), + ("g, G", "go to end, beginning"), ("space", "page down"), ("pg up/down", "page up/down"), ("arrows", "up, down, left, right"), -- cgit v1.2.3 From ff654730e8dc0e68998487a8dcaf3db00a42c371 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Fri, 17 Apr 2015 13:30:49 +1200 Subject: console: make g/G shortcuts work in more contexts --- libmproxy/console/help.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'libmproxy/console/help.py') diff --git a/libmproxy/console/help.py b/libmproxy/console/help.py index 6d36ee71..cbd5bef8 100644 --- a/libmproxy/console/help.py +++ b/libmproxy/console/help.py @@ -103,4 +103,8 @@ class HelpView(urwid.ListBox): return None elif key == "?": key = None + elif key == "G": + self.set_focus(0) + elif key == "g": + self.set_focus(len(self.body.contents)) return urwid.ListBox.keypress(self, size, key) -- cgit v1.2.3 From a05a70d8168a07c92b2a3ecbbb1958d85532efe3 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Sat, 30 May 2015 12:03:28 +1200 Subject: Add coding style check, reformat. --- libmproxy/console/help.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'libmproxy/console/help.py') diff --git a/libmproxy/console/help.py b/libmproxy/console/help.py index cbd5bef8..4e81a566 100644 --- a/libmproxy/console/help.py +++ b/libmproxy/console/help.py @@ -6,7 +6,7 @@ from . import common, signals from .. import filt, version footer = [ - ("heading", 'mitmproxy v%s '%version.VERSION), + ("heading", 'mitmproxy v%s ' % version.VERSION), ('heading_key', "q"), ":back ", ] @@ -33,7 +33,12 @@ class HelpView(urwid.ListBox): ("pg up/down", "page up/down"), ("arrows", "up, down, left, right"), ] - text.extend(common.format_keyvals(keys, key="key", val="text", indent=4)) + text.extend( + common.format_keyvals( + keys, + key="key", + val="text", + indent=4)) text.append(urwid.Text([("head", "\n\nGlobal keys:\n")])) keys = [ @@ -52,15 +57,15 @@ class HelpView(urwid.ListBox): f = [] for i in filt.filt_unary: f.append( - ("~%s"%i.code, i.help) + ("~%s" % i.code, i.help) ) for i in filt.filt_rex: f.append( - ("~%s regex"%i.code, i.help) + ("~%s regex" % i.code, i.help) ) for i in filt.filt_int: f.append( - ("~%s int"%i.code, i.help) + ("~%s int" % i.code, i.help) ) f.sort() f.extend( @@ -75,7 +80,7 @@ class HelpView(urwid.ListBox): text.append( urwid.Text( - [ + [ "\n", ("text", " Regexes are Python-style.\n"), ("text", " Regexes can be specified as quoted strings.\n"), @@ -83,13 +88,13 @@ class HelpView(urwid.ListBox): ("text", " Expressions with no operators are regex matches against URL.\n"), ("text", " Default binary operator is &.\n"), ("head", "\n Examples:\n"), - ] + ] ) ) examples = [ - ("google\.com", "Url containing \"google.com"), - ("~q ~b test", "Requests where body contains \"test\""), - ("!(~q & ~t \"text/html\")", "Anything but requests with a text/html content type."), + ("google\.com", "Url containing \"google.com"), + ("~q ~b test", "Requests where body contains \"test\""), + ("!(~q & ~t \"text/html\")", "Anything but requests with a text/html content type."), ] text.extend( common.format_keyvals(examples, key="key", val="text", indent=4) -- cgit v1.2.3