mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Fix a number of small UI infelicities.
- Make request/response view switching behave sensibly - Avoid having an empty string appear in connection view text. This makes urwid misbehave. - Make it clear that intercept and cookies specifications are filters.
This commit is contained in:
parent
038a6eb1a7
commit
6cb40d03f4
@ -53,13 +53,11 @@ def format_keyvals(lst, key="key", val="text", space=5, indent=0):
|
|||||||
|
|
||||||
|
|
||||||
def format_flow(f, focus, extended=False, padding=2):
|
def format_flow(f, focus, extended=False, padding=2):
|
||||||
|
txt = []
|
||||||
if extended:
|
if extended:
|
||||||
ts = ("highlight", utils.format_timestamp(f.request.timestamp))
|
txt.append(("highlight", utils.format_timestamp(f.request.timestamp)))
|
||||||
else:
|
txt.append(" ")
|
||||||
ts = ""
|
txt.extend([
|
||||||
|
|
||||||
txt = [
|
|
||||||
ts,
|
|
||||||
("ack", "!") if f.intercepting and not f.request.acked else " ",
|
("ack", "!") if f.intercepting and not f.request.acked else " ",
|
||||||
("method", f.request.method),
|
("method", f.request.method),
|
||||||
" ",
|
" ",
|
||||||
@ -67,7 +65,7 @@ def format_flow(f, focus, extended=False, padding=2):
|
|||||||
"text" if (f.response or f.error) else "title",
|
"text" if (f.response or f.error) else "title",
|
||||||
f.request.url(),
|
f.request.url(),
|
||||||
),
|
),
|
||||||
]
|
])
|
||||||
if f.response or f.error or f.request.is_replay():
|
if f.response or f.error or f.request.is_replay():
|
||||||
tsr = f.response or f.error
|
tsr = f.response or f.error
|
||||||
if extended and tsr:
|
if extended and tsr:
|
||||||
@ -247,10 +245,10 @@ class ConnectionView(WWrap):
|
|||||||
]
|
]
|
||||||
def __init__(self, master, state, flow):
|
def __init__(self, master, state, flow):
|
||||||
self.master, self.state, self.flow = master, state, flow
|
self.master, self.state, self.flow = master, state, flow
|
||||||
if self.state.view_flow_mode == VIEW_FLOW_REQUEST:
|
if self.state.view_flow_mode == VIEW_FLOW_RESPONSE and flow.response:
|
||||||
self.view_request()
|
|
||||||
else:
|
|
||||||
self.view_response()
|
self.view_response()
|
||||||
|
else:
|
||||||
|
self.view_request()
|
||||||
|
|
||||||
def _tab(self, content, active):
|
def _tab(self, content, active):
|
||||||
if active:
|
if active:
|
||||||
@ -359,10 +357,10 @@ class ConnectionView(WWrap):
|
|||||||
|
|
||||||
def refresh_connection(self, c=None):
|
def refresh_connection(self, c=None):
|
||||||
if c == self.flow:
|
if c == self.flow:
|
||||||
if self.state.view_flow_mode == VIEW_FLOW_REQUEST:
|
if self.state.view_flow_mode == VIEW_FLOW_RESPONSE and flow.response:
|
||||||
self.view_request()
|
|
||||||
else:
|
|
||||||
self.view_response()
|
self.view_response()
|
||||||
|
else:
|
||||||
|
self.view_request()
|
||||||
|
|
||||||
def _spawn_editor(self, data):
|
def _spawn_editor(self, data):
|
||||||
fd, name = tempfile.mkstemp('', "mproxy")
|
fd, name = tempfile.mkstemp('', "mproxy")
|
||||||
@ -471,7 +469,7 @@ class ConnectionView(WWrap):
|
|||||||
|
|
||||||
def keypress(self, size, key):
|
def keypress(self, size, key):
|
||||||
if key == "tab":
|
if key == "tab":
|
||||||
if self.state.view_flow_mode == VIEW_FLOW_REQUEST:
|
if self.state.view_flow_mode == VIEW_FLOW_REQUEST and self.flow.response:
|
||||||
self.view_response()
|
self.view_response()
|
||||||
else:
|
else:
|
||||||
self.view_request()
|
self.view_request()
|
||||||
@ -1315,7 +1313,7 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
k = None
|
k = None
|
||||||
elif k == "i":
|
elif k == "i":
|
||||||
self.prompt(
|
self.prompt(
|
||||||
"Intercept: ",
|
"Intercept filter: ",
|
||||||
self.state.intercept_txt,
|
self.state.intercept_txt,
|
||||||
self.set_intercept
|
self.set_intercept
|
||||||
)
|
)
|
||||||
@ -1379,7 +1377,7 @@ class ConsoleMaster(flow.FlowMaster):
|
|||||||
k = None
|
k = None
|
||||||
elif k == "t":
|
elif k == "t":
|
||||||
self.prompt(
|
self.prompt(
|
||||||
"Sticky cookie: ",
|
"Sticky cookie filter: ",
|
||||||
self.stickycookie_txt,
|
self.stickycookie_txt,
|
||||||
self.set_stickycookie
|
self.set_stickycookie
|
||||||
)
|
)
|
||||||
|
@ -55,6 +55,8 @@ if __name__ == '__main__':
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
opts = console.Options(**cmdline.get_common_options(options))
|
opts = console.Options(**cmdline.get_common_options(options))
|
||||||
|
opts.intercept = options.intercept
|
||||||
|
opts.limit = options.limit
|
||||||
m = console.ConsoleMaster(server, opts)
|
m = console.ConsoleMaster(server, opts)
|
||||||
|
|
||||||
for i in args:
|
for i in args:
|
||||||
|
Loading…
Reference in New Issue
Block a user