From 26f658b4fba17fa0e2bd03a809f848f024423735 Mon Sep 17 00:00:00 2001 From: qo-op Date: Thu, 3 Dec 2020 13:37:24 +0100 Subject: [PATCH] I have $friend_of_mine_count friends amoung $liking_me_count liking me people --- zen/gchange_INIT.sh | 14 ++++---- zen/gchange_IPFS_swarm.sh | 70 ++++++++++++++++----------------------- 2 files changed, 35 insertions(+), 49 deletions(-) diff --git a/zen/gchange_INIT.sh b/zen/gchange_INIT.sh index 29186fc..3bbe69d 100644 --- a/zen/gchange_INIT.sh +++ b/zen/gchange_INIT.sh @@ -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 # 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[]); 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])/") @@ -105,14 +105,12 @@ NODEIPNS=$(ipfs name publish --allow-offline --quieter /ipfs/$IWALLETS) cd ~/.zen/astroport/zen/cesium-messaging # GET LIST of issuer(s) who likes me -LIKEIN=$(./jaklis.py like | jq -r '.likes[].issuer') - -for friend in $LIKEIN +for friend in $(./jaklis.py like | jq -r '.likes[].issuer') do - echo "sending IPFSTRYME message to my $friend" - ./jaklis.py send -d $friend -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr + echo "Sending IPFSTRYME message to $friend" + ./jaklis.py send -d $friend -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr done - - +cd - +# TODO: This message should be regularly deleted by receiver and sent again to refresh changing IP exit 0 diff --git a/zen/gchange_IPFS_swarm.sh b/zen/gchange_IPFS_swarm.sh index 10892f7..bab230f 100644 --- a/zen/gchange_IPFS_swarm.sh +++ b/zen/gchange_IPFS_swarm.sh @@ -36,50 +36,38 @@ IPFSNODEID=$(ipfs id -f='\n') [[ $IPFSNODEID == "" ]] && echo "ERROR missing IPFS Node id !! IPFS is not installed !?" && exit 1 ######################################################################## -#TODO: -# 1. Get gchange in-friends list -# 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. +# Force Strict #swarm0 !!? +# ipfs bootstrap rm --all -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 -echo "" > /tmp/This_friends_connect_astroport -echo "" > /tmp/This_friends_should_install_astroport -### TODO -> send gchange message (private or zip attached?) with this reports - -for SSBFRIEND in $(uniq /tmp/ssb-friends.txt); do - - # Force Strict #swarm0 !! - [[ $count == 1 ]] && ipfs bootstrap rm --all - - ### sbotc $SSBFRIEND name - 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) - ### GET SSB "ipfstryme" message type !!! Astroport Node should have publish it during "ssb_INIT.sh" - TRYME=$(sbotc query.read '{"query":[{"$filter":{"value":{"author": "'"$SSBFRIEND"'", "content":{"type":"ipfstryme"}}}}]}' | jq -r .value?.content?.text | tail -n 1) - - ## !! REMOVE NOTfriends from IPFS swarm - [[ $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 - ## Ici, on peut décider de demander à faire supprimer la couche astroport à son PAS AMI - - ## 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)) - +cd ~/.zen/astroport/zen/cesium-messaging +# 1. Get Gchange "liking_me" list +for liking_me in $(./jaklis.py like | jq -r '.likes[].issuer'); +do + friend_of_mine=$(./jaklis.py like -p $liking_me | jq -r '.yours'); + # 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 \ + && for adresse in $(./jaklis.py read -n50 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.content'); + do + # 3. liking_me friend_of_mine can join my swarm & bootstrap + ipfs swarm connect $adresse; + ipfs bootstrap add $adresse; + ipfsadd=$((ipfsadd+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" + # 4. liking_me IS NOT a friend_of_mine!! + [[ $friend_of_mine == null ]] && echo "I am NOT LIKING $liking_me"; + liking_me_count=$((liking_me_count+1)) done +cd - - -echo "__________________________________________ -$WHOAMI ipfs peers are:" +echo "I have $friend_of_mine_count friends amoung $liking_me_count liking me people +__________________________________________ +HERE IS MY #SWARM0" ipfs swarm peers + +