I have $friend_of_mine_count friends amoung $liking_me_count liking me people
This commit is contained in:
parent
cc45584292
commit
26f658b4fb
|
@ -30,7 +30,7 @@ diskperf=$(dd if=/dev/zero of=~/.ipfs/test.disk bs=10M count=1 oflag=dsync 2>&1
|
||||||
mkdir -p ~/.zen/ipfs/.$IPFSNODEID/G1SSB
|
mkdir -p ~/.zen/ipfs/.$IPFSNODEID/G1SSB
|
||||||
|
|
||||||
# find IPFSTRYME public address
|
# find IPFSTRYME public address
|
||||||
echo "ipfstryme" > ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
echo "" > ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
||||||
for tryme in $(ipfs id | jq -r .Addresses[]);
|
for tryme in $(ipfs id | jq -r .Addresses[]);
|
||||||
do
|
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 | 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])/")
|
||||||
|
@ -105,14 +105,12 @@ NODEIPNS=$(ipfs name publish --allow-offline --quieter /ipfs/$IWALLETS)
|
||||||
|
|
||||||
cd ~/.zen/astroport/zen/cesium-messaging
|
cd ~/.zen/astroport/zen/cesium-messaging
|
||||||
# GET LIST of issuer(s) who likes me
|
# GET LIST of issuer(s) who likes me
|
||||||
LIKEIN=$(./jaklis.py like | jq -r '.likes[].issuer')
|
for friend in $(./jaklis.py like | jq -r '.likes[].issuer')
|
||||||
|
|
||||||
for friend in $LIKEIN
|
|
||||||
do
|
do
|
||||||
echo "sending IPFSTRYME message to my $friend"
|
echo "Sending IPFSTRYME message to $friend"
|
||||||
./jaklis.py send -d $friend -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
./jaklis.py send -d $friend -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
||||||
done
|
done
|
||||||
|
cd -
|
||||||
|
# TODO: This message should be regularly deleted by receiver and sent again to refresh changing IP
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -36,50 +36,38 @@ IPFSNODEID=$(ipfs id -f='<id>\n')
|
||||||
[[ $IPFSNODEID == "" ]] && echo "ERROR missing IPFS Node id !! IPFS is not installed !?" && exit 1
|
[[ $IPFSNODEID == "" ]] && echo "ERROR missing IPFS Node id !! IPFS is not installed !?" && exit 1
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
#TODO:
|
# Force Strict #swarm0 !!?
|
||||||
# 1. Get gchange in-friends list
|
# ipfs bootstrap rm --all
|
||||||
# 2. Read gchange+ message from them and find their IPFS tryme address
|
|
||||||
# 3. Compare with out-friends list and add their address to bootstrap, connect swarm peers
|
|
||||||
# 4. Send message to not yet in-friends to install Astroport.
|
|
||||||
|
|
||||||
count=1
|
liking_me_count=0
|
||||||
|
friend_of_mine_count=0
|
||||||
########################################################################
|
########################################################################
|
||||||
# Let's look if our SSB Friends ARE "IPFS swarm connected"
|
# Let's look for Friends and "IPFS swarm connect" with them
|
||||||
########################################################################
|
########################################################################
|
||||||
echo "" > /tmp/This_NOTfriends_are_astroport
|
cd ~/.zen/astroport/zen/cesium-messaging
|
||||||
echo "" > /tmp/This_friends_connect_astroport
|
# 1. Get Gchange "liking_me" list
|
||||||
echo "" > /tmp/This_friends_should_install_astroport
|
for liking_me in $(./jaklis.py like | jq -r '.likes[].issuer');
|
||||||
### TODO -> send gchange message (private or zip attached?) with this reports
|
do
|
||||||
|
friend_of_mine=$(./jaklis.py like -p $liking_me | jq -r '.yours');
|
||||||
for SSBFRIEND in $(uniq /tmp/ssb-friends.txt); do
|
# 2. Searching "ipfstryme" message from friend_of_mine
|
||||||
|
[[ $friend_of_mine != null ]] && echo "Try to connect to my friend $liking_me" && friend_of_mine_count=$((friend_of_mine_count+1)) && ipfsadd=0 \
|
||||||
# Force Strict #swarm0 !!
|
&& for adresse in $(./jaklis.py read -n50 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.content');
|
||||||
[[ $count == 1 ]] && ipfs bootstrap rm --all
|
do
|
||||||
|
# 3. liking_me friend_of_mine can join my swarm & bootstrap
|
||||||
### sbotc $SSBFRIEND name
|
ipfs swarm connect $adresse;
|
||||||
MYFRIEND=$(sbotc query.read '{"query":[{"$filter":{"value":{"author": "'"$SSBFRIEND"'", "content":{"type":"about", "about": "'"$SSBFRIEND"'"}}}}]}' | jq -r .value?.content?.name | grep -v null | tail -n 1)
|
ipfs bootstrap add $adresse;
|
||||||
### GET SSB "ipfstryme" message type !!! Astroport Node should have publish it during "ssb_INIT.sh"
|
ipfsadd=$((ipfsadd+1))
|
||||||
TRYME=$(sbotc query.read '{"query":[{"$filter":{"value":{"author": "'"$SSBFRIEND"'", "content":{"type":"ipfstryme"}}}}]}' | jq -r .value?.content?.text | tail -n 1)
|
done;
|
||||||
|
[[ $ipfsadd == 0 ]] && echo "My friend did not sent ipfstryme message..." # && ./jaklis.py send -d $liking_me -t "Gchange IPFS" -m "Rejoins moi sur https://qo-op.com"
|
||||||
## !! REMOVE NOTfriends from IPFS swarm
|
# 4. liking_me IS NOT a friend_of_mine!!
|
||||||
[[ $TRYME ]] && [[ $(grep -Rwl "$SSBFRIEND" /tmp/ssb-NOTfriends.txt) ]] && MES="($count) HUMMMM $MYFRIEND ($SSBFRIEND) IS NOT my friend disconnecting" && ipfs swarm disconnect $TRYME && ipfs bootstrap rm $TRYME && echo $MES >> /tmp/This_NOTfriends_are_astroport && continue
|
[[ $friend_of_mine == null ]] && echo "I am NOT LIKING $liking_me";
|
||||||
## Ici, on peut décider de demander à faire supprimer la couche astroport à son PAS AMI
|
liking_me_count=$((liking_me_count+1))
|
||||||
|
|
||||||
## ADD Friend to our IPFS swarm
|
|
||||||
[[ $TRYME ]] && MES="($count) $MYFRIEND ($SSBFRIEND) connect OK $TRYME" && ipfs swarm connect $TRYME && ipfs bootstrap add $TRYME && echo $MES >> /tmp/This_friends_connect_astroport
|
|
||||||
## Ce pote est connecté IPFS avec moi
|
|
||||||
|
|
||||||
## This_friends_should_install_astroport
|
|
||||||
[[ ! $TRYME ]] && MES="($count) $MYFRIEND ($SSBFRIEND) is NOT running ASTROPORT !!!" && echo $MES >> /tmp/This_friends_should_install_astroport
|
|
||||||
|
|
||||||
### WHAT HAPPENED this loop on my ssb friends
|
|
||||||
echo $MES
|
|
||||||
echo "_________________________________________________"
|
|
||||||
count=$((count+1))
|
|
||||||
|
|
||||||
done
|
done
|
||||||
|
cd -
|
||||||
|
|
||||||
|
echo "I have $friend_of_mine_count friends amoung $liking_me_count liking me people
|
||||||
echo "__________________________________________
|
__________________________________________
|
||||||
$WHOAMI ipfs peers are:"
|
HERE IS MY #SWARM0"
|
||||||
ipfs swarm peers
|
ipfs swarm peers
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue