From f93275edfe2f496fc6a8865e714fbba8b24f4091 Mon Sep 17 00:00:00 2001 From: qo-op Date: Sat, 23 May 2020 05:02:11 +0200 Subject: [PATCH] host:10099 -> ipfs p2p localhost:10097 --- .install/loveland.sh | 13 +++++++++--- g1sms/sms_ASTROPORT.sh | 36 ++++----------------------------- www/LOVELand/ajaxform.js | 4 ++-- www/LOVELand/g1sms/code_sms.php | 7 +++++++ www/LOVELand/g1sms/test.php | 13 ------------ zen/ipfs_OPEN_ports.sh | 2 +- 6 files changed, 24 insertions(+), 51 deletions(-) delete mode 100644 www/LOVELand/g1sms/test.php diff --git a/.install/loveland.sh b/.install/loveland.sh index be9d568..92d049a 100755 --- a/.install/loveland.sh +++ b/.install/loveland.sh @@ -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 diff --git a/g1sms/sms_ASTROPORT.sh b/g1sms/sms_ASTROPORT.sh index 8cb5eb5..a121632 100755 --- a/g1sms/sms_ASTROPORT.sh +++ b/g1sms/sms_ASTROPORT.sh @@ -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 diff --git a/www/LOVELand/ajaxform.js b/www/LOVELand/ajaxform.js index a4a5a61..d55573d 100644 --- a/www/LOVELand/ajaxform.js +++ b/www/LOVELand/ajaxform.js @@ -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("

Votre inscription en prise en compte...

"); diff --git a/www/LOVELand/g1sms/code_sms.php b/www/LOVELand/g1sms/code_sms.php index 84548e8..0050c64 100644 --- a/www/LOVELand/g1sms/code_sms.php +++ b/www/LOVELand/g1sms/code_sms.php @@ -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; } diff --git a/www/LOVELand/g1sms/test.php b/www/LOVELand/g1sms/test.php deleted file mode 100644 index e252348..0000000 --- a/www/LOVELand/g1sms/test.php +++ /dev/null @@ -1,13 +0,0 @@ - -
-
-
- -
- LOVE
- -
- - diff --git a/zen/ipfs_OPEN_ports.sh b/zen/ipfs_OPEN_ports.sh index af997c5..63a740a 100755 --- a/zen/ipfs_OPEN_ports.sh +++ b/zen/ipfs_OPEN_ports.sh @@ -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