stop propagating all swam peers address, only friends

This commit is contained in:
qo-op 2021-05-15 21:05:28 +02:00
parent fb6235ba8a
commit 0392c3ea73
1 changed files with 10 additions and 1 deletions

View File

@ -24,6 +24,13 @@ mkdir -p ~/.zen/ipfs/.${IPFSNODEID}
rm -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
touch ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
########################################################################
## If my address is published by my friends, sending it only.
# ME=$(cat ~/.zen/ipfs/.*/FRIENDS/*/tryme.addr | grep $IPFSNODEID | sort | uniq)
# [[ $ME ]] && cat ~/.zen/ipfs/.*/FRIENDS/*/tryme.addr | grep $IPFSNODEID | sort | uniq > ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr && exit 0
########################################################################
for tryme in $(ipfs id | jq -r .Addresses[]);
do
isLAN=$(echo $tryme | cut -f3 -d '/' | grep -E "(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
@ -33,8 +40,10 @@ done
# Now adding "ipfs swarm peers" to ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
for tryme in $(ipfs swarm peers);
do
ipfsnodeid=$(echo $tryme | rev | cut -d '/' -f 1 | rev)
isMySWARM=$(cat ~/.zen/astrXbian/A_my_swarm.txt | grep $ipfsnodeid )
isLAN=$(echo $tryme | cut -f3 -d '/' | grep -E "(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
[[ ! $isLAN ]] && echo "$tryme" >> ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr && echo "$tryme"
[[ ! $isLAN ]] && [[ $isMySWARM ]] && echo "$tryme" >> ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr && echo "$tryme" || ipfs swarm disconnect /ipfs/$ipfsnodeid
done
# REMOVE ipv6 address for in LAN node