Implemented basic marking of flows

- Press m to toggle flow mark
- Flow mark is set in libmproxy/console/common.py. Currently set to "==="
This commit is contained in:
Jake Drahos 2015-06-11 10:27:48 -05:00
parent d389b9c59d
commit 8b998cfbea
3 changed files with 22 additions and 0 deletions

View File

@ -115,6 +115,7 @@ def fcol(s, attr):
if urwid.util.detected_encoding:
SYMBOL_REPLAY = u"\u21ba"
SYMBOL_RETURN = u"\u2190"
SYMBOL_MARK = "==="
else:
SYMBOL_REPLAY = u"[r]"
SYMBOL_RETURN = u"<-"
@ -133,6 +134,10 @@ def raw_format_flow(f, focus, extended, padding):
)
else:
req.append(fcol(">>" if focus else " ", "focus"))
if f["marked"]:
req.append(fcol(SYMBOL_MARK, "mark"))
if f["req_is_replay"]:
req.append(fcol(SYMBOL_REPLAY, "replay"))
req.append(fcol(f["req_method"], "method"))
@ -384,6 +389,8 @@ def format_flow(f, focus, extended=False, hostheader=False, padding=2):
err_msg = f.error.msg if f.error else None,
resp_code = f.response.code if f.response else None,
marked = f.marked,
)
if f.response:
if f.response.content:

View File

@ -17,6 +17,7 @@ def _mkhelp():
("F", "toggle follow flow list"),
("l", "set limit filter pattern"),
("L", "load saved flows"),
("m", "toggle flow mark"),
("n", "create a new request"),
("P", "copy flow to clipboard"),
("r", "replay request"),
@ -177,6 +178,13 @@ class ConnectionItem(urwid.WidgetWrap):
elif key == "D":
f = self.master.duplicate_flow(self.flow)
self.master.view_flow(f)
elif key == "m":
self.flow.toggle_mark()
signals.flowlist_change.send(self)
if self.flow.marked:
signals.status_message.send(message="Flow is now marked")
else:
signals.status_message.send(message="Flow is now not marked")
elif key == "r":
r = self.master.replay_request(self.flow)
if r:

View File

@ -77,6 +77,7 @@ class Flow(stateobject.StateObject):
"""@type: bool"""
self._backup = None
self.reply = None
self.marked = False
_stateobject_attributes = dict(
id=str,
@ -165,6 +166,12 @@ class Flow(stateobject.StateObject):
self.intercepted = False
self.reply()
master.handle_accept_intercept(self)
def toggle_mark(self):
if self.marked:
self.marked = False
else:
self.marked = True
class ProtocolHandler(object):