discord-bot/fail2ban/discord-notify.sh

32 lines
602 B
Bash
Raw Normal View History

2025-12-16 11:44:25 +09:00
#!/bin/bash
# fail2ban에서 IP 차단 시 디스코드 봇으로 알림을 보내는 스크립트
# 사용법: discord-notify.sh <ip> <jail> <failures>
# 봇 웹훅 URL
BOT_WEBHOOK_URL="http://localhost:5000/ban"
# 파라미터 받기
IP=$1
JAIL=$2
FAILURES=$3
# JSON 페이로드 생성
JSON_PAYLOAD=$(cat <<EOF
{
"ip": "${IP}",
"jail": "${JAIL}",
"failures": "${FAILURES}"
}
EOF
)
# 봇 웹훅으로 알림 전송
curl -H "Content-Type: application/json" \
-X POST \
-d "${JSON_PAYLOAD}" \
"${BOT_WEBHOOK_URL}" \
--silent --output /dev/null \
--max-time 5
exit 0