Compare commits

...

10 Commits

21 changed files with 388 additions and 72 deletions

10
debug/GSM_PWRKEY.py Executable file
View File

@ -0,0 +1,10 @@
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.OUT)
while True:
GPIO.output(7, GPIO.LOW)
time.sleep(4)
GPIO.output(7, GPIO.HIGH)
break
GPIO.cleanup()

View File

@ -1,4 +1,4 @@
From: support@qo-op.com
To: EMAIL
Subject: SUBJECT
MESSAGE
To: _EMAIL
Subject: _SUBJECT
_MESSAGE

30
shell/0.sms.command.sh Executable file
View File

@ -0,0 +1,30 @@
# Author: Fred (support@qo-op.com)
# Version: 0.2
# License: GPL (http://www.google.com/search?q=GPL)
################################################################################
# READ /tmp/sms.commands and RUN it.. TODO, add keys for security ;)
#################################################################################
# RECEIVE COMMAND FROM zen_sms.php
#<?php
#header("Access-Control-Allow-Origin: *");
#if (strlen($_REQUEST['num']) == 10 ) {
# $newNumber = preg_replace('/^0?/', '+33', $_REQUEST['num']);
# $data = '"'.$newNumber.'" "'.$_REQUEST['val'].'"'.PHP_EOL;
# $fp = fopen('/tmp/sms.commands', 'a');
# fwrite($fp, $data);
#} else {
# return false;
#}
#?>
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
[[ -f /tmp/sms.commands ]] && echo "" > /tmp/sms.commands
tail -fn 1 /tmp/sms.commands | while read -r line
do
if [[ $line != "" ]]; then
mycmd="$MY_PATH/sms_AUTH.sh $line"
echo "RUN: $mycmd" > /tmp/sms.commmand.result
eval "$mycmd" >> /tmp/sms.commmand.result
fi
done

View File

@ -4,6 +4,12 @@
# Version: 0.1
# 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
########################################################################
# \\///
# qo-op
#############
# cron_G1TAG_REFRESH.sh
# Scan all TAG created by current $IPFSNODEID
# Update local and Publish it

View File

