firewall/modules/module-nostr.sh
Your Name 5b25040de2 fiux
2024-09-25 19:49:34 -06:00

16 lines
485 B
Bash

#!/bin/bash
POLICY='/opt/strfry-policies/strfry-policy.ts'
FIREWALL="/opt/firewall/firewall.sh"
IP=($(grep $2 $3 | 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