cesium like control swarm

master
qo-op 2 years ago
parent 69fc6bd07c
commit f91e993fe5
  1. 46
      www/jukebox.conf
  2. 112
      zen/cesium_IPFS_swarm.sh

@ -0,0 +1,46 @@
server {
listen _PORT_;
listen [::]:_PORT_;
root /var/www/loveland/_APPLI_;
server_name _MY_NODE_NAME_ localhost 127.0.0.1;
error_log /var/log/nginx/_APPLI_.error.log;
access_log /var/log/nginx/_APPLI_.access.log;
# This section can be copied into an existing default setup
location / {
allow all;
index index.php index.html index.htm;
location ~ \.php {
try_files $uri index.php =404;
fastcgi_pass unix:/var/run/php/php_PHPVERSION_-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include /etc/nginx/fastcgi_params;
fastcgi_read_timeout 1800;
}
error_page 404 = /error/404.html;
try_files $uri $uri/ =404;
location ~ /albumart/* {
expires -1s;
}
}
# IPFS GATEWAY PROXY
location /ipfs {
proxy_pass http://127.0.0.1:8181;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
location /ipns {
proxy_pass http://127.0.0.1:8181;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}

@ -0,0 +1,112 @@
#!/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" (Cesium+ 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
########################################################################
# ENVIRONEMENT DETECTION + IPFS ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_info
########################################################################
IPFSNODEID=$(ipfs id -f='<id>\n')
[[ $IPFSNODEID == "" ]] && echo "ERROR missing IPFS Node id !! IPFS is not installed !?" && exit 1
isIPFSRunning=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1)
[[ ! $isIPFSRunning ]] && echo "ERROR! ipfs daemon is not running. EXIT" && 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/astrXbian/zen/jaklis
# 1. Get C+ "liking_me" people list
for liking_me in $(./jaklis.py like | jq -r '.likes[].issuer');
do
# Check if my like is reverse
friend_of_mine=$(./jaklis.py like -p $liking_me | jq -r '.yours');
[[ $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');
# 2. Searching "ipfstryme" message from friend_of_mine
do
ip=$(echo "$peer" | awk -F '/' '{print $3}') && [[ $ip == "" ]] && continue || echo "Adding $ip to ~/.zen/A_allow_ip.txt"
# Fill a file with friend of mine ip
echo $ip >> ~/.zen/A_allow_ip.txt
# Get its ipfsnodeid
ipfsnodeid=$(echo "$peer" | awk -F '/' '{print $7}')
# 3. ADD liking_me friend_of_mine to my swarm & bootstrap
ipfs swarm connect $peer;
ipfs bootstrap add $peer;
ipfsadd=$((ipfsadd+1))
done;
#g1id=$(~/.zen/astrXbian/zen/tools/ipfs_to_g1.py "$ipfsnodeid")
#echo "G1 ID : $g1id"
if [[ $friend_of_mine != null ]]; then
if [[ $ipfsadd == 0 ]]; then
# Friend of mine with no ipfstryme message (did not install astroport)
echo "No 'ipfstryme' message... from $liking_me"
echo "$liking_me" >> ~/.zen/A_liking_me_NO_ipfstryme.txt
else
# REMOVING DUPLICATES OLD ipfstryme MESSAGES
nbmessage=0
for messageid in $(./jaklis.py read -n50 -j | jq -r --arg friendKEY "$liking_me" '.[] | select(.pubkey == $friendKEY)' | jq 'select(.title == "ipfstryme")' | jq -r '.id')
do
nbmessage=$((nbmessage+1))
[ $nbmessage -gt 1 ] && echo "Delete OLD 'ipfstryme' messages from $liking_me" && ./jaklis.py delete -i $messageid
done
fi
fi
# Automatic level_1 like from oasis.astroport.com (TODO add other default bootstrap)
# TODO get $g1pub from ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.pubkey ??
# [[ $friend_of_mine == null && $G1PUB == "2jQUH4HfHxdTesjCjvMCx1VJgA5AnpuvrWRq1swfRdsS" ]] && ./jaklis.py like -p $g1pub -s 1
echo "__________________________________________"
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
## Could send message to friends with 'ipfstryme' message
for line in $(cat ~/.zen/A_liking_me_NO_ipfstryme.txt | uniq); do
echo "Liking each other, but no ipfstryme received..."
echo "cd ~/.zen/astrXbian/zen/jaklis"
echo "./jaklis.py send -d $line -t 'Astroport' -m 'Rejoins mon #Swarm0 https://copylaradio.com'"
done
cd -
Loading…
Cancel
Save