ZOMBIE NODE protect & SWARM recovery

This commit is contained in:
qo-op 2021-06-04 02:42:23 +02:00
parent 06870b91fc
commit 0fed9ebf1e
1 changed files with 7 additions and 4 deletions

View File

@ -37,9 +37,12 @@ do
# Check if my like is reverse
liking_me_count=$((liking_me_count+1))
echo ">>>>>> CHECKING liking_me n° $liking_me_count : READING 'ipfstryme' message from $liking_me"
## Get "/tmp/ipfstryme.$liking_me" from Gchange "ipfstryme" message
~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" read -n300 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.content' > /tmp/ipfstryme.$liking_me
[[ $(cat /tmp/ipfstryme.$liking_me | wc -l) -gt 300 ]] && echo "## THIS NODE IS CONTAMINATED !!" && rm -f /tmp/ipfstryme.$liking_me && continue ## ZOMBIE NODE
## ZOMBIE NODE sends more that 300 ipfstryme ?
[[ $(cat /tmp/ipfstryme.$liking_me | wc -l) -gt 300 ]] && echo "THIS NODE IS A ZOMBIE..." && rm -f /tmp/ipfstryme.$liking_me && continue
for peerline in $(cat /tmp/ipfstryme.$liking_me);
do
echo "======================================================"
@ -47,10 +50,10 @@ do
echo "PEERLINE: $peerline"
ipfsnodeid=${peerline##*/} # http://mywiki.wooledge.org/BashFAQ/100
[[ "$ipfsnodeid" == "" ]] && continue
[[ $(cat ~/.zen/A_my_swarm.txt | grep $ipfsnodeid ) ]] && continue # ALREADY in my SWARM
# GET $whoisg1 FROM $peerline
## Remove Qm ipfs nodes
[[ ! "${ipfsnodeid:0:2}" == "Qm" ]] && whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) || echo "$ipfsnodeid" >> ~/.zen/A_Qm_swarm.txt && continue
[[ "${ipfsnodeid:0:2}" != "Qm" ]] && whoisg1=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py $ipfsnodeid) || echo "$ipfsnodeid" >> ~/.zen/A_Qm_swarm.txt && continue
# KEEPING LAST ipfstryme MESSAGES only
nbmessage=0
@ -132,7 +135,7 @@ for g1id in $(ls ~/.zen/ipfs/.$IPFSNODEID/FRIENDS);
do
if [[ -d ~/.zen/ipfs/.$IPFSNODEID/FRIENDS/$g1id ]]; then
ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $g1id)
ipfs swarm connect /ipfs/$ipfsnodeid
ipfs --timeout=10s swarm connect /ipfs/$ipfsnodeid
[[ $? == 0 ]] && ipfs swarm peers | grep $ipfsnodeid | tail -n 1 >> ~/.zen/A_my_swarm.txt
fi
done