mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Merge pull request #1982 from ujjwal96/preserve-marked-flows
Closes #1960 'Z' removes unmarked flows
This commit is contained in:
commit
3f26a0b5a5
@ -230,6 +230,17 @@ class View(collections.Sequence):
|
|||||||
self.sig_view_refresh.send(self)
|
self.sig_view_refresh.send(self)
|
||||||
self.sig_store_refresh.send(self)
|
self.sig_store_refresh.send(self)
|
||||||
|
|
||||||
|
def clear_not_marked(self):
|
||||||
|
"""
|
||||||
|
Clears only the unmarked flows.
|
||||||
|
"""
|
||||||
|
for flow in self._store.copy().values():
|
||||||
|
if not flow.marked:
|
||||||
|
self._store.pop(flow.id)
|
||||||
|
|
||||||
|
self._refilter()
|
||||||
|
self.sig_store_refresh.send(self)
|
||||||
|
|
||||||
def add(self, f: mitmproxy.flow.Flow) -> bool:
|
def add(self, f: mitmproxy.flow.Flow) -> bool:
|
||||||
"""
|
"""
|
||||||
Adds a flow to the state. If the flow already exists, it is
|
Adds a flow to the state. If the flow already exists, it is
|
||||||
|
@ -35,6 +35,7 @@ def _mkhelp():
|
|||||||
("W", "stream flows to file"),
|
("W", "stream flows to file"),
|
||||||
("X", "kill and delete flow, even if it's mid-intercept"),
|
("X", "kill and delete flow, even if it's mid-intercept"),
|
||||||
("z", "clear flow list or eventlog"),
|
("z", "clear flow list or eventlog"),
|
||||||
|
("Z", "clear unmarked flows"),
|
||||||
("tab", "tab between eventlog and flow list"),
|
("tab", "tab between eventlog and flow list"),
|
||||||
("enter", "view flow"),
|
("enter", "view flow"),
|
||||||
("|", "run script on this flow"),
|
("|", "run script on this flow"),
|
||||||
@ -354,6 +355,8 @@ class FlowListBox(urwid.ListBox):
|
|||||||
self.master.view.update(f)
|
self.master.view.update(f)
|
||||||
elif key == "z":
|
elif key == "z":
|
||||||
self.master.view.clear()
|
self.master.view.clear()
|
||||||
|
elif key == "Z":
|
||||||
|
self.master.view.clear_not_marked()
|
||||||
elif key == "e":
|
elif key == "e":
|
||||||
self.master.toggle_eventlog()
|
self.master.toggle_eventlog()
|
||||||
elif key == "g":
|
elif key == "g":
|
||||||
|
@ -108,6 +108,13 @@ def test_simple():
|
|||||||
assert list(v) == [f, f3, f2]
|
assert list(v) == [f, f3, f2]
|
||||||
assert len(v._store) == 3
|
assert len(v._store) == 3
|
||||||
|
|
||||||
|
f.marked = not f.marked
|
||||||
|
f2.marked = not f2.marked
|
||||||
|
v.clear_not_marked()
|
||||||
|
assert list(v) == [f, f2]
|
||||||
|
assert len(v) == 2
|
||||||
|
assert len(v._store) == 2
|
||||||
|
|
||||||
v.clear()
|
v.clear()
|
||||||
assert len(v) == 0
|
assert len(v) == 0
|
||||||
assert len(v._store) == 0
|
assert len(v._store) == 0
|
||||||
|
Loading…
Reference in New Issue
Block a user