**ACLs (Access Control Lists):** - Ajout du type AclConfig dans sources/event.v (allowed_ips CIDR + allowed_tokens) - Chaque source webhook (Gitea, Uptime Kuma, Cron, Generic) supporte les ACLs - Validation IP via X-Forwarded-For / X-Real-IP avant HMAC - Validation Bearer token via Authorization header - Tests: 7 tests ACL (IP exact, CIDR, parse IPv4, ACL vide, IP+token combiné) **Plugin system:** - sources/plugin.v: runner exécutable externe, stdout JSON → Event - Exit 0 = publish, exit ≠ 0 = skip. Timeout configurable - Plugin loop dans server.v (goroutine, toutes les 60s) - Example: scripts/example-plugin-disk.sh (vérifie espace disque) **Docs:** - README.md: ajout source Plugin + section Features complète - ARCHITECTURE.md: flux Plugin, flux ACL, endpoints /metrics /api/silence - ROADMAP.md: Phase 5 → 8/8 complet, ajout v0.6.0 - ntfy-bridge.example.yaml: sections ACLs et Plugins commentées - Version bump: 0.5.0 → 0.6.0
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
# Example ntfy-bridge plugin — disk space checker
|
||||
#
|
||||
# A plugin receives nothing on stdin (when polled) and outputs a JSON
|
||||
# Event object on stdout. Exit 0 = send, exit 1 = skip/drop.
|
||||
#
|
||||
# Fields: source, name, topic, priority (1-5), message, tags[], click_url, actions[]
|
||||
|
||||
THRESHOLD=90
|
||||
USAGE=$(df -h / | tail -1 | awk '{print $5}' | sed 's/%//')
|
||||
|
||||
if [ "$USAGE" -lt "$THRESHOLD" ]; then
|
||||
# No alert needed — exit non-zero to skip
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Output a JSON Event to stdout
|
||||
cat <<EOF
|
||||
{
|
||||
"source": "plugin",
|
||||
"name": "disk-check",
|
||||
"topic": "daily",
|
||||
"priority": 4,
|
||||
"message": "💾 **Disk usage: ${USAGE}%**\nThreshold: ${THRESHOLD}%\nHost: $(hostname)",
|
||||
"tags": ["warning"]
|
||||
}
|
||||
EOF
|
||||
Reference in New Issue
Block a user