17 lines
515 B
Bash
17 lines
515 B
Bash
#!/bin/bash
|
|
POLICY='/opt/strfry-policies/strfry-policy.ts'
|
|
FIREWALL="/opt/firewall/firewall.sh"
|
|
ACCESS="/tmp/minute.log"
|
|
IP=($(grep $2 $ACCESS | grep "/block=" | cut -d '=' -f2 | cut -d ' ' -f1 | sed 's/"//'))
|
|
for i in "${IP[@]}"; do
|
|
if [[ "$i" == *"npub"* ]]; then
|
|
HEX=$(/opt/nak-v0.2.2-linux-amd64 decode $i | jq ".pubkey" | sed 's/"//i' | sed 's/"//i')
|
|
sed -i "29i '$HEX'," $POLICY
|
|
sed -i "s/\'\'//g" $POLICY
|
|
sed -i "s/'',//g" $POLICY
|
|
sed -i '/^$/d' $POLICY
|
|
else
|
|
echo "No Npubs to block"
|
|
fi
|
|
done
|