mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 16:17:49 +00:00
implement a toggle for viewing marked flows only in console
This commit is contained in:
parent
ebaad91484
commit
dbc3e72723
@ -33,6 +33,8 @@ class ConsoleState(flow.State):
|
|||||||
self.default_body_view = contentviews.get("Auto")
|
self.default_body_view = contentviews.get("Auto")
|
||||||
self.flowsettings = weakref.WeakKeyDictionary()
|
self.flowsettings = weakref.WeakKeyDictionary()
|
||||||
self.last_search = None
|
self.last_search = None
|
||||||
|
self.last_filter = None
|
||||||
|
self.mark_filter = False
|
||||||
|
|
||||||
def __setattr__(self, name, value):
|
def __setattr__(self, name, value):
|
||||||
self.__dict__[name] = value
|
self.__dict__[name] = value
|
||||||
@ -106,6 +108,37 @@ class ConsoleState(flow.State):
|
|||||||
self.set_focus(self.focus)
|
self.set_focus(self.focus)
|
||||||
return ret
|
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):
|
def clear(self):
|
||||||
marked_flows = []
|
marked_flows = []
|
||||||
for f in self.flows:
|
for f in self.flows:
|
||||||
|
@ -21,6 +21,7 @@ def _mkhelp():
|
|||||||
("l", "set limit filter pattern"),
|
("l", "set limit filter pattern"),
|
||||||
("L", "load saved flows"),
|
("L", "load saved flows"),
|
||||||
("m", "toggle flow mark"),
|
("m", "toggle flow mark"),
|
||||||
|
("M", "toggle marked flow view"),
|
||||||
("n", "create a new request"),
|
("n", "create a new request"),
|
||||||
("P", "copy flow to clipboard"),
|
("P", "copy flow to clipboard"),
|
||||||
("r", "replay request"),
|
("r", "replay request"),
|
||||||
@ -197,6 +198,12 @@ class ConnectionItem(urwid.WidgetWrap):
|
|||||||
else:
|
else:
|
||||||
self.state.set_flow_marked(self.flow, True)
|
self.state.set_flow_marked(self.flow, True)
|
||||||
signals.flowlist_change.send(self)
|
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":
|
elif key == "r":
|
||||||
r = self.master.replay_request(self.flow)
|
r = self.master.replay_request(self.flow)
|
||||||
if r:
|
if r:
|
||||||
|
@ -163,6 +163,10 @@ class StatusBar(urwid.WidgetWrap):
|
|||||||
r.append("[")
|
r.append("[")
|
||||||
r.append(("heading_key", "l"))
|
r.append(("heading_key", "l"))
|
||||||
r.append(":%s]" % self.master.state.limit_txt)
|
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:
|
if self.master.stickycookie_txt:
|
||||||
r.append("[")
|
r.append("[")
|
||||||
r.append(("heading_key", "t"))
|
r.append(("heading_key", "t"))
|
||||||
|
Loading…
Reference in New Issue
Block a user