···
programs.zsh.initContent = ''
eval "$(/usr/libexec/path_helper)"
43
+
# MITM proxy management functions
44
+
MITM_SERVICE="Wi-Fi" # Change to "Ethernet" if needed
45
+
MITM_CERT="$HOME/.mitmproxy/mitmproxy-ca-cert.pem"
48
+
# Generate mitmproxy CA certificate if it doesn't exist
49
+
if [ ! -f "$MITM_CERT" ]; then
50
+
echo "Generating mitmproxy CA certificate..."
51
+
(timeout 0.1 mitmproxy --set confdir="$HOME/.mitmproxy" 2>/dev/null; true)
54
+
networksetup -setwebproxy "$MITM_SERVICE" localhost 8080 &&
55
+
networksetup -setsecurewebproxy "$MITM_SERVICE" localhost 8080 &&
56
+
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain "$MITM_CERT" &&
57
+
echo "mitmproxy enabled and cert added"
61
+
networksetup -setwebproxystate "$MITM_SERVICE" off &&
62
+
networksetup -setsecurewebproxystate "$MITM_SERVICE" off &&
63
+
sudo security delete-certificate -c mitmproxy /Library/Keychains/System.keychain &&
64
+
echo "mitmproxy disabled and cert removed"
70
+
NC='\033[0m' # No Color
72
+
echo "========== Proxy Status =========="
73
+
for proto in webproxy securewebproxy; do
74
+
proxy_status=$(networksetup -get''${proto} "$MITM_SERVICE")
75
+
enabled=$(echo "$proxy_status" | grep "Enabled: Yes")
76
+
PROTO_UPPER=$(echo "$proto" | tr '[:lower:]' '[:upper:]')
77
+
if [ -n "$enabled" ]; then
78
+
echo -e "''${PROTO_UPPER} : ''${GREEN}ENABLED''${NC}"
80
+
echo -e "''${PROTO_UPPER} : ''${RED}DISABLED''${NC}"
82
+
echo "$proxy_status" | grep -E "Server:|Port:"
85
+
echo "========== mitmproxy Certificate =========="
86
+
if security find-certificate -c mitmproxy /Library/Keychains/System.keychain > /dev/null 2>&1; then
87
+
echo -e "mitmproxy certificate: ''${GREEN}PRESENT''${NC}"
89
+
echo -e "mitmproxy certificate: ''${RED}NOT PRESENT''${NC}"
92
+
echo "========== mitmproxy Process =========="
93
+
if pgrep -f mitmproxy > /dev/null; then
94
+
echo -e "mitmproxy process: ''${GREEN}RUNNING''${NC}"
96
+
echo -e "mitmproxy process: ''${RED}NOT RUNNING''${NC}"
98
+
echo "==========================================="
# Let Home Manager install and manage itself