firewall/modules/module-akkoma-instance.sh

20 lines
558 B
Bash
Raw Normal View History

2024-09-24 21:27:33 -06:00
#!/bin/bash
FIREWALL="/opt/firewall/firewall.sh"
2024-09-24 21:56:20 -06:00
NFT_CACHE='/tmp/nft.cache'
2024-09-24 22:30:26 -06:00
ATTACK="module-akkoma-instance"
2024-09-25 19:49:34 -06:00
COUNT_SPAM=$(grep $2 $3 | grep -E "api/v1/instance" | grep $1 | wc -l)
2024-09-25 19:23:57 -06:00
SEARCH_SPAM=$(($COUNT_SPAM))
2024-09-24 21:27:33 -06:00
CHECK=$(cat $NFT_CACHE | sort -u | grep $1)
2024-09-25 19:23:57 -06:00
if [[ $SEARCH_SPAM -gt 30 ]]; then
2024-09-24 21:27:33 -06:00
echo "$IP $CHECK $COUNT"
if [ "$CHECK" = "" ]; then
2024-09-24 21:56:20 -06:00
bash $FIREWALL ipBlockParser "$1"
2024-09-24 22:30:26 -06:00
bash $FIREWALL message "$ATTACK-$1"
2024-09-24 21:27:33 -06:00
redis-cli SADD tmp_block $1
2024-09-25 22:33:17 -06:00
cp -f $3 /tmp/debug-$ATTACK-$1.txt
2024-09-24 21:27:33 -06:00
echo "$ATTACK $1"
else
echo "$ATTACK Ignoring Duplicate IP: $1"
fi
fi