ipfs p2p stuff

This commit is contained in:
qo-op 2021-06-03 02:53:56 +02:00
parent fcc0cb7e75
commit 6d5722fa94
6 changed files with 101 additions and 60 deletions

1
A_swarm_admin.txt Normal file
View File

@ -0,0 +1 @@
Ee1n3hDv9vunfd6m3LW6XeYg7bnt5aaRn9EjqnBe8GNS

View File

@ -1,27 +0,0 @@
#!/bin/bash
################################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
################################################################################
# Activate SUPPORT MODE: open ssh over IPFS
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
########################################################################
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) || er+=" ipfs daemon not running"
IPFSNODEID=$(ipfs id -f='<id>\n') || er+=" ipfs id problem"
WHOAMI=$(sbotc whoami | jq -r .id) || er+=" sbotc whoami problem"
[[ "$YOU" == "" || "$IPFSNODEID" == "" || "$WHOAMI" == "" ]] && echo "ERROR : $er " && exit 1
########################################################################
# TODO ESTABLISH A PORT FORWARD STRATEGY (depending on Node Flavour)
# Arrange local port forwarded to swarm
# GET _uidna (means g1sms/init.sh been run)
[[ -f /home/$YOU/.zen/ipfs/.${IPFSNODEID}/_xbian.zuid ]] && UIDNA=$(cat /home/$YOU/.zen/ipfs/.${IPFSNODEID}/_xbian.zuid)
ipfs p2p close --all
ipfs p2p listen /x/ssh-$UIDNA /ip4/127.0.0.1/tcp/22
# ipfs p2p listen /x/http-$UIDNA /ip4/127.0.0.1/tcp/80
# ipfs p2p listen /x/https-$UIDNA /ip4/127.0.0.1/tcp/443
ipfs p2p ls

41
zen/ipfs_P2P_forward.sh Executable file
View File

@ -0,0 +1,41 @@
#!/bin/bash
################################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.1
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
################################################################################
# Activate SUPPORT MODE: open ssh over IPFS
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
########################################################################
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) || er+=" ipfs daemon not running"
IPFSNODEID=$(ipfs --timeout=5s id -f='<id>\n') || er+=" ipfs id problem"
[[ "$YOU" == "" || "$IPFSNODEID" == "" ]] && echo "ERROR : $er " && exit 1
########################################################################
# TODO ESTABLISH A PORT FORWARD STRATEGY (depending on Node Flavour)
IPFSADMINID=$(cat ~/.zen/astrXbian/A_swarm_admin.txt)
## OASIS acts as nginx proxy WITH localhost:2443 => taurus:443 (NextCloud)
# OASIS : /etc/nginx/sites-available/taurus.copylaradio.com.conf
# server {
# server_name taurus.copylaradio.com;
#
# access_log /var/log/nginx/taurus-access.log;
# error_log /var/log/nginx/taurus-error.log;
#
# location / {
# proxy_pass https://127.0.0.1:2443;
# }
# }
# + sudo certbot !!
if [[ "$IPFSNODEID" == "12D3KooWRstYPJSakosgnvvGpxDdUJd2xAncJB7fbBwLBaTAEJxp" ]]; then
ipfs p2p listen /x/https-taurus /ip4/127.0.0.1/tcp/443
fi
# OASIS /etc/nginx/sites-available/taurus.copylaradio.com.conf
if [[ "$IPFSNODEID" == "12D3KooWBYme2BsNUrtx4mEdNX6Yioa9AV7opWzQp6nrPs6ZKabN" ]]; then
ipfs p2p close -p /x/https-taurus
ipfs p2p forward /x/https-taurus /ip4/127.0.0.1/tcp/2443 /p2p/12D3KooWRstYPJSakosgnvvGpxDdUJd2xAncJB7fbBwLBaTAEJxp
fi
ipfs p2p ls

View File

