mirror of
https://github.com/zhigang1992/mitmproxy.git
synced 2026-01-12 17:32:27 +08:00
console: various bugs
- Action bar now correctly gets the palette background - Viewing connection details for a killed flow no longer crashes - Editing options with selections no longer crashes
This commit is contained in:
committed by
Aldo Cortesi
parent
4e39d387d3
commit
dcae79e017
@@ -27,7 +27,7 @@ def flowdetails(state, flow: http.HTTPFlow):
|
||||
text.append(urwid.Text([("head", "Metadata:")]))
|
||||
text.extend(common.format_keyvals(parts, key="key", val="text", indent=4))
|
||||
|
||||
if sc is not None:
|
||||
if sc is not None and sc.ip_address:
|
||||
text.append(urwid.Text([("head", "Server Connection:")]))
|
||||
parts = [
|
||||
["Address", human.format_address(sc.address)],
|
||||
|
||||
@@ -27,7 +27,6 @@ from mitmproxy.tools.console import keymap
|
||||
from mitmproxy.tools.console import overlay
|
||||
from mitmproxy.tools.console import palettes
|
||||
from mitmproxy.tools.console import signals
|
||||
from mitmproxy.tools.console import statusbar
|
||||
from mitmproxy.tools.console import window
|
||||
from mitmproxy import contentviews
|
||||
from mitmproxy.utils import strutils
|
||||
@@ -483,7 +482,6 @@ class ConsoleMaster(master.Master):
|
||||
|
||||
signal.signal(signal.SIGINT, sigint_handler)
|
||||
|
||||
self.ab = None
|
||||
self.window = None
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
@@ -621,7 +619,6 @@ class ConsoleMaster(master.Master):
|
||||
handle_mouse = self.options.console_mouse,
|
||||
)
|
||||
|
||||
self.ab = statusbar.ActionBar(self)
|
||||
self.window = window.Window(self)
|
||||
self.loop.widget = self.window
|
||||
|
||||
|
||||
@@ -219,6 +219,7 @@ class OptionsList(urwid.ListBox):
|
||||
elif foc.opt.choices:
|
||||
self.master.overlay(
|
||||
overlay.Chooser(
|
||||
self.master,
|
||||
foc.opt.name,
|
||||
foc.opt.choices,
|
||||
foc.opt.current(),
|
||||
|
||||
@@ -151,7 +151,8 @@ class StatusBar(urwid.WidgetWrap):
|
||||
self.master = master
|
||||
self.helptext = helptext
|
||||
self.ib = urwid.WidgetWrap(urwid.Text(""))
|
||||
super().__init__(urwid.Pile([self.ib, self.master.ab]))
|
||||
self.ab = ActionBar(self)
|
||||
super().__init__(urwid.Pile([self.ib, self.ab]))
|
||||
signals.update_settings.connect(self.sig_update)
|
||||
signals.flowlist_change.connect(self.sig_update)
|
||||
signals.footer_help.connect(self.sig_footer_help)
|
||||
@@ -167,7 +168,7 @@ class StatusBar(urwid.WidgetWrap):
|
||||
self.redraw()
|
||||
|
||||
def keypress(self, *args, **kwargs):
|
||||
return self.master.ab.keypress(*args, **kwargs)
|
||||
return self.ab.keypress(*args, **kwargs)
|
||||
|
||||
def get_status(self):
|
||||
r = []
|
||||
|
||||
@@ -12,10 +12,11 @@ from mitmproxy.tools.console import grideditor
|
||||
|
||||
class Window(urwid.Frame):
|
||||
def __init__(self, master):
|
||||
self.statusbar = statusbar.StatusBar(master, "")
|
||||
super().__init__(
|
||||
None,
|
||||
header = None,
|
||||
footer = statusbar.StatusBar(master, ""),
|
||||
footer = urwid.AttrWrap(self.statusbar, "background")
|
||||
)
|
||||
self.master = master
|
||||
self.primary_stack = []
|
||||
|
||||
@@ -150,7 +150,7 @@ def test_options(tmpdir):
|
||||
|
||||
sa.options_save(p)
|
||||
with pytest.raises(exceptions.CommandError):
|
||||
sa.options_save("/nonexistent")
|
||||
sa.options_save("/")
|
||||
|
||||
sa.options_reset()
|
||||
assert tctx.options.stickyauth is None
|
||||
|
||||
@@ -152,7 +152,7 @@ class TestScriptLoader:
|
||||
sc = script.ScriptLoader()
|
||||
with taddons.context():
|
||||
with pytest.raises(exceptions.CommandError):
|
||||
sc.script_run([tflow.tflow(resp=True)], "/nonexistent")
|
||||
sc.script_run([tflow.tflow(resp=True)], "/")
|
||||
|
||||
def test_simple(self):
|
||||
sc = script.ScriptLoader()
|
||||
|
||||
Reference in New Issue
Block a user