aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2016-06-03 15:05:18 +1200
committerAldo Cortesi <aldo@corte.si>2016-06-03 15:05:18 +1200
commit1ab64da68245b80c701fadee6a4ddf59bd245cc6 (patch)
tree0d96279d15f69a95e46a5eff9e50e3af6058653c
parent08e4cd2a40778a1a10eef1bba0d2c167f6edeea9 (diff)
parentdbc3e727231b55fc86b22cb58f901eba0bf40411 (diff)
downloadmitmproxy-1ab64da68245b80c701fadee6a4ddf59bd245cc6.tar.gz
mitmproxy-1ab64da68245b80c701fadee6a4ddf59bd245cc6.tar.bz2
mitmproxy-1ab64da68245b80c701fadee6a4ddf59bd245cc6.zip
Merge pull request #1167 from xntrik/mark_filter
implement a toggle for viewing marked flows only in console
-rw-r--r--mitmproxy/console/__init__.py33
-rw-r--r--mitmproxy/console/flowlist.py7
-rw-r--r--mitmproxy/console/statusbar.py4
3 files changed, 44 insertions, 0 deletions
diff --git a/mitmproxy/console/__init__.py b/mitmproxy/console/__init__.py
index 00fb4b1b..63692ec0 100644
--- a/mitmproxy/console/__init__.py
+++ b/mitmproxy/console/__init__.py
@@ -44,6 +44,8 @@ class ConsoleState(flow.State):
self.default_body_view = contentviews.get("Auto")
self.flowsettings = weakref.WeakKeyDictionary()
self.last_search = None
+ self.last_filter = None
+ self.mark_filter = False
def __setattr__(self, name, value):
self.__dict__[name] = value
@@ -117,6 +119,37 @@ class ConsoleState(flow.State):
self.set_focus(self.focus)
return ret
+ def filter_marked(self, m):
+ def actual_func(x):
+ if x.id in m:
+ return True
+ return False
+ return actual_func
+
+ def enable_marked_filter(self):
+ self.last_filter = self.limit_txt
+ marked_flows = []
+ for f in self.flows:
+ if self.flow_marked(f):
+ marked_flows.append(f.id)
+ if len(marked_flows) > 0:
+ f = self.filter_marked(marked_flows)
+ self.view._close()
+ self.view = flow.FlowView(self.flows, f)
+ self.focus = 0
+ self.set_focus(self.focus)
+ self.mark_filter = True
+
+ def disable_marked_filter(self):
+ if self.last_filter is None:
+ self.view = flow.FlowView(self.flows, None)
+ else:
+ self.set_limit(self.last_filter)
+ self.focus = 0
+ self.set_focus(self.focus)
+ self.last_filter = None
+ self.mark_filter = False
+
def clear(self):
marked_flows = []
for f in self.flows:
diff --git a/mitmproxy/console/flowlist.py b/mitmproxy/console/flowlist.py
index eb1e76fb..8c20c4b6 100644
--- a/mitmproxy/console/flowlist.py
+++ b/mitmproxy/console/flowlist.py
@@ -22,6 +22,7 @@ def _mkhelp():
("l", "set limit filter pattern"),
("L", "load saved flows"),
("m", "toggle flow mark"),
+ ("M", "toggle marked flow view"),
("n", "create a new request"),
("P", "copy flow to clipboard"),
("r", "replay request"),
@@ -198,6 +199,12 @@ class ConnectionItem(urwid.WidgetWrap):
else:
self.state.set_flow_marked(self.flow, True)
signals.flowlist_change.send(self)
+ elif key == "M":
+ if self.state.mark_filter:
+ self.state.disable_marked_filter()
+ else:
+ self.state.enable_marked_filter()
+ signals.flowlist_change.send(self)
elif key == "r":
r = self.master.replay_request(self.flow)
if r:
diff --git a/mitmproxy/console/statusbar.py b/mitmproxy/console/statusbar.py
index b3e1517f..af8089b6 100644
--- a/mitmproxy/console/statusbar.py
+++ b/mitmproxy/console/statusbar.py
@@ -168,6 +168,10 @@ class StatusBar(urwid.WidgetWrap):
r.append("[")
r.append(("heading_key", "l"))
r.append(":%s]" % self.master.state.limit_txt)
+ if self.master.state.mark_filter:
+ r.append("[")
+ r.append(("heading_key", "Marked Flows"))
+ r.append("]")
if self.master.stickycookie_txt:
r.append("[")
r.append(("heading_key", "t"))