summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Bobov <anton@bobov.name>2025-02-08 00:44:38 +0500
committerAnton Bobov <anton@bobov.name>2025-02-08 00:44:38 +0500
commit2d76aa94d9bca6d08a31d5f94721c390227993f1 (patch)
tree07f76b858e22c5982884c9d94831ceacd4e3db3a
parent5b3b31b515ddc3940edfaf1a2edd29a0de66d44f (diff)
Update mitm-chrome
Use mitmweb by default.
-rwxr-xr-xmitm-chrome29
1 files changed, 18 insertions, 11 deletions
diff --git a/mitm-chrome b/mitm-chrome
index f154b1a..3fc84ac 100755
--- a/mitm-chrome
+++ b/mitm-chrome
@@ -1,17 +1,24 @@
-#!/bin/bash
+#!/usr/bin/env bash
-set -e
+set -euo pipefail
+
+MITM_COMMAND=${MITM_COMMAND:-mitmweb}
check_command() {
- if ! command -v "$1" &>/dev/null ; then
- echo "No $1 found."
- exit 1
- fi
+ if ! command -v "$1" &>/dev/null; then
+ echo "No $1 found."
+ exit 1
+ fi
}
-check_command chromium
-check_command mitmproxy
+main() {
+ check_command chromium
+ check_command "$MITM_COMMAND"
+
+ PROXY_PORT=38752
+ HTTP_PROXY=http://localhost:$PROXY_PORT
+ chromium --proxy-server=$HTTP_PROXY --temp-profile "$@" >/dev/null 2>&1 &
+ "$MITM_COMMAND" --listen-port=$PROXY_PORT
+}
-PROXY_PORT=38752
-HTTP_PROXY=http://localhost:$PROXY_PORT chromium --temp-profile "$@" >/dev/null 2>&1 &
-mitmproxy --listen-port=$PROXY_PORT
+main "$@"