- Add luci-app-lyrion: Music server dashboard - Add luci-app-mailinabox: Email server management - Add luci-app-nextcloud: Cloud storage dashboard - Add luci-app-mitmproxy: Security proxy in security section - Add luci-app-magicmirror2: Smart display dashboard - Add secubox-app-metablogizer: CLI tool with uhttpd/nginx support - Update luci-app-metablogizer: Runtime selection, QR codes, social share - Update secubox-core v0.8.1: Service watchdog (auto-restart crashed services) - Update haproxyctl: Hostname validation to prevent config errors - Fix portal.js app discovery Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
57 lines
2.0 KiB
Bash
Executable File
57 lines
2.0 KiB
Bash
Executable File
#!/bin/sh
|
|
# RPCD backend for mitmproxy LuCI app
|
|
|
|
CONFIG="mitmproxy"
|
|
CONTAINER="secbx-mitmproxy"
|
|
|
|
uci_get() { uci -q get ${CONFIG}.main.$1; }
|
|
|
|
get_status() {
|
|
local enabled=$(uci_get enabled)
|
|
local web_port=$(uci_get web_port)
|
|
local proxy_port=$(uci_get proxy_port)
|
|
local data_path=$(uci_get data_path)
|
|
|
|
local docker_available=0
|
|
command -v docker >/dev/null 2>&1 && docker_available=1
|
|
|
|
local running=0
|
|
if [ "$docker_available" = "1" ]; then
|
|
docker ps --filter "name=$CONTAINER" --format "{{.Names}}" 2>/dev/null | grep -q "$CONTAINER" && running=1
|
|
fi
|
|
|
|
local installed=0
|
|
[ "$docker_available" = "1" ] && docker images --format "{{.Repository}}" 2>/dev/null | grep -q "mitmproxy" && installed=1
|
|
|
|
cat <<EOFJ
|
|
{
|
|
"enabled": $([ "$enabled" = "1" ] && echo "true" || echo "false"),
|
|
"running": $([ "$running" = "1" ] && echo "true" || echo "false"),
|
|
"installed": $([ "$installed" = "1" ] && echo "true" || echo "false"),
|
|
"docker_available": $([ "$docker_available" = "1" ] && echo "true" || echo "false"),
|
|
"web_port": ${web_port:-8081},
|
|
"proxy_port": ${proxy_port:-8080},
|
|
"data_path": "${data_path:-/srv/mitmproxy}"
|
|
}
|
|
EOFJ
|
|
}
|
|
|
|
do_install() {
|
|
command -v mitmproxyctl >/dev/null 2>&1 && { mitmproxyctl install >/tmp/mitmproxy-install.log 2>&1 & echo '{"success":true,"message":"Installing"}'; } || echo '{"success":false,"error":"mitmproxyctl not found"}'
|
|
}
|
|
|
|
do_start() { [ -x /etc/init.d/mitmproxy ] && /etc/init.d/mitmproxy start >/dev/null 2>&1; echo '{"success":true}'; }
|
|
do_stop() { [ -x /etc/init.d/mitmproxy ] && /etc/init.d/mitmproxy stop >/dev/null 2>&1; echo '{"success":true}'; }
|
|
do_restart() { [ -x /etc/init.d/mitmproxy ] && /etc/init.d/mitmproxy restart >/dev/null 2>&1; echo '{"success":true}'; }
|
|
|
|
list_methods() { cat <<'EOFM'
|
|
{"status":{},"install":{},"start":{},"stop":{},"restart":{}}
|
|
EOFM
|
|
}
|
|
|
|
case "$1" in
|
|
list) list_methods ;;
|
|
call) case "$2" in status) get_status ;; install) do_install ;; start) do_start ;; stop) do_stop ;; restart) do_restart ;; *) echo '{"error":"Unknown method"}' ;; esac ;;
|
|
*) echo '{"error":"Unknown command"}' ;;
|
|
esac
|