swarm control code upgrade
This commit is contained in:
parent
19b747ae7f
commit
46ecb32eca
10
ISOconfig.sh
10
ISOconfig.sh
|
@ -47,6 +47,8 @@ jq -r --arg PeerID "$PeerID" '.Identity.PeerID=$PeerID' ~/.ipfs/config > /tmp/co
|
||||||
jq -r --arg PrivKEY "$PrivKEY" '.Identity.PrivKey=$PrivKEY' /tmp/config.tmp > /tmp/config.ipfs
|
jq -r --arg PrivKEY "$PrivKEY" '.Identity.PrivKey=$PrivKEY' /tmp/config.tmp > /tmp/config.ipfs
|
||||||
rm /tmp/config.tmp
|
rm /tmp/config.tmp
|
||||||
|
|
||||||
|
IPFSNODEID=$PeerID
|
||||||
|
|
||||||
## Directory transfered to IPFS
|
## Directory transfered to IPFS
|
||||||
IPFS_sync_directory="$HOME/.zen/miam"
|
IPFS_sync_directory="$HOME/.zen/miam"
|
||||||
|
|
||||||
|
@ -80,16 +82,16 @@ sleep 10
|
||||||
echo 'EXTEND ~/.bashrc'
|
echo 'EXTEND ~/.bashrc'
|
||||||
~/.zen/astroport/.install/update_bashrc.sh
|
~/.zen/astroport/.install/update_bashrc.sh
|
||||||
|
|
||||||
mkdir -p ~/.zen/ipfs/.${PeerID}/G1SSB
|
mkdir -p ~/.zen/ipfs/.${IPFSNODEID}/G1SSB
|
||||||
echo "" > ~/.zen/ipfs/.${PeerID}/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])/")
|
||||||
[[ ! $isLAN ]] && echo "$tryme" >> ~/.zen/ipfs/.${PeerID}/tryme.addr && echo "$tryme"
|
[[ ! $isLAN ]] && echo "$tryme" >> ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr && echo "$tryme"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo 'SEND ipfstryme to oasis'
|
echo 'SEND ipfstryme to oasis'
|
||||||
./jaklis.py send -d 2jQUH4HfHxdTesjCjvMCx1VJgA5AnpuvrWRq1swfRdsS -t "ipfstryme" -f ~/.zen/ipfs/.${PeerID}/tryme.addr
|
./jaklis.py send -d 2jQUH4HfHxdTesjCjvMCx1VJgA5AnpuvrWRq1swfRdsS -t "ipfstryme" -f ~/.zen/ipfs/.${IPFSNODEID}/tryme.addr
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,9 @@ MY_PATH="`dirname \"$0\"`" # relative
|
||||||
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
ME="${0##*/}"
|
ME="${0##*/}"
|
||||||
|
|
||||||
|
# Connect to IPFS peers with bidirectionnal "like" (gchange friends)
|
||||||
|
#
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# \\///
|
# \\///
|
||||||
# qo-op
|
# qo-op
|
||||||
|
@ -37,7 +40,8 @@ IPFSNODEID=$(ipfs id -f='<id>\n')
|
||||||
|
|
||||||
# Force Strict #swarm0 !!?
|
# Force Strict #swarm0 !!?
|
||||||
# ipfs bootstrap rm --all
|
# ipfs bootstrap rm --all
|
||||||
echo "" > /tmp/A_liking_me_NO_ipfstryme.txt
|
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
|
liking_me_count=0
|
||||||
friend_of_mine_count=0
|
friend_of_mine_count=0
|
||||||
########################################################################
|
########################################################################
|
||||||
|
@ -51,15 +55,34 @@ do
|
||||||
# 2. Searching "ipfstryme" message from friend_of_mine
|
# 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 \
|
[[ $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');
|
&& 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
|
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
|
# 3. liking_me friend_of_mine can join my swarm & bootstrap
|
||||||
ipfs swarm connect $peer;
|
ipfs swarm connect $peer;
|
||||||
ipfs bootstrap add $peer;
|
ipfs bootstrap add $peer;
|
||||||
ipfsadd=$((ipfsadd+1))
|
ipfsadd=$((ipfsadd+1))
|
||||||
done;
|
done;
|
||||||
[[ $friend_of_mine != null && $ipfsadd == 0 ]] && echo "No ipfstryme message..." && echo "$liking_me" >> /tmp/A_liking_me_NO_ipfstryme.txt
|
|
||||||
|
# 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!!
|
# 4. liking_me IS NOT a friend_of_mine!!
|
||||||
[[ $friend_of_mine == null ]] && echo "I am NOT LIKING $liking_me";
|
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))
|
liking_me_count=$((liking_me_count+1))
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -71,7 +94,10 @@ My actual #SWARM0"
|
||||||
ipfs swarm peers
|
ipfs swarm peers
|
||||||
echo "__________________________________________"
|
echo "__________________________________________"
|
||||||
echo
|
echo
|
||||||
for line in $(cat /tmp/A_liking_me_NO_ipfstryme.txt | uniq); do
|
## 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'"
|
echo "./jaklis.py send -d $liking_me -t 'Astroport' -m 'Rejoins mon #Swarm0 sur https://qo-op.com'"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,17 @@
|
||||||
MY_PATH="`dirname \"$0\"`" # relative
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
ME="${0##*/}"
|
ME="${0##*/}"
|
||||||
|
########################################################################
|
||||||
|
# This script is controling IPFS swarm
|
||||||
|
|
||||||
## NOT WORKING !!!
|
# Removes from peers not friends on gchange+
|
||||||
|
# remember Nodes ID and IPs
|
||||||
|
# add IPs to fail2ban
|
||||||
|
|
||||||
|
# Sync friends peers ~/.zen/ipfs/ into ~/.zen/ipfs_swarm/.IPFSNODEID's/ directories
|
||||||
|
#
|
||||||
|
|
||||||
|
## NOT WORKING !!! YET
|
||||||
exit 1
|
exit 1
|
||||||
########################################################################
|
########################################################################
|
||||||
# \\///
|
# \\///
|
||||||
|
@ -16,8 +25,8 @@ exit 1
|
||||||
############# '$MY_PATH/$ME'
|
############# '$MY_PATH/$ME'
|
||||||
########################################################################
|
########################################################################
|
||||||
# ex: ./'$ME'
|
# ex: ./'$ME'
|
||||||
# SYNC IPFS SWARM PEERS SHARED DATA .12D3KooW****
|
########################################################################
|
||||||
########################################################################'
|
# TODO remove because it is in~/.bashrc
|
||||||
export YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1)
|
export YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1)
|
||||||
export IPFSNODEID=$(ipfs id -f='<id>\n')
|
export IPFSNODEID=$(ipfs id -f='<id>\n')
|
||||||
########################################################################
|
########################################################################
|
||||||
|
@ -31,13 +40,30 @@ _|_| | __) __)\/\//--\| \| | | \|_| | \|___)| |
|
||||||
'
|
'
|
||||||
echo "I am $IPFSNODEID"
|
echo "I am $IPFSNODEID"
|
||||||
|
|
||||||
## TODO CHANNELS SWARM INDEX COPY PROCEDURE
|
for peer in $(ipfs swarm peers);
|
||||||
## SIGNAL ~/.zen/g1sms/ TODO
|
do
|
||||||
|
id=$(echo "$peer" | awk -F '/' '{print $7}')
|
||||||
|
ip=$(echo "$peer" | awk -F '/' '{print $3}')
|
||||||
|
nowdate=$(date)
|
||||||
|
timestamp=$(date -u +%s%N | cut -b1-13)
|
||||||
|
|
||||||
|
echo "$nowdate - $id - $ip"
|
||||||
|
foundIp=$(cat ~/.zen/allow_ip.txt | grep "$ip" | wc -l)
|
||||||
|
if [ "$foundIp" -eq 0 ] ; then
|
||||||
|
echo "${ip} of peer ${id} is not in the authorized ip list. ${peer} will be removed from the swarm"
|
||||||
|
ipfs swarm disconnect $peer
|
||||||
|
ipfs bootstrap rm $peer
|
||||||
|
else
|
||||||
|
${path_script}/timeout.sh -t 30 ipfs get --output ${path_shared_files}/ /ipns/$id
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
echo "PUBLISHING MY OWN /home/$YOU/.zen/ipfs/ to SWARM"
|
echo "PUBLISHING MY OWN /home/$YOU/.zen/ipfs/ to SWARM"
|
||||||
[[ ! -d /home/$YOU/.zen/ipfs ]] && echo "ERROR : /home/$YOU/.zen/ipfs/ NOT FOUND" && exit 1
|
[[ ! -d /home/$YOU/.zen/ipfs ]] && echo "ERROR : /home/$YOU/.zen/ipfs/ NOT FOUND" && exit 1
|
||||||
IWALLETS=$(ipfs add -rHq /home/$YOU/.zen/ipfs | tail -n 1)
|
IWALLETS=$(ipfs add -rHq /home/$YOU/.zen/ipfs | tail -n 1)
|
||||||
NODEIPNS=$(ipfs name publish --quieter /ipfs/$IWALLETS)
|
NODEIPNS=$(ipfs name publish --quieter /ipfs/$IWALLETS)
|
||||||
|
|
||||||
|
# Put my own data in /home/$YOU/.zen/ipfs_swarm/
|
||||||
ipfs get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$IPFSNODEID
|
ipfs get --output=/home/$YOU/.zen/ipfs_swarm/ /ipns/$IPFSNODEID
|
||||||
|
|
||||||
echo "REFRESHING /home/$YOU/.zen/ipfs_swarm/ from my SWARM peers"
|
echo "REFRESHING /home/$YOU/.zen/ipfs_swarm/ from my SWARM peers"
|
||||||
|
|
Loading…
Reference in New Issue