@ -14,7 +14,7 @@ if [[ -f $MY_PATH/.install/.GPATH ]]; then source $MY_PATH/.install/.GPATH; fi
if [[ -f $MY_PATH/../.install/.GPATH ]]; then source $MY_PATH/../.install/.GPATH; fi
YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
if [[ "$USER" != "root" ]]; then echo "Hey, $USER you must at least be admin of your system (sudo $0)"; exit; fi
#if [[ "$USER" != "root" ]]; then echo "Hey, $USER you must at least be admin of your system (sudo $0)"; exit; fi # BUG because cron USER=""
if [[ "$YOU" == "" || "$YOU" == "root" ]]; then echo "BAD IPFS. Aucune installation IPFS satisfaisante ici... Ciao $YOU !"; exit; fi
IPFSNODEID=$(su $YOU -c "ipfs id -f='<id>\n'")
cd $GPATH
@ -22,13 +22,75 @@ source ./shell/init.sh
source ./shell/functions.sh
timebar=$(date +%H:%M)
minut=$(date +%M | sed 's/^0*//')
[[ $minut == "" ]] && minut=0
# log "__CRON:cron_MINUTE.sh - $minut - It is $timebar ... $1"
##################################################################
##################################################################
if [[ "$1" == "" ]]; then
##################################################################
echo "It is $timebar in the morning, or in the night? It depends on your day..."
exit
fi
##################################################################
# EVERY EVERY MINUTES
# START CHECK FOR EMAIL CMD
# START CHECK FOR TX CMD
EVERY=1
##################################################################
if [[ $(($minut%$EVERY)) == 0 ]]; then
##################################################################
# CHECK FOR TX COMMAND
TIMEBEFORE=$(date --date="-$EVERY minutes" +"%s")
[[ $NODE_G1PUBKEY == "" ]] && NODE_G1PUBKEY="5sdcypPRDrzEirtTqXwzvNnMwGpjXK6EhNdti8qsdS4h"
TIMESTAMP=$(date +"%s")
#log "GETTING last $EVERY mn TX : https://duniter-g1.p2p.legal/tx/history/$NODE_G1PUBKEY/times/$TIMEBEFORE/$TIMESTAMP"
curl -s https://duniter-g1.p2p.legal/tx/history/$NODE_G1PUBKEY/times/$TIMEBEFORE/$TIMESTAMP | jq '.history.pending' | jq '.[].comment' > /tmp/zenfontain.g1tx.txt
while read SMS_1_TEXT
do
export $SMS_1_TEXT
log "$NODE_G1PUBKEY TX PENDING $timebar !! COMMENT = " $SMS_1_TEXT
# TODO: VERIFY SOURCE PUBKEY IS RELATED TO A WALLET
# PUBKEY=
# WALLET=$(grep -Rwl "$PUBKEY" ./wallets/*/*.pub | head -n 1)
# export SMS_1_NUMBER=$(echo $WALLET | cut -d '/' -f 3) #TODO CHANGE ON NEXT SHA RELEASE
# TODO: GET PHONE G1SMS (OPTION: SEND SMS FOR AUTH CHALENGE?)
# TODO: EXTRACT CMD FROM TX AND RELAY TO SMS_RECEIVED API
# TODO: MEMORIZE CMD TO MAKE IT ONLY ONE TIME!!!!!!!
done < /tmp/zenfontain.g1tx.txt
# CHECK FOR EMAIL COMMAND
FROM="None"
SUBJECT="None"
# LOOP ON EVERY mn received emails
while [[ $FROM != "" && $SUBJECT != "" ]]; do
# GET POP3 From Address (TODO: CREATE != EMAILs FOR EACH NODE = UIDNA@g1sms.fr )
FROM=$(curl -s --insecure --url "pop3://pop.bookmyname.com/1" --user "vir@g1sms.fr:Z1cG1V1r!" | grep From | head -n 1 | grep -i -o '[A-Z0-9._%+-]\+@[A-Z0-9.-]\+\.[A-Z]\{2,4\}' | tr -d '\r')
# GET POP3 Email Subject (remove carriage return | tr -d '\r' )
export SMS_1_TEXT=$(curl -s --insecure --url "pop3://pop.bookmyname.com/1" --user "vir@g1sms.fr:Z1cG1V1r!" | grep Subject | head -n 1 | cut -d ':' -f 2 | sed -e 's/^[[:space:]]*//' | tr -d '\r')
# SHA256(FROM) as Search ./wallets
[[ $FROM != "" ]] && HMAIL=$(echo -n $FROM | sha256sum | cut -d ' ' -f 1)
# SEARCH for FROM corresponding WALLET
[[ $HMAIL != "" ]] && WALLET=$(grep -Rwl "$HMAIL" ./wallets/*/_email.sha | head -n 1)
# HAVE WALLET SOURCE + CMD: OK
if [[ $WALLET ]]; then
# DELETE EMAIL 1
curl -s --user "vir@g1sms.fr:Z1cG1V1r!" pop3://pop.bookmyname.com/1 --request dele --list-only
# GET G1SMS PHONE NUMBER
export SMS_1_NUMBER=$(echo -n $WALLET | cut -d '/' -f 3) #TODO CHANGE ON NEXT SHA RELEASE
# $SMS_1_NUMBER && $SMS_1_TEXT => RUN ./sms_received.sh
[[ $SMS_1_TEXT != "" && $SMS_1_NUMBER ]] && log "EMAIL CMD = $SMS_1_NUMBER $SMS_1_TEXT" && ./sms_received.sh
cat ./email.txt | sed s/_EMAIL/"${FROM}"/g | sed s/_SUBJECT/"G1sms+ EMAIL ACK"/g | sed s/_MESSAGE/"$SMS_1_TEXT OK"/g | ssmtp ${FROM}
else
if [[ $FROM != "" ]]; then
log "MAIL RECEIVED! NO GOOD SENDER: $FROM"
curl -s --user "vir@g1sms.fr:Z1cG1V1r!" pop3://pop.bookmyname.com/1 --request dele --list-only
cat ./email.txt | sed s/_EMAIL/"${FROM}"/g | sed s/_SUBJECT/"G1sms+ INCONNU"/g | sed s/_MESSAGE/"Portefeuille G1sms inconnu"/g | ssmtp ${FROM}
fi
#log "NO MAIL"
fi
done
##################################################################
fi # END CHECK FOR EMAIL CMD
##################################################################
##################################################################
@ -92,8 +154,12 @@ if [[ "$1" == "KALKUN" ]]; then
member=""
phone=$(echo $number | cut -d '/' -f 3);
if [[ -f $number/$phone.uidname ]]; then member=$(cat $number/$phone.uidname); fi
if [[ ! $member ]]; then member=$phone; fi
if [[ $phone && $member ]]; then add_contact $phone $member; log "__SUB:cron_MINUTE.sh: KALKUN add_contact $phone $member"; fi
if [[ $phone && $member ]]; then
rm_contact $phone $member;
sleep 2
add_contact $phone $member;
log "__SUB:cron_MINUTE.sh: KALKUN refresh contact $phone $member";
fi
done
fi
##################################################################

View File

@ -124,14 +124,14 @@ su $YOU -c "ipfs get --output=./wallets_swarm/ /ipns/$IPFSNODEID"
count=1
# Search for All peers Nodes. TODO: To be changed when Swarm is too bug or not expendanding
#for id in ./wallets/.Qm*/;
for id in $(su $YOU -c "ipfs swarm peers" | awk -F '/' '{print $7}');
do
count=$((count+1))
id=$(echo $id | cut -d '.' -f 3 | cut -d '/' -f 1)
log "__SUB:ipfs_swarm_wallets_refresh: IPFS: ipfs get --output=./wallets_swarm/ /ipns/$id"
rm -Rf ./wallets_swarm/.$id
./shell/timeout.sh -t 20 su $YOU -c "ipfs get --output=./wallets_swarm/ /ipns/$id"
done
#for id in $(su $YOU -c "ipfs swarm peers" | awk -F '/' '{print $7}');
#do
# count=$((count+1))
# id=$(echo $id | cut -d '.' -f 3 | cut -d '/' -f 1)
# log "__SUB:ipfs_swarm_wallets_refresh: IPFS: ipfs get --output=./wallets_swarm/ /ipns/$id"
# rm -Rf ./wallets_swarm/.$id
# ./shell/timeout.sh -t 20 su $YOU -c "ipfs get --output=./wallets_swarm/ /ipns/$id"
#done
log "__SUB:ipfs_swarm_wallets_refresh: ./wallets_swarm/ RENEW from $count peers .........OK!!!"
@ -320,6 +320,7 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
RIBFILE="./wallets/$PHONE/$PHONE.uidrib" # Contains phone wallet related UID Pubkey
NAMEFILE="./wallets/$PHONE/$PHONE.uidname" # Contains the member UID related to wallet
MAILFILE="./wallets/$PHONE/$PHONE.email" # Contains the member EMAIL (Send BILLET)
HMAILFILE="./wallets/$PHONE/_email.sha" # Contains sha256 EMAIL (Email CMD wallet owner search)
GPGMAILFILE="./wallets/$PHONE/$PHONE.email.gpg" # Contains the member EMAIL (Send BILLET)
UIDNAFILE="./wallets/$PHONE/$PHONE.uidna" # Contains the G1sms+ UID Name for recursive VIR
GEOFILE="./wallets/$PHONE/$PHONE.uidgeo.json" # Contains the member GeoPoint from member Cesium+ related to wallet
@ -429,8 +430,8 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
# CYPHER EMAIL FILE
if [[ ! -f "$GPGMAILFILE" ]]; then
# ------------8<------------------
log "__SUB:sms_INIT_ACCOUNT: NO EMAIL .gpg file, CREATING it"
if [ -f "$MAILFILE" ]; then
log "__SUB:sms_INIT_ACCOUNT: NO EMAIL .gpg file, CREATING it"
MAIL=$(cat "$MAILFILE");
echo "${GPGPASS}" | gpg -q --output "$GPGMAILFILE" --yes --pinentry-mode loopback --symmetric --passphrase-fd 0 "$MAILFILE";
else
@ -441,9 +442,12 @@ log "__SUB:sms_INIT_ACCOUNT: ($1=phone, $2=NOSMS)"
log "__SUB:sms_INIT_ACCOUNT: DECODING EMAIL .gpg... "
echo "${GPGPASS}" | gpg -d -q --output "$MAILFILE" --yes --pinentry-mode loopback --passphrase-fd 0 "$GPGMAILFILE"
MAIL=$(cat "$MAILFILE");
# Double decypher (TODO: stop PGP for email)
[[ $MAIL == "" && -f "$MAILFILE.node.crypt" ]] && ./shell/natools.py decrypt -k "$NODE_G1AUTHFILE" -i "$MAILFILE.node.crypt" -o "$MAILFILE" && MAIL=$(cat "$MAILFILE");
# EMPTY CLEAR EMAIL FILE
[[ $MAIL != "" ]] && echo "" > "$MAILFILE" || log "SYSTEM ERROR :: MAIL EMPTY !!! GPG???"
[[ $MAIL != "" ]] && echo "" > "$MAILFILE" || log "SYSTEM ERROR :: MAIL EMPTY !!! GPG PROBLEM???"
# Create _email.sha
[[ $MAIL != "" && ! -f $HMAILFILE ]] && echo -n $MAIL | sha256sum | cut -d ' ' -f 1 > $HMAILFILE
fi
# ------------8<------------------
@ -647,6 +651,7 @@ function add_contact(){
$sql "INSERT INTO user_group (id_group, id_pbk, id_pbk_groups, id_user) VALUES ('$id_user', '$id_user', '1', '1')" || exit 1
else
log "${red}Contact already exist$c_"
#TODO: UPDATE Kalkun Contact database
fi
}

View File

@ -1,6 +0,0 @@
duniter.moul.re:443
g1.duniter.fr:443
g1.duniter.org:443
g1.le-sou.org:443
g1.monnaielibreoccitanie.org:443
g1.presles.fr:443

View File

@ -23,7 +23,7 @@ export GPGPASS=$(cat "/home/$YOU/.ipfs/config" | jq '.Identity.PrivKey' | sed s/
if [ ! $GPGPASS ]; then echo "FATAL ERROR:: IPFS Node.Identity.PrivKey GPGPASS EMPTY"; exit; fi
# GET SWARM KEY G1sms+ .ipfs/swarm.key
export SWARMKEY=$(cat "/home/$YOU/.ipfs/swarm.key" | tail -n 1)
export SWARMKEY=$(cat "/home/$YOU/.ipfs/swarm.key.old" | tail -n 1)
if [ ! $SWARMKEY ]; then echo "FATAL ERROR:: .ipfs/swarm.key EMPTY"; exit; fi
##################################################################

28
shell/key_create_dunikey.py Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env python3
# This Python script gets Duniter creddentials as arguments, and writes a PubSec file that should be compatible with Cesium and Silkaj(DuniterPy) clients.
# launch with :
# python3 key_create_dnuikey.py <id> <mdp>
# depends on duniterpy 0.56
### Licence - WTFPL
# This script was written my Matograine, in the hope that it will be helpful.
# Do What The Fuck you like with it. There is :
# * no guarantee that this will work
# * no support of any kind
#
# If this is helpful, please consider making a donation to the developper's pubkey : 78ZwwgpgdH5uLZLbThUQH7LKwPgjMunYfLiCfUCySkM8
# Have fun
from sys import argv
from duniterpy.key import SigningKey
# path to save to
path = "/tmp/secret.dunikey"
key = SigningKey.from_credentials(argv[1], argv[2], None)
key.save_pubsec_file(path)
print(
"G1 Wallet: ",
key.pubkey,
)

View File

@ -45,7 +45,7 @@ for result in $(find billets/ -daystart -mtime +$vieux -type d -name "*"); do
if [[ "$virement" == "0.0" ]]; then
echo "G1Billet déjà vide, suppression de $result"; rm -Rf $result;
else
PAY=$(/usr/local/bin/silkaj -p duniter-g1.p2p.legal:443 tx --amount="$virement" --output="$dest" --comment="[G1Billet] $numero" -y)
PAY=$(/usr/local/bin/silkaj -p g1.presles.fr:443 tx --amount="$virement" --output="$dest" --comment="[G1Billet] $numero" -y)
if [[ ! $(echo $PAY | grep "successfully sent") ]]; then
echo "!!!! ERREUR: $virement Something Wrong happened with $result. Moving to /tmp/ERROR_BILL_$billetname (please check or remove)"
mkdir -p /tmp/ERROR_BILL_$billetname

56
shell/sms_AUTH.sh Executable file
View File

@ -0,0 +1,56 @@
#!/bin/bash
################################################################################
# Author: Fred (support@qo-op.com)
# Version: 0.1
# 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
if [[ -f $MY_PATH/.install/.GPATH ]]; then source $MY_PATH/.install/.GPATH; fi
if [[ -f $MY_PATH/../.install/.GPATH ]]; then source $MY_PATH/../.install/.GPATH; fi
cd $GPATH
source ./shell/init.sh
source ./shell/functions.sh
PHONE=$1
VALEUR=$2
TODAY=$(date '+%Y%m%d')
log "__SUB:sms_AUTH.sh ($PHONE, $VALEUR)"
## INITIALIZE RESULT FILE
[[ $VALEUR == "" ]] && echo "Indiquez la valeur des G1Billets" && exit 1
[[ $PHONE != "" ]] && sms_INIT_ACCOUNT "$PHONE" "NOSMS" || exit 1
[[ $UNKNOWN == "unknown" ]] && echo "G1sms Wallet $PHONE inconnu! Envoyer N au $MASTERPHONE" && exit 1
# Get AMOUNTG1, AMOUNTLOVE, AMOUNTDU
AMOUNTG1=$(./silkaj/silkaj amount "$PUBKEY")
AMOUNTDU=$(bc -l <<< "scale=2; $AMOUNTG1 / $DUFACTOR")
AMOUNTLOVE=$(bc -l <<< "scale=0; $AMOUNTG1 * 100 / $DUFACTOR")
# Convert amount to G1 unit
VIR=$(bc -l <<< "scale=2; $VALEUR * $DUFACTOR / 100")
# Need at least $MIN G1 available!
MIN=$(bc -l <<< "$AMOUNTG1 - $LIMIT")
testmin=$( echo "${VIR} < ${MIN}" | bc -l )
SMSPIN=$((1000 + RANDOM % 9999))
log "__SUB:sms_AUTH.sh: CODE $SMSPIN : $VIR < $MIN ? $testmin"
if [[ "$testmin" -eq "1" ]]
then
mess="CODE: $SMSPIN
A saisir pour vous authentifier...
[G1] Zen Astroport Satellite #$(cat /etc/hostname)"
# Send response SMS
sms_SEND "$PHONE" "$mess"
echo $SMSPIN > /tmp/$PHONE.PIN.auth
echo $SMSPIN
else
text="Solde: $AMOUNTLOVE LOVE ($AMOUNTG1 G1 = $AMOUNTDU DU)
Insuffisant (minimum $VIR G1 + $LIMIT G1)"
sms_ERROR "$PHONE" "$text"
echo "Minimum $VIR G1 + $LIMIT G1"
fi
log "__SUB:sms_AUTH.sh: END sms_AUTH.sh "
log "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
exit

View File

@ -96,7 +96,7 @@ then
rm -f "./authfile"
log_history $PHONE "G1BILLET, $TRANSAC, $BILLETPUBKEY"
sleep 3
sleep 5
# Fill BILLET with TRANSAC amount
PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$TRANSAC" --output="$BILLETPUBKEY" --comment="G1Billet $NUMBER" -y)
if [[ "$(echo $PAY | cut -d '|' -f 1)" != "KO" ]]; then
@ -131,7 +131,7 @@ then
done
# + G1SMS Commission
sleep 2
sleep 10
COM=$(./silkaj/silkaj transaction --auth-scrypt -salt="$PHONE" -password="$PIN" --amount="$BILLCOM" --output="$NODE_G1PUBKEY" --comment="[G1sms+] Achat G1Billets" -y)
# POUR IMPRIMER LES BILLETS! Brancher votre imprimante, configurer cups, activer code lp ;)
@ -160,7 +160,7 @@ Support: $ADMINPSEUDO ($ADMINPHONE)
sms_SEND "$phone" "$mess"
# ADMIN ALERT SMS + TODO Add ADMINEMAIL parameter in "install.sh"
sms_SEND "$ADMINPHONE" "$MEMBER vient de créer $NBbillets G1Billets de $VALbillet $UNIT ($TRANSAC G1): $MAIL"
cat ./email.txt | sed s/EMAIL/frenault@linkeo.com/g | sed s/SUBJECT/Creation_G1Billets/g | sed s/MESSAGE/"$MEMBER ($PHONE) vient de creer $NBbillets G1Billets de $VALbillet $UNIT ($TRANSAC G1) vers $MAIL"/g | ssmtp "frenault@linkeo.com"
cat ./email.txt | sed s/_EMAIL/frenault@linkeo.com/g | sed s/_SUBJECT/Creation_G1Billets/g | sed s/_MESSAGE/"$MEMBER ($PHONE) vient de creer $NBbillets G1Billets de $VALbillet $UNIT ($TRANSAC G1) vers $MAIL"/g | ssmtp "frenault@linkeo.com"
#####################################
# Amount too High, solde insuffisant

View File

@ -7,21 +7,22 @@ source ./shell/functions.sh
log "X sms_BILLETCHK.sh $0"
PHONE="$1"
CODE="$2 $3"
SEC="$4 $5 $6 $7"
CODE=""
# Construct billet path
bpath=$(echo "$CODE" | sed 's/ /_/g')
bpath=$(echo "$2 $3" | sed 's/ /_/g')
[[ -d "./billets/$bpath" ]] && CODE="$2 $3" && SEC="$4 $5 $6 $7" && zpath=$bpath
if [ -d "./billets/$bpath" ]
then
SECRET=$(cat "./billets/$bpath/note.secret")
SALT=$(cat "./billets/$bpath/note.salt")
VALbillet=$(cat "./billets/$bpath/note.value")
UNIT=$(cat "./billets/$bpath/note.unit")
BILLETPUBKEY=$(cat "./billets/$bpath/note.pubkey")
oldpath=$(echo "$2 $3 $4 $5" | sed 's/ /_/g')
[[ -d "./billets/$oldpath" ]] && CODE="$2 $3 $4 $5" && SEC="$6 $7 $8" && zpath=$oldpath
AMOUNTG1=$(./silkaj/silkaj amount "$BILLETPUBKEY")
if [[ $CODE != "" ]]; then
SECRET=$(cat "./billets/$zpath/note.secret")
SALT=$(cat "./billets/$zpath/note.salt")
VALbillet=$(cat "./billets/$zpath/note.love")
UNIT="LOVE"
BILLETPUBKEY=$(cat "./billets/$zpath/note.pubkey")
G1=$(./silkaj/silkaj amount "$BILLETPUBKEY")
log "Billet: $AMOUNTG1 ($VALbillet $UNIT): $BILLETPUBKEY"
# NO GOOD SECRET
@ -29,11 +30,11 @@ then
# SEND ACTUAL BILLET VALUE
mess="[G1SMS]
Billet de $VALbillet $UNIT Valide!
Valeur: $AMOUNTG1 G1
Valeur: $G1 G1
https://www.g1sms.fr/contact"
sms_SEND "$PHONE" "$mess"
log "BILLETCHK: $VALbillet $UNIT ($AMOUNTG1 G1)"
log_history $PHONE "BILLET_CHK, $AMOUNTG1, $bpath"
log "BILLETCHK: $VALbillet $UNIT ($G1 G1)"
log_history $PHONE "BILLET_CHK, $G1, $zpath"
else
# TRANSFER & DESTROY
sms_INIT_ACCOUNT "$PHONE" "NOSMS"
@ -41,35 +42,43 @@ https://www.g1sms.fr/contact"
# Account creation
sms_INIT_ACCOUNT "$PHONE"
fi
log "./silkaj/silkaj transaction --auth-scrypt -salt=\"$CODE\" -password=\"$SEC$SALT\" --amount=\"$AMOUNTG1\" --output=\"$PUBKEY\" --comment=\"THIRD_PARTY_MANAGER:$NODE_G1PUBKEY:G1SMS:ENCAISSEMENT:$CODE\" -y"
PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$CODE" -password="$SEC$SALT" --amount="$AMOUNTG1" --output="$PUBKEY" --comment="THIRD_PARTY_MANAGER:$NODE_G1PUBKEY:ENCAISSEMENT:$CODE" -y)
################ BUG SILKAJ TX
log "python3 ./shell/key_create_dunikey.py $CODE / $SEC $SALT"
# [[ $SALT != "" ]] && PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$CODE" -password="$SEC $SALT" --amount="$G1" --output="$PUBKEY" --comment="THIRD_PARTY_MANAGER:$NODE_G1PUBKEY:ENCAISSEMENT:$CODE" -y) \
# || PAY=$(./silkaj/silkaj transaction --auth-scrypt -salt="$CODE" -password="$SEC" --amount="$G1" --output="$PUBKEY" --comment="THIRD_PARTY_MANAGER:$NODE_G1PUBKEY:ENCAISSEMENT:$CODE" -y)
# MAKE .dunikey file and use latest silkaj
[[ $SALT != "" ]] && python3 ./shell/key_create_dunikey.py "$CODE" "$SEC $SALT" \
|| python3 ./shell/key_create_dunikey.py "$CODE" "$SEC"
log "silkaj -p duniter-g1.p2p.legal:443 -af --file /tmp/secret.dunikey tx --output $PUBKEY --amount $G1"
PAY=$(silkaj -p duniter-g1.p2p.legal:443 -af --file /tmp/secret.dunikey tx --output $PUBKEY --amount $G1 -y)
log "$PAY"
### TODO AMELIORER ANALYSE DU RETOUR SILKAJ
if [[ "$(echo $PAY | cut -d '|' -f 1)" != "KO" ]]; then
# DESTROY BILLET
rm -Rf ./billets/$bpath
rm -Rf ./billets/$zpath
# DESTROY PUBLIC CACHE in /tmp
if [ -d "/tmp/billets_valides/$bpath" ]; then
rm -Rf /tmp/billets_valides/$bpath
if [ -d "/tmp/billets_valides/$zpath" ]; then
rm -Rf /tmp/billets_valides/$zpath
fi
SOLDE=$(./silkaj/silkaj amount "$PUBKEY")
mess="[G1SMS]
ENCAISSEMENT de $VALbillet $UNIT ($AMOUNTG1 G1)
ENCAISSEMENT de $VALbillet $UNIT ($G1 G1)
dans portefeuille $UIDNA ($PHONE)
OK!
Solde: $SOLDE G1"
sms_SEND "$PHONE" "$mess"
log "BILLETCHK DESTROY: $VALbillet $UNIT ($AMOUNTG1 G1)"
log "BILLETCHK DESTROY: $VALbillet $UNIT ($G1 G1)"
log "=> $PUBKEY"
log_history $PHONE "BILLET_CHK, $AMOUNTG1, $bpath, $PUBKEY"
log_history $PHONE "BILLET_CHK, $G1, $zpath, $PUBKEY"
else
sms_ERROR "$PHONE" "Erreur! Transaction Impossible! Valeur du G1Billet $AMOUNTG1 G1. Contactez $ADMINPSEUDO : $ADMINPHONE"
sms_ERROR "$PHONE" "Erreur! Transaction Impossible! Valeur du G1Billet $G1 G1. Contactez $ADMINPSEUDO : $ADMINPHONE"
fi
fi
else
sms_SEND "$PHONE" "BILLET \"$CODE\" INCONNU !!"
log_history $PHONE "BILLET_CHK, ERROR, $bpath"
sms_SEND "$PHONE" "BILLET \"$CODE\" inconnu !!"
log_history $PHONE "BILLET_CHK, ERROR, $zpath"
fi
log "END sms_BILLETCHK.sh"

View File

@ -11,7 +11,7 @@
source ./shell/init.sh
source ./shell/functions.sh
log "__SUB:sms_EMAIL.sh.sh: START ($1=phone, $2=mail)"
log "__SUB:sms_EMAIL.sh: START ($1=phone, $2=mail)"
phone="$1"
mail="$2"
@ -30,7 +30,7 @@ if [[ "$mail" != "" ]]; then
echo "$mail" > "$MAILFILE"
./shell/natools.py encrypt -p $NODE_G1PUBKEY -i "$MAILFILE" -o "$MAILFILE.node.crypt"
echo "" > "$MAILFILE"
log "__SUB:sms_EMAIL.sh.sh: EMAIL $MEMBER ($PHONE) NOUVEAU: $mail... Publishing to IPFS"
log "__SUB:sms_EMAIL.sh: EMAIL $MEMBER ($PHONE) NOUVEAU: $mail... Publishing to IPFS"
ipfs_node_wallets_add
else
mail=$MAIL
@ -39,10 +39,10 @@ fi
# SEND EMAIL WITH ssmtp
SUBJECT="[G1sms+] $MEMBER, Message de votre portefeuille monnaie libre $UIDNA ($PHONE)"
MESSAGE="Bonjour $MEMBER\n\nVotre porte-monnaie G1sms $UIDNA ($PHONE) a choisi votre email comme contact.\nPour commander vos G1Billets, envoyez par SMS à $MASTERPHONE :\nBILL 10/20/50/100/200/500/1000\n\n\nA bientot <3\n$ADMINPSEUDO ($ADMINPHONE)"
cat ./email.txt | sed s/EMAIL/"${mail}"/g | sed s/SUBJECT/"${SUBJECT}"/g | sed s/MESSAGE/"${MESSAGE}"/g | ssmtp ${mail}
cat ./email.txt | sed s/_EMAIL/"${mail}"/g | sed s/_SUBJECT/"${SUBJECT}"/g | sed s/_MESSAGE/"${MESSAGE}"/g | ssmtp ${mail}
mpack -s "[G1sms+] $PHONE, $UIDNA :: Envoyer 'BILL nnn' à $MASTERPHONE pour fabriquer des G1Billets (ci-joint exemple de verso)" ./Dos_G1Billets.odt ${mail}
log "__SUB:sms_EMAIL.sh.sh: Send welcome EMAIL to $mail via ssmtp"
log "__SUB:sms_EMAIL.sh: Send welcome EMAIL to $mail via ssmtp"
log_history $PHONE "EMAIL, $mail"
mess="[G1sms+]

View File

@ -14,8 +14,10 @@ function log () {
echo "$line
$1" >> /tmp/tag_READ_XY.log
}
source ./shell/init.sh
source ./shell/functions.sh
#############################################
# No external dependance !!!!
#source ./shell/init.sh
#source ./shell/functions.sh
##############################################
# NODE ENVIRONEMENT DETECTION
##############################################

View File

@ -4,17 +4,19 @@
# PUBKEY G1 DU SWARMMASTER: 8qs69HriAdytcCLzvQGJ15XBwpjAVFx8JoVM2ahue1y7
# ipfs ls /ipns/QmZHTne3bjtMgaXWRqSbdKchJbgq2NaAeVSzFUN7ceYpif
#
# G1sms+ est totalement décentralisé! Il peut être fait de multiples SWARM de Services dont les codes évoluent de façon décentralisé.
# Puis se mettent à jour autour des $ADMINPHONE par consensus d'utilisateurs ;)
# G1sms+ est constitué de multiples essaims (SWARM) qui évoluent de façon décentralisé.
# Ils se mettent à jour autour des $ADMINPHONE par consensus d'utilisateurs ;)
#
# Log => tail -f /tmp/g1sms.log -n 200
# gammu => tail -f /tmp/smsd.log -n 200
#
# PRODUCTION : RAM DISK / NO LOG
# 2 commands needed to make the ramdisk if planning to run from ramdisk to gain some speed
# sudo mkdir /mnt/ramdisk
# sudo mount -t tmpfs -o size=50m tmpfs /mnt/ramdisk
#
# Utiliser la commande ./search fournie pour fouiller dans le code, mais tout est ordonnancé d'ici, donc vous êtes au bon endroit pour commencer à farfouiller.
# Utiliser la commande ./search fournie pour fouiller dans le code,
# mais tout est ordonnancé à partir d'ici, vous êtes au bon endroit pour commencer à farfouiller.
###############################################################################
# EN FAISANT PARTIE DU SWARM G1sms+ VOUS VOUS ENGAGEZ A ASSURER LA SECURITE
# PHYSIQUE ET INFORMATIQUE DE VOTRE NOEUD ET NE PAS INTRODUIRE DE CODE MALVEILLANT
@ -23,7 +25,7 @@
# ELLE EST PROVISION EN CAS DE FRAUDE ET SA REATRIBUTION POURRA EVOLUER...
#
# Author: Fred (support@qo-op.com)
# Version: 0.1
# Version: 0.2
# License: GPL (http://www.google.com/search?q=GPL)
################################################################################
@ -63,7 +65,7 @@ security
##################################################################
# Refresh All peers SWARM Wallets.
##################################################################
ipfs_swarm_wallets_refresh
# ipfs_swarm_wallets_refresh
##################################################################
# Check if PHONE is already registred in G1sms+ SWARM
@ -109,7 +111,7 @@ case "$CMD" in
;;
VIR)
montant=$(echo "$TEXT" | awk '{print $2}' | grep -E "^\-?[0-9]+$")
membre=$(echo "$TEXT" | awk '{print $3}' | grep -E "([A-Za-z0-9\-\_]+$)")
membre=$(echo "$TEXT" | awk '{print $3}' | grep -E "([A-Za-z0-9\-\_]+$)") #TODO: UTF8 Char compatible? zöoma case
if [[ "$montant" != "" && "$membre" != "" ]]; then
./shell/sms_VIR.sh "$PHONE" "$montant" "$membre" &
else
@ -204,8 +206,7 @@ case "$CMD" in
*)
#./shell/sms_ERROR.sh "$PHONE" "$TEXT" &
log "SMS forward to $ADMINPHONE"
sms_SEND "$ADMINPHONE" "ADMIN! BAD SMS FROM $PHONE
$TEXT"
sms_SEND "$ADMINPHONE" "$PHONE !! BAD CMD: $TEXT"
;;
esac

