2014-03-10 21:36:47 +00:00
|
|
|
from __future__ import absolute_import
|
2015-03-13 12:14:37 +00:00
|
|
|
|
2012-02-07 03:39:37 +00:00
|
|
|
import urwid
|
2015-03-13 12:14:37 +00:00
|
|
|
|
2015-03-22 04:18:53 +00:00
|
|
|
from . import common, signals
|
2012-03-22 01:57:57 +00:00
|
|
|
from .. import filt, version
|
|
|
|
|
|
|
|
footer = [
|
2015-05-30 00:03:28 +00:00
|
|
|
("heading", 'mitmproxy v%s ' % version.VERSION),
|
2012-03-22 01:57:57 +00:00
|
|
|
('heading_key', "q"), ":back ",
|
|
|
|
]
|
2012-02-07 03:39:37 +00:00
|
|
|
|
2015-03-13 12:14:37 +00:00
|
|
|
|
2012-02-07 03:39:37 +00:00
|
|
|
class HelpView(urwid.ListBox):
|
2015-03-22 04:18:53 +00:00
|
|
|
def __init__(self, help_context):
|
2012-02-08 08:47:39 +00:00
|
|
|
self.help_context = help_context or []
|
2012-02-07 03:39:37 +00:00
|
|
|
urwid.ListBox.__init__(
|
|
|
|
self,
|
|
|
|
self.helptext()
|
|
|
|
)
|
|
|
|
|
|
|
|
def helptext(self):
|
|
|
|
text = []
|
2012-08-31 01:28:04 +00:00
|
|
|
text.append(urwid.Text([("head", "This view:\n")]))
|
2012-02-08 08:47:39 +00:00
|
|
|
text.extend(self.help_context)
|
|
|
|
|
2012-02-11 05:23:07 +00:00
|
|
|
text.append(urwid.Text([("head", "\n\nMovement:\n")]))
|
2012-02-08 09:55:48 +00:00
|
|
|
keys = [
|
2014-09-19 15:56:54 +00:00
|
|
|
("j, k", "down, up"),
|
2012-02-08 09:55:48 +00:00
|
|
|
("h, l", "left, right (in some contexts)"),
|
2015-07-08 15:10:03 +00:00
|
|
|
("g, G", "go to beginning, end"),
|
2012-02-08 09:55:48 +00:00
|
|
|
("space", "page down"),
|
|
|
|
("pg up/down", "page up/down"),
|
|
|
|
("arrows", "up, down, left, right"),
|
|
|
|
]
|
2015-05-30 00:03:28 +00:00
|
|
|
text.extend(
|
|
|
|
common.format_keyvals(
|
|
|
|
keys,
|
|
|
|
key="key",
|
|
|
|
val="text",
|
|
|
|
indent=4))
|
2012-02-08 09:55:48 +00:00
|
|
|
|
2012-02-11 05:23:07 +00:00
|
|
|
text.append(urwid.Text([("head", "\n\nGlobal keys:\n")]))
|
2012-02-07 03:39:37 +00:00
|
|
|
keys = [
|
2015-07-04 17:11:02 +00:00
|
|
|
("c", "client replay of HTTP requests"),
|
2012-02-07 03:39:37 +00:00
|
|
|
("i", "set interception pattern"),
|
2015-04-03 06:10:12 +00:00
|
|
|
("o", "options"),
|
2015-04-06 05:27:46 +00:00
|
|
|
("q", "quit / return to previous page"),
|
2012-02-07 03:39:37 +00:00
|
|
|
("Q", "quit without confirm prompt"),
|
2015-07-04 17:11:02 +00:00
|
|
|
("S", "server replay of HTTP responses"),
|
2012-02-07 03:39:37 +00:00
|
|
|
]
|
2015-03-13 12:14:37 +00:00
|
|
|
text.extend(
|
|
|
|
common.format_keyvals(keys, key="key", val="text", indent=4)
|
|
|
|
)
|
2012-02-07 03:39:37 +00:00
|
|
|
|
2012-02-11 05:23:07 +00:00
|
|
|
text.append(urwid.Text([("head", "\n\nFilter expressions:\n")]))
|
2012-02-07 03:39:37 +00:00
|
|
|
f = []
|
|
|
|
for i in filt.filt_unary:
|
|
|
|
f.append(
|
2015-05-30 00:03:28 +00:00
|
|
|
("~%s" % i.code, i.help)
|
2012-02-07 03:39:37 +00:00
|
|
|
)
|
|
|
|
for i in filt.filt_rex:
|
|
|
|
f.append(
|
2015-05-30 00:03:28 +00:00
|
|
|
("~%s regex" % i.code, i.help)
|
2012-02-07 03:39:37 +00:00
|
|
|
)
|
|
|
|
for i in filt.filt_int:
|
|
|
|
f.append(
|
2015-05-30 00:03:28 +00:00
|
|
|
("~%s int" % i.code, i.help)
|
2012-02-07 03:39:37 +00:00
|
|
|
)
|
|
|
|
f.sort()
|
|
|
|
f.extend(
|
|
|
|
[
|
|
|
|
("!", "unary not"),
|
|
|
|
("&", "and"),
|
|
|
|
("|", "or"),
|
|
|
|
("(...)", "grouping"),
|
|
|
|
]
|
|
|
|
)
|
|
|
|
text.extend(common.format_keyvals(f, key="key", val="text", indent=4))
|
|
|
|
|
2012-02-11 05:23:07 +00:00
|
|
|
text.append(
|
|
|
|
urwid.Text(
|
2015-05-30 00:03:28 +00:00
|
|
|
[
|
2012-02-11 05:23:07 +00:00
|
|
|
"\n",
|
|
|
|
("text", " Regexes are Python-style.\n"),
|
|
|
|
("text", " Regexes can be specified as quoted strings.\n"),
|
|
|
|
("text", " Header matching (~h, ~hq, ~hs) is against a string of the form \"name: value\".\n"),
|
|
|
|
("text", " Expressions with no operators are regex matches against URL.\n"),
|
|
|
|
("text", " Default binary operator is &.\n"),
|
|
|
|
("head", "\n Examples:\n"),
|
2015-05-30 00:03:28 +00:00
|
|
|
]
|
2012-02-11 05:23:07 +00:00
|
|
|
)
|
2012-02-07 03:39:37 +00:00
|
|
|
)
|
|
|
|
examples = [
|
2015-05-30 00:03:28 +00:00
|
|
|
("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."),
|
2012-02-07 03:39:37 +00:00
|
|
|
]
|
2015-03-13 12:14:37 +00:00
|
|
|
text.extend(
|
|
|
|
common.format_keyvals(examples, key="key", val="text", indent=4)
|
|
|
|
)
|
2012-02-11 05:23:07 +00:00
|
|
|
return text
|
2012-02-07 03:39:37 +00:00
|
|
|
|
2012-06-03 08:11:07 +00:00
|
|
|
def keypress(self, size, key):
|
|
|
|
key = common.shortcuts(key)
|
|
|
|
if key == "q":
|
2015-03-22 04:18:53 +00:00
|
|
|
signals.pop_view_state.send(self)
|
2012-06-03 08:11:07 +00:00
|
|
|
return None
|
|
|
|
elif key == "?":
|
|
|
|
key = None
|
2015-04-17 01:30:49 +00:00
|
|
|
elif key == "g":
|
2015-07-08 15:10:03 +00:00
|
|
|
self.set_focus(0)
|
|
|
|
elif key == "G":
|
2015-04-17 01:30:49 +00:00
|
|
|
self.set_focus(len(self.body.contents))
|
2012-06-03 08:11:07 +00:00
|
|
|
return urwid.ListBox.keypress(self, size, key)
|