aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@corte.si>2017-04-29 09:58:32 +1200
committerAldo Cortesi <aldo@corte.si>2017-04-29 09:58:32 +1200
commit7317ea134e467dd0bc8ad9129dd8a417b0a0fdfd (patch)
treec1dbff334576f33a0fd3ef0cb4760cb2e878a641 /mitmproxy
parentf21a970f294486e47b183472ef9f535e2a661604 (diff)
downloadmitmproxy-7317ea134e467dd0bc8ad9129dd8a417b0a0fdfd.tar.gz
mitmproxy-7317ea134e467dd0bc8ad9129dd8a417b0a0fdfd.tar.bz2
mitmproxy-7317ea134e467dd0bc8ad9129dd8a417b0a0fdfd.zip
command: flow.kill, flow.replay
Plus the matching bindings in the flow list.
Diffstat (limited to 'mitmproxy')
-rw-r--r--mitmproxy/addons/core.py23
-rw-r--r--mitmproxy/tools/console/flowlist.py17
-rw-r--r--mitmproxy/tools/console/master.py3
3 files changed, 28 insertions, 15 deletions
diff --git a/mitmproxy/addons/core.py b/mitmproxy/addons/core.py
index 5728b9cc..215cbb4c 100644
--- a/mitmproxy/addons/core.py
+++ b/mitmproxy/addons/core.py
@@ -52,3 +52,26 @@ class Core:
for i in flows:
i.marked = not i.marked
ctx.master.addons.trigger("update", flows)
+
+ @command.command("flow.replay")
+ def replay(self, f: flow.Flow) -> None:
+ """
+ Replay an HTTP flow request.
+ """
+ try:
+ ctx.master.replay_request(f) # type: ignore
+ except exceptions.ReplayException as e:
+ raise exceptions.CommandError("Replay error: %s" % e) from e
+ ctx.master.addons.trigger("update", [f])
+
+ @command.command("flow.kill")
+ def kill(self, flows: typing.Sequence[flow.Flow]) -> None:
+ """
+ Kill running flows.
+ """
+ updated = []
+ for f in flows:
+ if f.killable:
+ f.kill()
+ updated.append(f)
+ ctx.master.addons.trigger("update", updated)
diff --git a/mitmproxy/tools/console/flowlist.py b/mitmproxy/tools/console/flowlist.py
index 5ca93a28..9f652bd9 100644
--- a/mitmproxy/tools/console/flowlist.py
+++ b/mitmproxy/tools/console/flowlist.py
@@ -1,6 +1,5 @@
import urwid
-from mitmproxy import exceptions
from mitmproxy.tools.console import common
from mitmproxy.tools.console import signals
from mitmproxy.addons import view
@@ -150,13 +149,7 @@ class FlowItem(urwid.WidgetWrap):
def keypress(self, xxx_todo_changeme, key):
(maxcol,) = xxx_todo_changeme
key = common.shortcuts(key)
- if key == "r":
- try:
- self.master.replay_request(self.flow)
- except exceptions.ReplayException as e:
- signals.add_log("Replay error: %s" % e, "warn")
- signals.flowlist_change.send(self)
- elif key == "S":
+ if key == "S":
def stop_server_playback(response):
if response == "y":
self.master.options.server_replay = []
@@ -186,10 +179,6 @@ class FlowItem(urwid.WidgetWrap):
self.flow.revert()
signals.flowlist_change.send(self)
signals.status_message.send(message="Reverted.")
- elif key == "X":
- if self.flow.killable:
- self.flow.kill()
- self.master.view.update(self.flow)
elif key == "|":
signals.status_prompt_path.send(
prompt = "Send flow to script",
@@ -303,9 +292,7 @@ class FlowListBox(urwid.ListBox):
def keypress(self, size, key):
key = common.shortcuts(key)
- if key == "Z":
- self.master.view.clear_not_marked()
- elif key == "L":
+ if key == "L":
signals.status_prompt_path.send(
self,
prompt = "Load flows",
diff --git a/mitmproxy/tools/console/master.py b/mitmproxy/tools/console/master.py
index 50a64006..6ddfcb81 100644
--- a/mitmproxy/tools/console/master.py
+++ b/mitmproxy/tools/console/master.py
@@ -157,10 +157,13 @@ def default_keymap(km):
km.add("g", "view.go 0", context="flowlist")
km.add("G", "view.go -1", context="flowlist")
km.add("m", "flow.mark.toggle @focus", context="flowlist")
+ km.add("r", "flow.replay @focus", context="flowlist")
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("X", "flow.kill @focus", context="flowlist")
km.add("z", "view.remove @all", context="flowlist")
+ km.add("Z", "view.remove @hidden", context="flowlist")
km.add("enter", "console.view.flow @focus", context="flowlist")