26
www/g1billet.conf Normal file
View File

@ -0,0 +1,26 @@
server {
listen 9980;
server_name rock64.p2p.legal g1sms.local localhost 127.0.0.1;
index index.php index.html;
root /var/www/g1billet;
# set expiration of assets to MAX for caching
location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
expires max;
log_not_found off;
}
# php parsing
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
error_log /var/log/nginx/g1billet_error.log;
access_log /var/log/nginx/g1billet_access.log;
}

17
www/g1billet/code_sms.php Normal file
View File

@ -0,0 +1,17 @@
<?php
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;
}
?>

13
www/g1billet/test.php Normal file
View File

@ -0,0 +1,13 @@
<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
?>

15
www/g1billet/zen_sms.php Normal file
View File

@ -0,0 +1,15 @@
<?php
header("Access-Control-Allow-Origin: *");
if (strlen($_REQUEST['num']) == 10 ) {
$newNumber = preg_replace('/^0?/', '+33', $_REQUEST['num']);
$data = '"'.$newNumber.'" "'.$_REQUEST['val'].'"'.PHP_EOL;
$fp = fopen('/tmp/sms.commands', 'a');
fwrite($fp, $data);
sleep(1);
echo exec('cat /tmp/sms.commmand.result');
return true;
} else {
return false;
}
?>

38
www/rompr.conf Normal file
View File

@ -0,0 +1,38 @@
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/rompr;
index index.php index.html index.htm;
server_name copylaradio;
# This section can be copied into an existing default setup
location / {
allow all;
index index.php;
location ~ \.php {
try_files $uri index.php =404;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include /etc/nginx/fastcgi_params;
fastcgi_read_timeout 1800;
}
error_page 404 = /404.php;
try_files $uri $uri/ =404;
location ~ /albumart/* {
expires -1s;
}
}
# IPFS GATEWAY PROXY
location /ipfs {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}