ipfs p2p forward g1sms:10099 to all swarm node

This commit is contained in:
qo-op 2020-05-23 03:05:05 +02:00
parent 135f4647c9
commit 41693e8b00
5 changed files with 38 additions and 24 deletions

View File

@ -175,7 +175,8 @@ sudo sed -i "s/_APPLI_/jukebox/g" /tmp/jukebox.conf
sudo cp -f /tmp/jukebox.conf /etc/nginx/conf.d/jukebox.conf
### G1SMS loveland entrance localhost:10099 ("ipfs p2p" forwarded)
[[ $(which gammu) ]] && sudo sed "s/_PHPVERSION_/$PHPVERSION/g" /home/$YOU/.zen/astroport/www/g1sms.conf > /tmp/g1sms.conf && sudo cp -f /tmp/g1sms.conf /etc/nginx/conf.d/
[[ $(which gammu) ]] && sudo sed "s/_PHPVERSION_/$PHPVERSION/g" /home/$YOU/.zen/astroport/www/g1sms.conf > /tmp/g1sms.conf \
&& sudo cp -f /tmp/g1sms.conf /etc/nginx/conf.d/ # && ipfs p2p listen /x/g1sms /ip4/127.0.0.1/tcp/10099 # SEE 'zen/ipfs_OPEN_ports.sh'
sudo systemctl restart nginx || err=1

View File

@ -90,7 +90,7 @@ fi
# /_//_/ /____/|__/|__/\__,_/_/ /_/ /_/ /_/\____/
#
##################################################################
# REFRESH IPFS SWARM DATA EVERY 12 minutes
# REFRESH IPFS SWARM DATA EVERY 12 & 15 minutes
[[ $(($minute % 12)) == 0 ]] && sleep $((1 + RANDOM % 10)) && $MY_PATH/zen/ssb_IPFS_swarm.sh
[[ $(($minute % 15)) == 0 ]] && sleep $((1 + RANDOM % 10)) && $MY_PATH/zen/ipfs_SWARM_refresh.sh
##################################################################
@ -159,8 +159,19 @@ if [[ "$timebar" == "00:01" ]]; then
rm ~/.zen/zenytv.last.ts
rm ~/.zen/zenyta.last.ts
# SYNC SSB Friends with IPFS SWARM
$MY_PATH/zen/ssb_IPFS_swarm.sh
# ipfs_OPEN_ports.sh (distribute g1sms port with ipfs p2p
echo '
_________
/ ____< / _________ ___ _____
/ / __ / / / ___/ __ `__ \/ ___/
/ /_/ // / (__ ) / / / / (__ )
\____//_/ /____/_/ /_/ /_/____/
http://127.0.0.1:10099
'
ipfs p2p close --all
$MY_PATH/zen/ipfs_OPEN_ports.sh
ipfs p2p ls
fi
##################################################################

View File

@ -13,7 +13,7 @@ jQuery(document).ready(function () {
var naissance = jQuery("#naissance");
var data = '';
// ajax call to ajax.php
jQuery.getJSON("g1sms/sms_loveland.php", {
jQuery.getJSON("http://127.0.0.1:10099/sms_loveland.php", {
phone: phone.val(), parrain: parrain.val(), naissance: naissance.val()
}, function (data) {
$("#phoneresultat").html("<p>Votre inscription en prise en compte...</p>");

View File

@ -18,17 +18,8 @@ if (strlen($_REQUEST['phone']) == 10 ) {
// LOCAL
$fp = fopen('/tmp/loveland_entrance/'.$HPHONE, 'w');
fwrite($fp, $PHONE.'|'.$PARRAIN.'|'.$naissance);
// MODE SWARM : write
$YOU = exec("ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d ' ' -f 1", $output, $return);
$POINTSMS = exec("ls /home/$YOU/.zen/ipfs_swarm/.Qm*/G1SSB/_g1sms | shuf -n 1 | cut -d '/' -f 6", $output, $return);
if ($return == 0) {
// FOUND $POINTSMS ACCESS RIGHT PROBLEM !!!
$fp = fopen('/home/'.$YOU.'/.zen/ipfs/'.$POINTSMS.'/TASK/loveland_entrance/'.$HPHONE, 'w');
fwrite($fp, $PHONE);
}
return true;
} else {
return false;

View File

@ -7,20 +7,31 @@
# 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 "
########################################################################
# TODO ESTABLISH A PORT FORWARD STRATEGY (depending on Node Flavour)
exit
# Arrange local port forwarded to swarm
# GET _uidna
YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
# GET _uidna (means g1sms/init.sh been run)
[[ -f /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna ]] && UIDNA=$(cat /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna)
IPFSNODEID=$(ipfs id -f='<id>\n')
UIDNA=$(cat ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_uidna)
if [[ $(which gammu) ]]; then
# I am a g1sms NODE, pushing my web interface
ipfs p2p listen /x/g1sms /ip4/127.0.0.1/tcp/10099
else
# Looking for g1sms NODE in my swarm
SMSNODE=$(ls /home/$YOU/.zen/ipfs_swarm/.Qm*/G1SSB/_g1sms | shuf -n 1 | cut -d '/' -f 6 | cut -d '.' -f 2)
sleep 10 # Wait for DHT to propagate.... Then forward /x/g1sms
[[ $SMSNODE ]] && ipfs p2p forward /x/g1sms /ip4/127.0.0.1/tcp/10099 /p2p/$SMSNODE
fi
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
# 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