mirror of
https://github.com/zhigang1992/mitmproxy.git
synced 2026-01-12 22:48:54 +08:00
@@ -63,4 +63,19 @@ class Core:
|
||||
if f.killable:
|
||||
f.kill()
|
||||
updated.append(f)
|
||||
ctx.log.alert("Killed %s flows." % len(updated))
|
||||
ctx.master.addons.trigger("update", updated)
|
||||
|
||||
# FIXME: this will become view.revert later
|
||||
@command.command("flow.revert")
|
||||
def revert(self, flows: typing.Sequence[flow.Flow]) -> None:
|
||||
"""
|
||||
Revert flow changes.
|
||||
"""
|
||||
updated = []
|
||||
for f in flows:
|
||||
if f.modified():
|
||||
f.revert()
|
||||
updated.append(f)
|
||||
ctx.log.alert("Reverted %s flows." % len(updated))
|
||||
ctx.master.addons.trigger("update", updated)
|
||||
|
||||
@@ -141,14 +141,7 @@ class FlowItem(urwid.WidgetWrap):
|
||||
def keypress(self, xxx_todo_changeme, key):
|
||||
(maxcol,) = xxx_todo_changeme
|
||||
key = common.shortcuts(key)
|
||||
if key == "V":
|
||||
if not self.flow.modified():
|
||||
signals.status_message.send(message="Flow not modified.")
|
||||
return
|
||||
self.flow.revert()
|
||||
signals.flowlist_change.send(self)
|
||||
signals.status_message.send(message="Reverted.")
|
||||
elif key == "|":
|
||||
if key == "|":
|
||||
signals.status_prompt_path.send(
|
||||
prompt = "Send flow to script",
|
||||
callback = self.master.run_script_once,
|
||||
|
||||
@@ -166,6 +166,7 @@ def default_keymap(km):
|
||||
km.add("v", "set console_order_reversed=toggle", context="flowlist")
|
||||
km.add("U", "flow.mark @all false", context="flowlist")
|
||||
km.add("w", "console.command 'save.file @shown '", context="flowlist")
|
||||
km.add("V", "flow.revert @focus", context="flowlist")
|
||||
km.add("X", "flow.kill @focus", context="flowlist")
|
||||
km.add("z", "view.remove @all", context="flowlist")
|
||||
km.add("Z", "view.remove @hidden", context="flowlist")
|
||||
|
||||
@@ -50,3 +50,14 @@ def test_kill():
|
||||
assert f.killable
|
||||
sa.kill([f])
|
||||
assert not f.killable
|
||||
|
||||
|
||||
def test_revert():
|
||||
sa = core.Core()
|
||||
with taddons.context():
|
||||
f = tflow.tflow()
|
||||
f.backup()
|
||||
f.request.content = b"bar"
|
||||
assert f.modified()
|
||||
sa.revert([f])
|
||||
assert not f.modified()
|
||||
|
||||
Reference in New Issue
Block a user