From 88d43b51bb99840766e58ac6fed3cebf4548aac9 Mon Sep 17 00:00:00 2001 From: Martin Plattner Date: Fri, 4 Sep 2020 18:39:08 +0200 Subject: [PATCH] tweak cli recordings --- docs/scripts/clirecording/clidirector.py | 14 ++++++++------ docs/scripts/clirecording/screenplays.py | 17 ++++++++++++----- .../content/mitmproxytutorial-replayrequests.md | 2 ++ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/docs/scripts/clirecording/clidirector.py b/docs/scripts/clirecording/clidirector.py index f671b5821..f674e276e 100644 --- a/docs/scripts/clirecording/clidirector.py +++ b/docs/scripts/clirecording/clidirector.py @@ -67,12 +67,14 @@ class CliDirector: target.send_keys(cmd=keys, enter=False, suppress_history=False) # inspired by https://github.com/dmotz/TuringType - real_pause = random.uniform(0, pause) + 0.3 * pause - if keys == "Space" or keys == "," or keys == ".": - real_pause += random.uniform(0, pause) - if random.random() > 0.7: + real_pause = random.uniform(0, pause) + 0.4 * pause + if keys == "Space": + real_pause += 1.5 * pause + elif keys == ".": real_pause += pause - if random.random() > 0.95: + elif random.random() > 0.75: + real_pause += pause + elif random.random() > 0.95: real_pause += 2 * pause self.pause(real_pause) @@ -106,7 +108,7 @@ class CliDirector: def message(self, msg: str, duration: typing.Optional[int] = None, add_instruction: bool = True, instruction_html: str = "") -> None: if duration is None: - duration = len(msg) * 0.1 # seconds + duration = len(msg) * 0.08 # seconds self.tmux_session.set_option("display-time", int(duration * 1000)) # milliseconds self.tmux_pane.display_message(" " + msg) diff --git a/docs/scripts/clirecording/screenplays.py b/docs/scripts/clirecording/screenplays.py index 2ca657c03..6c482ded7 100644 --- a/docs/scripts/clirecording/screenplays.py +++ b/docs/scripts/clirecording/screenplays.py @@ -94,6 +94,8 @@ def record_user_interface(d: CliDirector): d.message("You now know basics of mitmproxy’s UI and how to control it.") d.pause(1) + + d.message("In the next lesson you will learn to intercept flows.") d.save_instructions("recordings/mitmproxy_user_interface_instructions.json") d.end() @@ -152,10 +154,13 @@ def record_intercept_requests(d: CliDirector): d.focus_pane(pane_top) d.press_key("Down") + d.pause(1) d.message("Press `X` to kill this flow, i.e., discard it without forwarding it to its final destination `wttr.in`.") d.type("X") d.pause(3) + + d.message("In the next lesson you will learn to modify intercepted flows.") d.save_instructions("recordings/mitmproxy_intercept_requests_instructions.json") d.end() @@ -227,6 +232,7 @@ def record_modify_requests(d: CliDirector): d.message("You see that the request URL was modified and `wttr.in` replied with the weather report for `Innsbruck`.") + d.message("In the next lesson you will learn to replay flows.") d.save_instructions("recordings/mitmproxy_modify_requests_instructions.json") d.end() @@ -255,17 +261,18 @@ def record_replay_requests(d: CliDirector): d.focus_pane(pane_top) - d.message("We now want to replay the intercepted request.") - d.message("Put the focus (`>>`) on the intercepted flow. This is already the case in our example.") - d.message("Press `r` to replay this flow.") + d.message("We now want to replay the this request.") + d.message("Put the focus (`>>`) on the request that should be replayed. This is already the case in our example.") + d.message("Press `r` to replay the request.") d.type("r") d.message("Note that no new rows are added for replayed flows, but the existing row is updated.") d.message("Every time you press `r`, mitmproxy sends this request to the server again and updates the flow.") - d.press_key("r", count=6, pause=0.75) + d.press_key("r", count=4, pause=1) d.message("You can also modify a flow before replaying it.") - d.message("It works as shown in the previous tutorial by pressing `e`.") + d.message("It works as shown in the previous lesson, by pressing `e`.") + d.message("Congratulations! You have completed all lessons of the mitmproxy tutorial.") d.save_instructions("recordings/mitmproxy_replay_requests_instructions.json") d.end() diff --git a/docs/src/content/mitmproxytutorial-replayrequests.md b/docs/src/content/mitmproxytutorial-replayrequests.md index cd895798e..97a0acd73 100644 --- a/docs/src/content/mitmproxytutorial-replayrequests.md +++ b/docs/src/content/mitmproxytutorial-replayrequests.md @@ -18,3 +18,5 @@ In this tutorial we focus on the more common use case of client-side replays. See the docs for more info on [server-side replay]({{< relref "concepts-advancedfeatures#server-side-replay" >}}). {{% asciicast file="mitmproxy_replay_requests" poster="0:3" instructions=true %}} + +You are almost done with this tutorial. In the last step you find more mitmproxy-related resources to discover.