firewall/modules/module-nostr.sh
Your Name bec4acd12e fix
2024-09-25 10:07:41 -06:00

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