Skip to content

Instantly share code, notes, and snippets.

@buzzkillb
Last active June 19, 2021 18:10
Show Gist options
  • Save buzzkillb/5192fe6ef3e2c2031986df49a2e1680a to your computer and use it in GitHub Desktop.
Save buzzkillb/5192fe6ef3e2c2031986df49a2e1680a to your computer and use it in GitHub Desktop.
#########
# Remove the # from the UFW lines to make this fully work
#########
#!/bin/bash
. config.conf
. rpc.sh
wallet_ip=$(rpc_get_peerinfo | jq -r '.[].addr' | awk '!seen[$0]++')
while IFS= read -r
do
subver=$(rpc_get_peerinfo | jq -r --arg ADDRESS "$REPLY" '[.[] | select(.addr == $ADDRESS) | .subver ]')
if [[ $subver == *"3.3.9.13"* ]]; then
echo "String is found, current wallet."
echo $subver
ip_noport=$(echo $REPLY | cut -f1 -d":")
echo $ip_noport
else
echo "---------------------------"
echo "Strings are not equal."
echo "gonna ban"
ip_noportban=$(echo $REPLY | cut -f1 -d":")
echo $ip_noportban
#sudo ufw insert 1 deny out from any to $ip_noportban comment 'Block denarius spammer'
#sudo ufw insert 1 deny from $ip_noportban comment 'Block denarius spammer'
fi
done <<< "$wallet_ip"
#reload ufw
#sudo ufw reload
#sudo ufw status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment