better quality ipfstryme

This commit is contained in:
qo-op 2021-06-04 02:02:04 +02:00
parent fba22ba2e3
commit cc766b6ca8
1 changed files with 16 additions and 19 deletions

View File

@ -33,28 +33,25 @@ touch ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
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])/")
[[ ! $isLAN ]] && echo "$tryme" >> ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr && echo "$tryme"
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"
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/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 ]] && [[ $isMySWARM ]] && echo "$tryme" >> ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr && echo "$tryme" || ipfs swarm disconnect /ipfs/$ipfsnodeid
done
# REMOVE ipv6 address for in LAN node
if [[ $IamInLAN ]]; then
cat ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr | grep -Ev "ip6" > /tmp/tryme.addr
cp -f /tmp/tryme.addr ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
## Add "liking me" in "swarm peers" station
if [[ -f /tmp/liking_me ]]; then
for liking_me in $(cat /tmp/liking_me);
do
ipfsnodeid=$(~/.zen/astrXbian/zen/tools/g1_to_ipfs.py $liking_me)
[[ -f /tmp/ipfs_swarm_peers ]] && ipfsaddress=$(cat /tmp/ipfs_swarm_peers | grep $ipfsnodeid | tail -n 1)
if [[ $ipfsaddress ]]; then
nodeip=$(echo $ipfsaddress | cut -d '/' -f 3)
IsLAN=$(echo $nodeip | grep -E "(^127\.)|(^192\.168\.)|(^fd42\:)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/" )
[[ ! $IsLAN ]] && echo "$ipfsaddress" >> ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
fi
done
fi
# UNIQ TOUT CA
cat ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr | sort | uniq > /tmp/tryme.addr
cp -f /tmp/tryme.addr ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
rm -f /tmp/tryme.addr
# REFRESH ~/.zen/A_my_swarm.txt
cp -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr ~/.zen/A_my_swarm.txt
exit 0