mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 02:24:18 +00:00
Formatting and whitespace
This commit is contained in:
parent
468cc81c8a
commit
87a3c71041
@ -776,7 +776,7 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
self.loop = urwid.MainLoop(
|
self.loop = urwid.MainLoop(
|
||||||
self.view,
|
self.view,
|
||||||
screen = self.ui,
|
screen = self.ui,
|
||||||
input_filter=self.input_filter
|
input_filter = self.input_filter
|
||||||
)
|
)
|
||||||
self.view_flowlist()
|
self.view_flowlist()
|
||||||
self.statusbar.redraw()
|
self.statusbar.redraw()
|
||||||
|
@ -41,6 +41,8 @@ def highlight_key(s, k):
|
|||||||
|
|
||||||
|
|
||||||
KEY_MAX = 30
|
KEY_MAX = 30
|
||||||
|
|
||||||
|
|
||||||
def format_keyvals(lst, key="key", val="text", indent=0):
|
def format_keyvals(lst, key="key", val="text", indent=0):
|
||||||
"""
|
"""
|
||||||
Format a list of (key, value) tuples.
|
Format a list of (key, value) tuples.
|
||||||
@ -103,10 +105,8 @@ else:
|
|||||||
SYMBOL_RETURN = u"<-"
|
SYMBOL_RETURN = u"<-"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def raw_format_flow(f, focus, extended, padding):
|
def raw_format_flow(f, focus, extended, padding):
|
||||||
f = dict(f)
|
f = dict(f)
|
||||||
|
|
||||||
pile = []
|
pile = []
|
||||||
req = []
|
req = []
|
||||||
if extended:
|
if extended:
|
||||||
@ -122,7 +122,7 @@ def raw_format_flow(f, focus, extended, padding):
|
|||||||
req.append(fcol(SYMBOL_REPLAY, "replay"))
|
req.append(fcol(SYMBOL_REPLAY, "replay"))
|
||||||
req.append(fcol(f["req_method"], "method"))
|
req.append(fcol(f["req_method"], "method"))
|
||||||
|
|
||||||
preamble = sum(i[1] for i in req) + len(req) -1
|
preamble = sum(i[1] for i in req) + len(req) - 1
|
||||||
|
|
||||||
if f["intercepted"] and not f["acked"]:
|
if f["intercepted"] and not f["acked"]:
|
||||||
uc = "intercept"
|
uc = "intercept"
|
||||||
@ -348,7 +348,6 @@ def format_flow(f, focus, extended=False, hostheader=False, padding=2):
|
|||||||
duration = 0
|
duration = 0
|
||||||
if f.response.timestamp_end and f.request.timestamp_start:
|
if f.response.timestamp_end and f.request.timestamp_start:
|
||||||
duration = f.response.timestamp_end - f.request.timestamp_start
|
duration = f.response.timestamp_end - f.request.timestamp_start
|
||||||
size = f.response.size()
|
|
||||||
roundtrip = utils.pretty_duration(duration)
|
roundtrip = utils.pretty_duration(duration)
|
||||||
|
|
||||||
d.update(dict(
|
d.update(dict(
|
||||||
@ -362,7 +361,9 @@ def format_flow(f, focus, extended=False, hostheader=False, padding=2):
|
|||||||
d["resp_ctype"] = t[0].split(";")[0]
|
d["resp_ctype"] = t[0].split(";")[0]
|
||||||
else:
|
else:
|
||||||
d["resp_ctype"] = ""
|
d["resp_ctype"] = ""
|
||||||
return flowcache.format_flow(tuple(sorted(d.items())), focus, extended, padding)
|
return flowcache.format_flow(
|
||||||
|
tuple(sorted(d.items())), focus, extended, padding
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def int_version(v):
|
def int_version(v):
|
||||||
@ -380,8 +381,8 @@ class WWrap(urwid.WidgetWrap):
|
|||||||
if int_version(urwid.__version__) >= 990:
|
if int_version(urwid.__version__) >= 990:
|
||||||
def set_w(self, x):
|
def set_w(self, x):
|
||||||
self._w = x
|
self._w = x
|
||||||
|
|
||||||
def get_w(self):
|
def get_w(self):
|
||||||
return self._w
|
return self._w
|
||||||
|
|
||||||
w = property(get_w, set_w)
|
w = property(get_w, set_w)
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ import urwid
|
|||||||
from netlib import http
|
from netlib import http
|
||||||
from . import common
|
from . import common
|
||||||
|
|
||||||
|
|
||||||
def _mkhelp():
|
def _mkhelp():
|
||||||
text = []
|
text = []
|
||||||
keys = [
|
keys = [
|
||||||
@ -35,6 +36,7 @@ footer = [
|
|||||||
('heading_key', "?"), ":help ",
|
('heading_key', "?"), ":help ",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class EventListBox(urwid.ListBox):
|
class EventListBox(urwid.ListBox):
|
||||||
def __init__(self, master):
|
def __init__(self, master):
|
||||||
self.master = master
|
self.master = master
|
||||||
@ -60,7 +62,10 @@ class BodyPile(urwid.Pile):
|
|||||||
self,
|
self,
|
||||||
[
|
[
|
||||||
FlowListBox(master),
|
FlowListBox(master),
|
||||||
urwid.Frame(EventListBox(master), header = self.inactive_header)
|
urwid.Frame(
|
||||||
|
EventListBox(master),
|
||||||
|
header = self.inactive_header
|
||||||
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
self.master = master
|
self.master = master
|
||||||
@ -80,11 +85,11 @@ class BodyPile(urwid.Pile):
|
|||||||
# This is essentially a copypasta from urwid.Pile's keypress handler.
|
# This is essentially a copypasta from urwid.Pile's keypress handler.
|
||||||
# So much for "closed for modification, but open for extension".
|
# So much for "closed for modification, but open for extension".
|
||||||
item_rows = None
|
item_rows = None
|
||||||
if len(size)==2:
|
if len(size) == 2:
|
||||||
item_rows = self.get_item_rows( size, focus=True )
|
item_rows = self.get_item_rows(size, focus = True)
|
||||||
i = self.widget_list.index(self.focus_item)
|
i = self.widget_list.index(self.focus_item)
|
||||||
tsize = self.get_item_size(size,i,True,item_rows)
|
tsize = self.get_item_size(size, i, True, item_rows)
|
||||||
return self.focus_item.keypress( tsize, key )
|
return self.focus_item.keypress(tsize, key)
|
||||||
|
|
||||||
|
|
||||||
class ConnectionItem(common.WWrap):
|
class ConnectionItem(common.WWrap):
|
||||||
@ -95,7 +100,11 @@ class ConnectionItem(common.WWrap):
|
|||||||
common.WWrap.__init__(self, w)
|
common.WWrap.__init__(self, w)
|
||||||
|
|
||||||
def get_text(self):
|
def get_text(self):
|
||||||
return common.format_flow(self.flow, self.f, hostheader=self.master.showhost)
|
return common.format_flow(
|
||||||
|
self.flow,
|
||||||
|
self.f,
|
||||||
|
hostheader = self.master.showhost
|
||||||
|
)
|
||||||
|
|
||||||
def selectable(self):
|
def selectable(self):
|
||||||
return True
|
return True
|
||||||
@ -125,7 +134,8 @@ class ConnectionItem(common.WWrap):
|
|||||||
[i.copy() for i in self.master.state.view],
|
[i.copy() for i in self.master.state.view],
|
||||||
self.master.killextra, self.master.rheaders,
|
self.master.killextra, self.master.rheaders,
|
||||||
False, self.master.nopop,
|
False, self.master.nopop,
|
||||||
self.master.options.replay_ignore_params, self.master.options.replay_ignore_content,
|
self.master.options.replay_ignore_params,
|
||||||
|
self.master.options.replay_ignore_content,
|
||||||
self.master.options.replay_ignore_payload_params
|
self.master.options.replay_ignore_payload_params
|
||||||
)
|
)
|
||||||
elif k == "t":
|
elif k == "t":
|
||||||
@ -133,7 +143,8 @@ class ConnectionItem(common.WWrap):
|
|||||||
[self.flow.copy()],
|
[self.flow.copy()],
|
||||||
self.master.killextra, self.master.rheaders,
|
self.master.killextra, self.master.rheaders,
|
||||||
False, self.master.nopop,
|
False, self.master.nopop,
|
||||||
self.master.options.replay_ignore_params, self.master.options.replay_ignore_content,
|
self.master.options.replay_ignore_params,
|
||||||
|
self.master.options.replay_ignore_content,
|
||||||
self.master.options.replay_ignore_payload_params
|
self.master.options.replay_ignore_payload_params
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@ -249,7 +260,7 @@ class FlowListBox(urwid.ListBox):
|
|||||||
|
|
||||||
def get_method_raw(self, k):
|
def get_method_raw(self, k):
|
||||||
if k:
|
if k:
|
||||||
self.get_url(k)
|
self.get_url(k)
|
||||||
|
|
||||||
def get_method(self, k):
|
def get_method(self, k):
|
||||||
if k == "e":
|
if k == "e":
|
||||||
@ -261,8 +272,13 @@ class FlowListBox(urwid.ListBox):
|
|||||||
method = i[0].upper()
|
method = i[0].upper()
|
||||||
self.get_url(method)
|
self.get_url(method)
|
||||||
|
|
||||||
def get_url(self,method):
|
def get_url(self, method):
|
||||||
self.master.prompt("URL:", "http://www.example.com/", self.new_request, method)
|
self.master.prompt(
|
||||||
|
"URL:",
|
||||||
|
"http://www.example.com/",
|
||||||
|
self.new_request,
|
||||||
|
method
|
||||||
|
)
|
||||||
|
|
||||||
def new_request(self, url, method):
|
def new_request(self, url, method):
|
||||||
parts = http.parse_url(str(url))
|
parts = http.parse_url(str(url))
|
||||||
@ -283,7 +299,11 @@ class FlowListBox(urwid.ListBox):
|
|||||||
elif key == "e":
|
elif key == "e":
|
||||||
self.master.toggle_eventlog()
|
self.master.toggle_eventlog()
|
||||||
elif key == "l":
|
elif key == "l":
|
||||||
self.master.prompt("Limit: ", self.master.state.limit_txt, self.master.set_limit)
|
self.master.prompt(
|
||||||
|
"Limit: ",
|
||||||
|
self.master.state.limit_txt,
|
||||||
|
self.master.set_limit
|
||||||
|
)
|
||||||
elif key == "L":
|
elif key == "L":
|
||||||
self.master.path_prompt(
|
self.master.path_prompt(
|
||||||
"Load flows: ",
|
"Load flows: ",
|
||||||
@ -291,7 +311,11 @@ class FlowListBox(urwid.ListBox):
|
|||||||
self.master.load_flows_callback
|
self.master.load_flows_callback
|
||||||
)
|
)
|
||||||
elif key == "n":
|
elif key == "n":
|
||||||
self.master.prompt_onekey("Method", common.METHOD_OPTIONS, self.get_method)
|
self.master.prompt_onekey(
|
||||||
|
"Method",
|
||||||
|
common.METHOD_OPTIONS,
|
||||||
|
self.get_method
|
||||||
|
)
|
||||||
elif key == "F":
|
elif key == "F":
|
||||||
self.master.toggle_follow_flows()
|
self.master.toggle_follow_flows()
|
||||||
elif key == "W":
|
elif key == "W":
|
||||||
|
Loading…
Reference in New Issue
Block a user