@ -20,7 +20,7 @@ ME="${0##*/}"
########################################################################
# ENVIRONEMENT DETECTION + IPFS ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_info
########################################################################
IPFSNODEID=$(ipfs id -f='<id>\n')
IPFSNODEID=$(ipfs --timeout=5s id -f='<id>\n')
[[ $IPFSNODEID == "" ]] && echo "ERROR missing IPFS Node id !! IPFS is not installed !?" && exit 1
########################################################################
[[ ! -f ~/.zen/secret.dunikey ]] && exit 1

View File

@ -23,8 +23,9 @@ then
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFLHW8P88C/B7622yXzdAn1ZcTBfE1A4wMqajBwAoHwUVTOUaYfvkiSxbzb5H9dPTAXhQU6ZfuLa70kTo1m2b9TKH0tD6hR3RiKJ0NIjCHYEypcPGpLmHaZWnBKPq3IUU24qFVdUJxnTkDdFUszYMNoV4nqlXY/ZYdNpic8L1jPPyfOLLfPFkuSxagyQj4FGJq77UQE5j+skMJS3ISkazNTLqOCGLFJ5qtBC11BvQaCJ4cQ2Ss7ejPYhpx16NLJfg9VtG4dv9ZebEIl2pf7niiQGSPrDMFWHuQcGAuHt/patr0BcvfvD3Gv+qNsVfAJCNZ2U5NHEMKIhgj1ilNPEw7 fred@ONELOVE" >> ~/.ssh/authorized_keys
fi
IPFSADMINID=$(cat ~/.zen/astrXbian/A_swarm_admin.txt)
## NOT forwarding for myself
if [[ "$G1PUB" != "Ee1n3hDv9vunfd6m3LW6XeYg7bnt5aaRn9EjqnBe8GNS" ]]
if [[ "$G1PUB" != "$IPFSADMINID" ]]
then
if [[ "$ARG" == "close" ]]
then
@ -32,7 +33,7 @@ then
## SEND MESSAGE
echo "ipfs p2p close -p /x/$G1PUB-ssh" > /tmp/ssh.forward
~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d Ee1n3hDv9vunfd6m3LW6XeYg7bnt5aaRn9EjqnBe8GNS -t "SSH-STOP" -f /tmp/ssh.forward
~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $IPFSADMINID -t "SSH-STOP" -f /tmp/ssh.forward
echo "STOP"
fi
if [[ "$ARG" == "" || "$ARG" == "open" ]]; then
@ -44,7 +45,7 @@ then
PORT=$(cat /tmp/ssh.forward.port)
echo "ipfs p2p forward /x/$G1PUB-ssh /ip4/127.0.0.1/tcp/$PORT /p2p/$IPFSNODEID
ssh $USER@localhost -p $PORT" > /tmp/ssh.forward
~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d Ee1n3hDv9vunfd6m3LW6XeYg7bnt5aaRn9EjqnBe8GNS -t "SSH-OPEN" -f /tmp/ssh.forward
echo "Demande de dépannage envoyé à fred@ONELOVE (Ee1n3hDv9vunfd6m3LW6XeYg7bnt5aaRn9EjqnBe8GNS)"
~/.zen/astrXbian/zen/jaklis/jaklis.py -k ~/.zen/secret.dunikey -n "https://data.gchange.fr" send -d $IPFSADMINID -t "SSH-OPEN" -f /tmp/ssh.forward
echo "Demande de dépannage envoyé à $IPFSADMINID (~/.zen/astrXbian/A_swarm_admin.txt)"
fi
fi

View File

