Rejigger status bar somewhat. Add indicators for various bits of state.

In particular, we now display limits, sticky cookie expressions and intercepts
in the bar.
This commit is contained in:
Aldo Cortesi 2011-03-13 15:55:47 +13:00
parent 3ef9d2cffc
commit ef27e2fb29
2 changed files with 52 additions and 23 deletions

View File

@ -228,7 +228,6 @@ VIEW_FLOW_RESPONSE = 1
class ConnectionView(WWrap): class ConnectionView(WWrap):
REQ = 0 REQ = 0
RESP = 1 RESP = 1
tabs = ["Request", "Response"]
methods = [ methods = [
("get", "g"), ("get", "g"),
("post", "p"), ("post", "p"),
@ -658,37 +657,59 @@ class ActionBar(WWrap):
class StatusBar(WWrap): class StatusBar(WWrap):
def __init__(self, master, text): def __init__(self, master, helptext):
self.master, self.text = master, text self.master, self.helptext = master, helptext
self.expire = None self.expire = None
self.ab = ActionBar() self.ab = ActionBar()
self.ib = urwid.AttrWrap(urwid.Text(""), 'foot') self.ib = WWrap(urwid.Text(""))
self.w = urwid.Pile([self.ib, self.ab]) self.w = urwid.Pile([self.ib, self.ab])
def get_status(self):
r = []
if self.master.state.intercept_txt:
r.append("[")
r.append(("statusbar_highlight", "i"))
r.append(":%s]"%self.master.state.intercept_txt)
if self.master.state.limit_txt:
r.append("[")
r.append(("statusbar_highlight", "l"))
r.append(":%s]"%self.master.state.limit_txt)
if self.master.stickycookie_txt:
r.append("[")
r.append(("statusbar_highlight", "t"))
r.append(":%s]"%self.master.stickycookie_txt)
return r
def redraw(self): def redraw(self):
if self.expire and time.time() > self.expire: if self.expire and time.time() > self.expire:
self.message("") self.message("")
status = urwid.Columns([
t = [
('statusbar_text', ("[%s]"%len(self.master.state.flow_list)).ljust(7)),
]
t.extend(self.get_status())
status = urwid.AttrWrap(urwid.Columns([
urwid.Text(t),
urwid.Text( urwid.Text(
[ [
self.helptext,
" ",
( (
'title', 'statusbar_text',
"mitmproxy %s:%s"%(self.master.server.address, self.master.server.port) "[%s:%s]"%(self.master.server.address or "*", self.master.server.port)
) ),
]
),
urwid.Text(
[
self.text,
('text', "%5s"%("[%s]"%len(self.master.state.flow_list)))
], ],
align="right"), align="right"
]) ),
]), "statusbar")
self.ib.set_w(status) self.ib.set_w(status)
self.master.drawscreen() self.master.drawscreen()
def update(self, text): def update(self, text):
self.text = text self.helptext = text
self.redraw() self.redraw()
def selectable(self): def selectable(self):
@ -807,16 +828,15 @@ VIEW_HELP = 2
class ConsoleMaster(flow.FlowMaster): class ConsoleMaster(flow.FlowMaster):
palette = [] palette = []
footer_text_default = [ footer_text_default = [
('key', "?"), ":help ", ('statusbar_key', "?"), ":help ",
('key', "q"), ":exit ",
] ]
footer_text_help = [ footer_text_help = [
('key', "q"), ":back", ('statusbar_key', "q"), ":back",
] ]
footer_text_connview = [ footer_text_connview = [
('key', "tab"), ":toggle view ", ('statusbar_key', "tab"), ":toggle view ",
('key', "?"), ":help ", ('statusbar_key', "?"), ":help ",
('key', "q"), ":back ", ('statusbar_key', "q"), ":back ",
] ]
def __init__(self, server, options): def __init__(self, server, options):
flow.FlowMaster.__init__(self, server, ConsoleState()) flow.FlowMaster.__init__(self, server, ConsoleState())
@ -871,12 +891,19 @@ class ConsoleMaster(flow.FlowMaster):
os.unlink(name) os.unlink(name)
def set_palette(self): def set_palette(self):
BARBG = "dark blue"
self.palette = [ self.palette = [
('body', 'black', 'dark cyan', 'standout'), ('body', 'black', 'dark cyan', 'standout'),
('foot', 'light gray', 'default'), ('foot', 'light gray', 'default'),
('title', 'white', 'default',), ('title', 'white', 'default',),
('editline', 'white', 'default',), ('editline', 'white', 'default',),
# Status bar
('statusbar', 'light gray', BARBG),
('statusbar_key', 'light cyan', BARBG),
('statusbar_text', 'light gray', BARBG),
('statusbar_highlight', 'white', BARBG),
# Help # Help
('key', 'light cyan', 'default', 'underline'), ('key', 'light cyan', 'default', 'underline'),
('head', 'white', 'default'), ('head', 'white', 'default'),

View File

@ -447,7 +447,9 @@ class FlowMaster(controller.Master):
self.client_playback = None self.client_playback = None
self.scripts = {} self.scripts = {}
self.kill_nonreplay = False self.kill_nonreplay = False
self.stickycookie_state = False self.stickycookie_state = False
self.stickycookie_txt = None
self.anticache = False self.anticache = False
self.refresh_server_playback = False self.refresh_server_playback = False