diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-02-18 12:12:01 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-02-18 12:12:01 +1300 |
commit | 4ed8031172235188fdd737e7b0d399a482c261f4 (patch) | |
tree | ad3df59427b7de480cf279ab56206a6891911236 /libmproxy | |
parent | 08fdd23e234ffaa11352891b103377240bc11fbe (diff) | |
download | mitmproxy-4ed8031172235188fdd737e7b0d399a482c261f4.tar.gz mitmproxy-4ed8031172235188fdd737e7b0d399a482c261f4.tar.bz2 mitmproxy-4ed8031172235188fdd737e7b0d399a482c261f4.zip |
Jazz up flow display
- Indicate interception by coloring text, rather than adding an exclamation
mark.
- Use unicode symbol to indicate replay and for the response indicator arrow.
Diffstat (limited to 'libmproxy')
-rw-r--r-- | libmproxy/console/__init__.py | 41 | ||||
-rw-r--r-- | libmproxy/console/common.py | 37 | ||||
-rw-r--r-- | libmproxy/console/palettes.py | 39 |
3 files changed, 67 insertions, 50 deletions
diff --git a/libmproxy/console/__init__.py b/libmproxy/console/__init__.py index f0c8d833..d12b16b3 100644 --- a/libmproxy/console/__init__.py +++ b/libmproxy/console/__init__.py @@ -18,7 +18,7 @@ import os.path, sys import cStringIO import urwid from .. import controller, utils, filt, flow -import connlist, connview, help, common, kveditor +import connlist, connview, help, common, kveditor, palettes EVENTLOG_SIZE = 500 @@ -471,48 +471,13 @@ class ConsoleMaster(flow.FlowMaster): os.unlink(name) def set_palette(self): - BARBG = "dark blue" - self.palette = [ - ('body', 'black', 'dark cyan', 'standout'), - ('foot', 'light gray', 'default'), - ('title', 'white,bold', '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 - ('key', 'light cyan', 'default', 'underline'), - ('head', 'white,bold', 'default'), - ('text', 'light gray', 'default'), - - # List and Connections - ('method', 'dark cyan', 'default'), - ('focus', 'yellow', 'default'), - ('goodcode', 'light green', 'default'), - ('error', 'light red', 'default'), - ('header', 'dark cyan', 'default'), - ('heading', 'white,bold', 'dark blue'), - ('inactive_heading', 'white', 'dark gray'), - ('highlight', 'white,bold', 'default'), - ('inactive', 'dark gray', 'default'), - ('ack', 'light red', 'default'), - - # Hex view - ('offset', 'dark cyan', 'default'), - - # KV Editor - ('focusfield', 'black', 'light gray'), - ('editfield', 'black', 'light cyan'), - ] + self.palette = palettes.dark def run(self): self.currentflow = None self.ui = urwid.raw_display.Screen() + self.ui.set_terminal_properties(256) self.ui.register_palette(self.palette) self.conn_list_view = connlist.ConnectionListView(self, self.state) diff --git a/libmproxy/console/common.py b/libmproxy/console/common.py index 2d7209bc..165b9497 100644 --- a/libmproxy/console/common.py +++ b/libmproxy/console/common.py @@ -71,7 +71,7 @@ def shortcuts(k): def fcol(s, attr): - s = str(s) + s = unicode(s) return ( "fixed", len(s), @@ -83,6 +83,7 @@ def fcol(s, attr): ) + def format_flow(f, focus, extended=False, padding=2): pile = [] @@ -97,17 +98,20 @@ def format_flow(f, focus, extended=False, padding=2): else: req.append(fcol(">>" if focus else " ", "focus")) if f.request.is_replay(): - req.append(fcol("[replay]", "method")) + req.append(fcol(u"\u267B", "replay")) req.append(fcol(f.request.method, "method")) preamble = sum(i[1] for i in req) + len(req) -1 + + if f.intercepting and not f.request.acked: + uc = "intercept" + elif f.response or f.error: + uc = "text" + else: + uc = "title" + req.append( - urwid.Text([ - ( - "text" if (f.response or f.error) else "title", - f.request.get_url(), - ) - ]) + urwid.Text([(uc, f.request.get_url())]) ) pile.append(urwid.Columns(req, dividechars=1)) @@ -118,21 +122,30 @@ def format_flow(f, focus, extended=False, padding=2): ) if f.response or f.error: - resp.append(fcol("<-", "method")) + resp.append(fcol(u"\u2190", "method")) if f.response: if f.response.is_replay(): - resp.append("[replay]", "method") + resp.append(fcol(u"\u267B", "replay")) if f.response.code in [200, 304]: resp.append(fcol(f.response.code, "goodcode")) else: resp.append(fcol(f.response.code, "error")) + + if f.intercepting and f.response and not f.response.acked: + rc = "intercept" + else: + rc = "text" + t = f.response.headers["content-type"] if t: t = t[0].split(";")[0] - resp.append(fcol(t, "text")) + resp.append(fcol(t, rc)) if f.response.content: - resp.append(fcol(utils.pretty_size(len(f.response.content)), "text")) + resp.append(fcol(utils.pretty_size(len(f.response.content)), rc)) + else: + resp.append(fcol("[empty content]", rc)) + elif f.error: resp.append( urwid.Text([ diff --git a/libmproxy/console/palettes.py b/libmproxy/console/palettes.py new file mode 100644 index 00000000..cb620b90 --- /dev/null +++ b/libmproxy/console/palettes.py @@ -0,0 +1,39 @@ + +dark = [ + ('body', 'black', 'dark cyan', 'standout'), + ('foot', 'light gray', 'default'), + ('title', 'white,bold', 'default',), + ('editline', 'white', 'default',), + + # Status bar + ('statusbar', 'light gray', "dark blue"), + ('statusbar_key', 'light cyan', "dark blue"), + ('statusbar_text', 'light gray', "dark blue"), + ('statusbar_highlight', 'white', "dark blue"), + + # Help + ('key', 'light cyan', 'default', 'underline'), + ('head', 'white,bold', 'default'), + ('text', 'light gray', 'default'), + + # List and Connections + ('method', 'dark cyan', 'default'), + ('focus', 'yellow', 'default'), + ('goodcode', 'light green', 'default'), + ('error', 'light red', 'default'), + ('header', 'dark cyan', 'default'), + ('heading', 'white,bold', 'dark blue'), + ('inactive_heading', 'white', 'dark gray'), + ('highlight', 'white,bold', 'default'), + ('inactive', 'dark gray', 'default'), + ('intercept', 'brown', 'default', None, "#f60", "default"), + ('replay', 'light green', 'default', None, "#0f0", "default"), + ('ack', 'light red', 'default'), + + # Hex view + ('offset', 'dark cyan', 'default'), + + # KV Editor + ('focusfield', 'black', 'light gray'), + ('editfield', 'black', 'light cyan'), +] |