@ -11,8 +11,10 @@ MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
########################################################################
LON=$1
LAT=$2
LAT="$1"
LON="$2"
RAD="$3"
[[ ! $RAD ]] && RAD="25km"
[[ ! ( $LAT && $LON ) ]] && echo "Indiquez les coordonnées GPS et le rayon de votre recherche! ex: $ME 43.614208 1.4155776 50km" && exit 1
@ -21,6 +23,8 @@ CESIUM="https://g1.data.le-sou.org"
GCHANGE="https://data.gchange.fr" # /user/profile/2L8vaYixCf97DMT8SistvQFeBj7vb6RQL7tvwyiv1XVH?&_source_exclude=avatar._content
[[ ! -d ~/.zen/.cache/gchange ]] && mkdir -p ~/.zen/.cache/gchange
rm ~/.zen/.cache/g1contact.txt
# curl -sk ${CESIUM}/user/profile/${g1pub} -o ~/.zen/.cache/cesium_profile.json
# LON=$(cat ~/.zen/.cache/cesium_profile.json | jq '._source.geoPoint.lon')
# LAT=$(cat ~/.zen/.cache/cesium_profile.json | jq '._source.geoPoint.lat')
@ -28,9 +32,6 @@ GCHANGE="https://data.gchange.fr" # /user/profile/2L8vaYixCf97DMT8SistvQFeBj7vb6
# LON=$(cat ~/.zen/.cache/GCHANGE_profile.json | jq '._source.geoPoint.lon')
# LAT=$(cat ~/.zen/.cache/GCHANGE_profile.json | jq '._source.geoPoint.lat')
RAD="$1"
[[ ! $RAD ]] && RAD="25km"
curl -sk -XPOST 'https://data.gchange.fr/market/record/_search?pretty&_source=title' -d '
{
"size": 200,
@ -51,42 +52,66 @@ curl -sk -XPOST 'https://data.gchange.fr/market/record/_search?pretty&_source=ti
TIMESTAMP=$(date -u +"%s")
TOTAL=$(cat /tmp/gchange.json | jq .hits.total)
echo "##################################################################"
echo "$TOTAL ANNONCES A $RAD de $LAT $LON"
echo "##################################################################"
chunk=0
fullcount=0
for gID in $(cat /tmp/gchange.json | jq -r .hits.hits[]._id); do
NEW=""
echo "##################################################################"
if [[ ! -f ~/.zen/.cache/gchange/$gID.json ]]; then
NEW="true"
# curl -s --create-dirs -o ~/.zen/.cache/gchange/$gID.json -s https://data.gchange.fr/market/record/$gID?_source=category,title,description,issuer,time,creationTime,location,address,city,price,unit,currency,thumbnail._content_type,thumbnail._content,picturesCount,type,stock,fees,feesCurrency,geoPoint
## ISSUER DE L'AUTEUR DE L'ANNONCE
curl -s --create-dirs -o ~/.zen/.cache/gchange/$gID.json -s https://data.gchange.fr/market/record/$gID?_source=category,title,description,issuer,time,creationTime,location,address,city,price,unit,currency,type,geoPoint
ISSUER=$(cat ~/.zen/.cache/gchange/$gID.json | jq -r ._source.issuer)
## ANNONCE
curl -S -s --create-dirs -o ~/.zen/.cache/gchange/$gID.json -s "https://data.gchange.fr/market/record/$gID?_source=category,title,description,issuer,time,creationTime,location,address,city,price,unit,currency,type,geoPoint"
sleep 1
fi
## ISSUER DE L'ANNONCE
ISSUER=$(cat ~/.zen/.cache/gchange/$gID.json | jq -r ._source.issuer)
echo "ISSUER=$ISSUER"
## SOCIAL DE L'AUTEUR DE L'ANNONCE
curl -s --create-dirs -o ~/.zen/.cache/gchange/profil.$ISSUER.json -s https://data.gchange.fr/user/profile/$ISSUER?&_source_exclude=avatar._content
SOCIAL=$(cat ~/.zen/.cache/gchange/profil.$ISSUER.json | jq -r ._source.socials)
## PROFIL CREATEUR DE L'ANNONCE
curl -S -s --create-dirs -o ~/.zen/.cache/gchange/profil.$ISSUER.json -s "https://data.gchange.fr/user/profile/$ISSUER?&_source_exclude=avatar._content"
Gtitle=$(cat ~/.zen/.cache/gchange/profil.$ISSUER.json | jq -r ._source.title)
Gaddress=$(cat ~/.zen/.cache/gchange/profil.$ISSUER.json | jq -r ._source.address)
Gcity=$(cat ~/.zen/.cache/gchange/profil.$ISSUER.json | jq -r ._source.city)
echo "GCONTACT $Gtitle - $Gaddress - $Gcity"
## G1KEY DE L'AUTEUR DE L'ANNONCE
G1KEY=$(cat ~/.zen/.cache/gchange/profil.$ISSUER.json | jq -r ._source.pubkey)
## G1KEY DE L'AUTEUR DE L'ANNONCE
G1KEY=$(cat ~/.zen/.cache/gchange/profil.$ISSUER.json | jq -r ._source.pubkey)
echo "G1KEY=$G1KEY"
## LIEN CESIUM +
if [[ $G1KEY != "" ]]; then
curl -s --create-dirs -o ~/.zen/.cache/g1profil.$G1KEY.json -s https://g1.data.le-sou.org/user/profile/$G1KEY
title=$(cat ~/.zen/.cache/g1profil.$ISSUER.json | jq -r ._source.title)
address=$(cat ~/.zen/.cache/g1profil.$ISSUER.json | jq -r ._source.address)
socials=$(cat ~/.zen/.cache/g1profil.$ISSUER.json | jq -r ._source.socials)
city=$(cat ~/.zen/.cache/g1profil.$ISSUER.json | jq -r ._source.city)
geoPoint=$(cat ~/.zen/.cache/g1profil.$ISSUER.json | jq -r ._source.geoPoint)
echo "$title - $address - $city" >> ~/.zen/.cache/gchange.txt
echo "$title - $address - $city"
echo $socials | jq -r
echo $geoPoint | jq -r
fi
## LIEN CESIUM +
if [[ $G1KEY != "null" && $G1KEY != "" ]]; then
curl -S -s --create-dirs -o ~/.zen/.cache/g1profil.$G1KEY.json -s "https://g1.data.le-sou.org/user/profile/$G1KEY?&_source_exclude=avatar._content"
[[ ! -f ~/.zen/.cache/g1profil.$G1KEY.json ]] && echo "RIEN SUR CESIUM" && continue
fi
[[ -f ~/.zen/.cache/g1contact.txt ]] && TEST=$(cat ~/.zen/.cache/g1contact.txt | grep $G1KEY)
if [[ "$TEST" == "" ]]
then
title=$(cat ~/.zen/.cache/g1profil.$G1KEY.json | jq -r ._source.title)
address=$(cat ~/.zen/.cache/g1profil.$G1KEY.json | jq -r ._source.address)
socials=$(cat ~/.zen/.cache/g1profil.$G1KEY.json | jq -r ._source.socials)
city=$(cat ~/.zen/.cache/g1profil.$G1KEY.json | jq -r ._source.city)
geoPoint=$(cat ~/.zen/.cache/g1profil.$G1KEY.json | jq -r ._source.geoPoint)
echo "##################################################################" >> ~/.zen/.cache/g1contact.txt
echo "$G1KEY" >> ~/.zen/.cache/g1contact.txt
echo "$title - $address - $city" >> ~/.zen/.cache/g1contact.txt
echo $socials >> ~/.zen/.cache/g1contact.txt
echo $geoPoint >> ~/.zen/.cache/g1contact.txt
echo "G1CONTACT $title - $address - $city"
echo $geoPoint
sleep $((1 + RANDOM % 3))
else
echo "DEJA CONNU"
fi
done
cat ~/.zen/.cache/gchange.txt
cat ~/.zen/.cache/g1contact.txt