host:10099 -> ipfs p2p localhost:10097

This commit is contained in:
qo-op 2020-05-23 05:02:11 +02:00
parent 98c50e06e2
commit f93275edfe
6 changed files with 24 additions and 51 deletions

View File

@ -175,9 +175,16 @@ 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/ # && ipfs p2p listen /x/g1sms /ip4/127.0.0.1/tcp/10099 # SEE 'zen/ipfs_OPEN_ports.sh'
if [[ $(which gammu) ]]; then
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'
else
sudo sed "s/_MY_NODE_NAME_/$NODENAME/g" /home/$YOU/.zen/astroport/www/oasis.conf > /tmp/g1sms.conf
sudo sed -i "s/_PORT_/10099/g" /tmp/g1sms.conf
sudo sed -i "s/_LPORT_/10097/g" /tmp/g1sms.conf
sudo sed -i "s/_APPLI_/g1sms/g" /tmp/g1sms.conf
sudo cp -f /tmp/g1sms.conf /etc/nginx/conf.d/g1sms.conf
fi
sudo systemctl restart nginx || err=1

View File

@ -21,13 +21,6 @@ export WHOAMI=$(sbotc whoami | jq -r .id) || er+=" sbotc whoami problem"
TODAY=$(date '+%Y%m%d')
timestamp=$(date -u +%s%N | cut -b1-13)
# VERIFY task relay directory EXISTS and is 777
# LOCAL MODE
[[ ! -d /tmp/loveland_entrance ]] && mkdir -p /tmp/loveland_entrance && chmod -R 777 /tmp/loveland_entrance
# SWARM TASK MODE
[[ ! -d /home/$YOU/.zen/ipfs/.$IPFSNODEID/TASK/loveland_entrance ]] \
&& mkdir -p /home/$YOU/.zen/ipfs/.$IPFSNODEID/TASK/loveland_entrance \
&& chmod -R 777 /home/$YOU/.zen/ipfs/.$IPFSNODEID/TASK/loveland_entrance
echo '
___ __ __
@ -36,26 +29,12 @@ echo '
/ ___ |(__ ) /_/ / / /_/ / /_/ / /_/ / / / /_
/_/ |_/____/\__/_/ \____/ .___/\____/_/ \__/
/_/
Love Land ENTRANCE CHECKING
Love Land ENTRANCE CHECKING
'
[[ ! $G1SMS == "yes" ]] && echo "I am NOT a G1SMS Node... Can't do nothing... EXIT" && exit 1
/home/$YOU/.zen/astroport/zen/ipfs_SWARM_refresh.sh
for hashfile in $(ls /home/$YOU/.zen/ipfs_swarm/.Qm*/TASK/loveland_entrance); do
PP=$(cat $hashfile)
PHONE=$(echo $PP | cut -d '|' -f 1)
PARRAIN=$(echo $PP | cut -d '|' -f 2)
NAISSANCE=$(echo $PP | cut -d '|' -f 3)
HPHONE=$(basename -- "$hashfile")
echo "We have received Ajax Astroport request from $PHONE"
done
# CHECK if PHONE is ALREADY registered in SWARM
# if [[ ! -f /home/$YOU/.zen/ipfs_swarm/.Qm*/CHANNEL/$PHONEHASH@*/_pub ]]; then
# fi
# TODO SSB task relay MODE ??
# Search new SSB Publish
# /home/$YOU/.zen/astroport/zen/ipfs_SWARM_refresh.sh
for hashfile in $(ls /tmp/loveland_entrance/); do
PP=$(cat $hashfile)
@ -66,9 +45,10 @@ for hashfile in $(ls /tmp/loveland_entrance/); do
HPHONE=$(basename -- "$hashfile")
echo "Astroport Ajax Request received $PP"
# TODO SEARCH IN SWARM (* = G1PUB) : /home/$YOU/.zen/ipfs_swarm/*/g1sms/Qm*/$HPHONE/_pub
if [[ ! -f /home/$YOU/.zen/g1sms/$PHONE/_pub ]]; then
# PHONE IS UNKNOW !
# PHONE IS UNKNOWN !
# CHECK for Associated PARRAIN. GET PubKey?
PARRAIN=$(echo "$PARRAIN" | grep -E "([A-Za-z0-9\-\_]+$)")
[[ $PARRAIN ]] && MEMRIB=$(sms_uid2key "$PARRAIN" "$PHONE" "$PIN") && echo "RIB PARRAIN: $MEMRIB"
@ -83,20 +63,12 @@ for hashfile in $(ls /tmp/loveland_entrance/); do
AMOUNTG1=$(silkaj_balance $PUBKEY)
AMOUNTDU=$(bc -l <<< "scale=2; $AMOUNTG1 / $DUFACTOR")
AMOUNTLOVE=$(bc -l <<< "scale=0; $AMOUNTG1 * 100 / $DUFACTOR")
# DOUBLE AUTH SMS !!
echo "RUN $MY_PATH/sms_AUTH.sh "$PHONE" "$PARRAIN" "
mess="Bonjour! Astroport Station"
# Send response SMS
sms_SEND "$PHONE" "$mess"
# SEND THE KEY !! AND START ONBOARDING
fi
done

View File

@ -12,8 +12,8 @@ jQuery(document).ready(function () {
var parrain = jQuery("#parrain");
var naissance = jQuery("#naissance");
var data = '';
// ajax call to ajax.php
jQuery.getJSON("http://127.0.0.1:10099/sms_loveland.php", {
// ajax call to ajax.php
jQuery.getJSON("http://"+host+":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

@ -2,14 +2,21 @@
header("Access-Control-Allow-Origin: *");
if ( strlen($_REQUEST['code']) == 4 && strlen($_REQUEST['num']) == 10 ) {
$newNumber = preg_replace('/^0?/', '+33', $_REQUEST['num']);
$pinfile = '/tmp/'.$newNumber.'.PIN.auth';
if (file_exists($pinfile)) {
$authpin = file_get_contents($pinfile);
if ( trim($authpin) === trim($_REQUEST['code']) ) {
echo "OK ".$authpin. " == ".$_REQUEST['code'];
} else { echo "KO ".$pinfile." != ".$_REQUEST['code']; }
} else { echo "KO FILE ".$pinfile; }
} else {
echo "KO";
return false;
}

View File

@ -1,13 +0,0 @@
<form accept-charset="UTF-8" action="zen_sms.php" autocomplete="off" method="GET" target="_self">
<label for="num">G1sms Wallet Number</label><br />
<input name="num" type="text" value="0612345678" /> <br />
<label for="g1billets_value">G1Billets Value</label><br />
<input name="val" type="text" value="10" /> LOVE <br />
<input type="submit" value="OK" />
</form>
<?php
?>

View File

@ -27,7 +27,7 @@ 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 $((1 + RANDOM % 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
[[ $SMSNODE ]] && ipfs p2p forward /x/g1sms /ip4/127.0.0.1/tcp/10097 /p2p/$SMSNODE
fi
# p2p close --all