firewall/modules/module-nostr.sh

16 lines
485 B
Bash
Raw Normal View History

2024-09-24 21:35:46 -06:00
#!/bin/bash
2024-09-25 10:07:41 -06:00
POLICY='/opt/strfry-policies/strfry-policy.ts'
2024-09-24 21:35:46 -06:00
FIREWALL="/opt/firewall/firewall.sh"
2024-09-25 19:49:34 -06:00
IP=($(grep $2 $3 | grep "/block=" | cut -d '=' -f2 | cut -d ' ' -f1 | sed 's/"//'))
2024-09-24 21:35:46 -06:00
for i in "${IP[@]}"; do
if [[ "$i" == *"npub"* ]]; then
2024-09-25 10:07:41 -06:00
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
2024-09-24 21:35:46 -06:00
else
echo "No Npubs to block"
fi
done