All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 10s
34 lines
909 B
Bash
Executable File
34 lines
909 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
usage() {
|
|
echo "Usage: tools/teardown_bridge_capture.sh --bridge <bridge> [--mirror-if mitmcap0] [--capture-if mitmcap1]"
|
|
}
|
|
|
|
BRIDGE=""
|
|
MIRROR_IF="mitmcap0"
|
|
CAPTURE_IF="mitmcap1"
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--bridge) BRIDGE="$2"; shift 2 ;;
|
|
--mirror-if) MIRROR_IF="$2"; shift 2 ;;
|
|
--capture-if) CAPTURE_IF="$2"; shift 2 ;;
|
|
-h|--help) usage; exit 0 ;;
|
|
*) echo "Unknown argument: $1" >&2; usage; exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
if [[ -n "$BRIDGE" ]] && ip link show "$BRIDGE" >/dev/null 2>&1; then
|
|
while read -r port; do
|
|
[[ -n "$port" ]] || continue
|
|
tc qdisc del dev "$port" clsact 2>/dev/null || true
|
|
done < <(bridge link show master "$BRIDGE" | awk -F': ' '{print $2}' | awk '{print $1}')
|
|
fi
|
|
|
|
tc qdisc del dev "$CAPTURE_IF" clsact 2>/dev/null || true
|
|
|
|
if ip link show "$MIRROR_IF" >/dev/null 2>&1; then
|
|
ip link del "$MIRROR_IF"
|
|
fi
|