notifications
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
# Lizenz: MIT
|
# Lizenz: MIT
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
VERSION="0.4.0"
|
VERSION="0.3.1"
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
@@ -228,6 +228,12 @@ write_pid() {
|
|||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
log "INFO" "AdGuard Shield wird beendet..."
|
log "INFO" "AdGuard Shield wird beendet..."
|
||||||
|
# Service-Stop-Benachrichtigung senden
|
||||||
|
if [[ "${NOTIFY_ENABLED:-false}" == "true" ]]; then
|
||||||
|
send_notification "service_stop" "" "" ""
|
||||||
|
# Kurz warten damit die Benachrichtigung gesendet wird (curl läuft im Hintergrund)
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
stop_blocklist_worker
|
stop_blocklist_worker
|
||||||
rm -f "$PID_FILE"
|
rm -f "$PID_FILE"
|
||||||
exit 0
|
exit 0
|
||||||
@@ -454,6 +460,10 @@ send_notification() {
|
|||||||
simple_dur=$(format_duration "${BAN_DURATION}")
|
simple_dur=$(format_duration "${BAN_DURATION}")
|
||||||
message="🚫 AdGuard Shield: Client **$client_ip** gesperrt (${count}x $domain in ${RATE_LIMIT_WINDOW}s). Sperre für ${simple_dur}."
|
message="🚫 AdGuard Shield: Client **$client_ip** gesperrt (${count}x $domain in ${RATE_LIMIT_WINDOW}s). Sperre für ${simple_dur}."
|
||||||
fi
|
fi
|
||||||
|
elif [[ "$action" == "service_start" ]]; then
|
||||||
|
message="🟢 AdGuard Shield v${VERSION} wurde gestartet."
|
||||||
|
elif [[ "$action" == "service_stop" ]]; then
|
||||||
|
message="🔴 AdGuard Shield v${VERSION} wurde gestoppt."
|
||||||
else
|
else
|
||||||
message="✅ AdGuard Shield: Client **$client_ip** wurde entsperrt."
|
message="✅ AdGuard Shield: Client **$client_ip** wurde entsperrt."
|
||||||
fi
|
fi
|
||||||
@@ -480,7 +490,7 @@ send_notification() {
|
|||||||
;;
|
;;
|
||||||
generic)
|
generic)
|
||||||
curl -s -H "Content-Type: application/json" \
|
curl -s -H "Content-Type: application/json" \
|
||||||
-d "{\"message\": \"$message\", \"action\": \"$action\", \"client\": \"$client_ip\", \"domain\": \"$domain\"}" \
|
-d "{\"message\": \"$message\", \"action\": \"$action\", \"client\": \"${client_ip:-}\", \"domain\": \"${domain:-}\"}" \
|
||||||
"$NOTIFY_WEBHOOK_URL" &>/dev/null &
|
"$NOTIFY_WEBHOOK_URL" &>/dev/null &
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -503,6 +513,10 @@ send_ntfy_notification() {
|
|||||||
|
|
||||||
if [[ "$action" == "ban" ]]; then
|
if [[ "$action" == "ban" ]]; then
|
||||||
tags="rotating_light,ban"
|
tags="rotating_light,ban"
|
||||||
|
elif [[ "$action" == "service_start" ]]; then
|
||||||
|
tags="green_circle,start"
|
||||||
|
elif [[ "$action" == "service_stop" ]]; then
|
||||||
|
tags="red_circle,stop"
|
||||||
else
|
else
|
||||||
tags="white_check_mark,unban"
|
tags="white_check_mark,unban"
|
||||||
fi
|
fi
|
||||||
@@ -843,6 +857,11 @@ main_loop() {
|
|||||||
fi
|
fi
|
||||||
log "INFO" "═══════════════════════════════════════════════════════════"
|
log "INFO" "═══════════════════════════════════════════════════════════"
|
||||||
|
|
||||||
|
# Service-Start-Benachrichtigung senden
|
||||||
|
if [[ "${NOTIFY_ENABLED:-false}" == "true" ]]; then
|
||||||
|
send_notification "service_start" "" "" ""
|
||||||
|
fi
|
||||||
|
|
||||||
# Blocklist-Worker als Hintergrundprozess starten
|
# Blocklist-Worker als Hintergrundprozess starten
|
||||||
start_blocklist_worker
|
start_blocklist_worker
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Webhook-Benachrichtigungen
|
# Webhook-Benachrichtigungen
|
||||||
|
|
||||||
Das Tool kann bei Sperren und Entsperrungen Benachrichtigungen an verschiedene Dienste senden.
|
Das Tool kann beim Starten und Stoppen des Services sowie bei Sperren und Entsperrungen Benachrichtigungen an verschiedene Dienste senden.
|
||||||
|
|
||||||
## Aktivierung
|
## Aktivierung
|
||||||
|
|
||||||
@@ -103,6 +103,12 @@ Sendet einen POST mit JSON-Body:
|
|||||||
|
|
||||||
## Beispiel-Nachrichten
|
## Beispiel-Nachrichten
|
||||||
|
|
||||||
|
**Service gestartet:**
|
||||||
|
> 🟢 AdGuard Shield v0.4.0 wurde gestartet.
|
||||||
|
|
||||||
|
**Service gestoppt:**
|
||||||
|
> 🔴 AdGuard Shield v0.4.0 wurde gestoppt.
|
||||||
|
|
||||||
**Sperre:**
|
**Sperre:**
|
||||||
> 🚫 AdGuard Shield: Client **192.168.1.50** gesperrt (45x microsoft.com in 60s). Sperre für 3600s.
|
> 🚫 AdGuard Shield: Client **192.168.1.50** gesperrt (45x microsoft.com in 60s). Sperre für 3600s.
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
# Lizenz: MIT
|
# Lizenz: MIT
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
VERSION="0.3.0"
|
VERSION="0.3.1"
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user