#!/bin/bash ######################################################################## # Author: Fred (support@qo-op.com) # Version: 2020.12.03 # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) ######################################################################## MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized ME="${0##*/}" # Connect to IPFS peers with bidirectionnal "like" (gchange friends) # ######################################################################## # \\/// # qo-op ############# '$MY_PATH/$ME' ######################################################################## # ex: ./'$ME' # GET GCHANGE FRIENDS AND FIND THEIR IPFS ID TO "ipfs swarm connect" THEM ########################################################################' ## TODO : Beware of liking_me FLOOD & Invite $liking_me people to my #Swarm0 ######################################################################## ## CONNECT GLOBAL "ipfs.io" ## DANGEROUS DATA LEAK only for short time... ######################################################################## # ADD ipfs.io public bootstrap into your swarm peers # RUN: cat ~/.zen/astroport/ipfs.swarm.ipfs.io | ipfs swarm connect # SOON ipfs swarm peers will GROW!!! YOU ARE VSIBLE !!! # RUN: sudo systemctl restart ipfs # GOES BACK TO SWARM0 ######################################################################## ######################################################################## # ENVIRONEMENT DETECTION + IPFS ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_info ######################################################################## IPFSNODEID=$(ipfs id -f='\n') [[ $IPFSNODEID == "" ]] && echo "ERROR missing IPFS Node id !! IPFS is not installed !?" && exit 1 ######################################################################## # Force Strict #swarm0 !!? # ipfs bootstrap rm --all echo "" > ~/.zen/A_allow_ip.txt echo "" > ~/.zen/A_liking_me_NO_ipfstryme.txt # contains "friends" with no "ipfstryme" incoming message liking_me_count=0 friend_of_mine_count=0 ######################################################################## # Let's look for Friends and "IPFS swarm connect" with them ######################################################################## cd ~/.zen/astroport/zen/jaklis # 1. Get Gchange "liking_me" people 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 "Connect to my friend $liking_me" && friend_of_mine_count=$((friend_of_mine_count+1)) && ipfsadd=0 \ && for peer in $(./jaklis.py read -n50 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.content'); # ipfstryme message contains peer ipfs adresses do ip=$(echo "$peer" | awk -F '/' '{print $3}') echo $ip >> ~/.zen/A_allow_ip.txt ipfsnodeid=$(echo "$peer" | awk -F '/' '{print $7}') # 3. liking_me friend_of_mine can join my swarm & bootstrap ipfs swarm connect $peer; ipfs bootstrap add $peer; ipfsadd=$((ipfsadd+1)) done; # Friend of mine with no ipfstryme message [[ $friend_of_mine != null && $ipfsadd == 0 ]] && echo "No ipfstryme message..." && echo "$liking_me" >> ~/.zen/A_liking_me_NO_ipfstryme.txt # 4. liking_me IS NOT a friend_of_mine!! if [[ $friend_of_mine == null ]]; then echo "I am NOT LIKING $liking_me"; # GET its ~/.zen/ipfs IPNS sharing ipfs get --output=/tmp/ipfs_swarm/ /ipns/$ipfsnodeid g1pub=$(cat /tmp/ipfs_swarm/.$ipfsnodeid/G1SSB/_g1.pubkey) ### NO G1SSB node => BAN IP (must be sudo with no password !!) [[ $g1pub == "" && ( $USER == "pi" || $USER == "xbian") ]] && "SHOULD BAN $liking_me" \ && sudo fail2ban-client add recidive && sudo fail2ban-client set recidive banip $ip # Automatic level_1 like from oasis.astroport.com (add other default bootstrap) [[ $G1PUB == "2jQUH4HfHxdTesjCjvMCx1VJgA5AnpuvrWRq1swfRdsS" ]] && ./jaklis.py like -p $g1pub -s 1 fi liking_me_count=$((liking_me_count+1)) done echo "#################################################### I have $friend_of_mine_count friends amoung $liking_me_count liking me people __________________________________________ My actual #SWARM0" ipfs swarm peers echo "__________________________________________" echo ## Send message to for line in $(cat ~/.zen/A_liking_me_NO_ipfstryme.txt | uniq); do echo "Liking ME, but no ipfstryme received..." echo "cd ~/.zen/astroport/zen/jaklis" echo "./jaklis.py send -d $liking_me -t 'Astroport' -m 'Rejoins mon #Swarm0 sur https://qo-op.com'" done cd -