ipfs cat /ipfs/bafybeiftunnb4nyk3b7yxkhvr4wolouw6rhqxi7iiz6rfkjobyg2s3u2l4 > templates/twdefault.html

This commit is contained in:
fred 2022-12-08 18:56:20 +01:00
parent 2af0af955b
commit be48e0a52a
8 changed files with 158 additions and 127 deletions

View File

@ -47,11 +47,12 @@ echo "_________________________________________________________ $(date)"
echo "LAUNCHING Astroport API Server - TUBE : $LIBRA - "
echo
echo "OPEN GCHANGE ${myHTTP}${myHOST}:1234/?salt=totodu56&pepper=totodu56&g1pub"
echo "VISA.new ${myHTTP}${myHOST}:1234/?salt=totodu56&pepper=totodu56&g1pub=on&email=totodu56@yopmail.com"
echo "OPEN TW ${myHTTP}${myHOST}:1234/?salt=totodu56&pepper=totodu56&g1pub=astro"
echo "CREATE PLAYER ON GW : ${myHTTP}${myHOST}:1234/?salt=totodu56&pepper=totodu56&g1pub=on&email=totodu56@yopmail.com"
echo
echo "GCHANGE MESSAGING ${myHTTP}${myHOST}:1234/?salt=totodu56&pepper=totodu56&messaging"
echo
echo "VIDEO URL COPY ${myHTTP}${myHOST}:1234/?salt=totodu56&pepper=totodu56&videourl=https://"
echo "VIDEO URL COPY ${myHTTP}${myHOST}:1234/?salt=totodu56&pepper=totodu56&CopierYoutube=https://"
echo
echo "TESTCRAFT ${myHTTP}${myHOST}:1234/?salt=totodu56&pepper=totodu56&testcraft=on&nodeid=12D3KooWK1ACupF7RD3MNvkBFU9Z6fX11pKRAR99WDzEUiYp5t8j&dataid=QmPXhrqQrS1bePKJUPH9cJ2qe4RrNjaJdRXaJzSjxWuvDi"
echo "_________________________________________________________"
@ -173,9 +174,9 @@ while true; do
###################################################################################################
# API ZERO ## Made In Zion & La Bureautique
if [[ ${arr[0]} == "salt" ]]; then
[[ ! $APPNAME ]] && echo "NO APPNAME - CONTINUE" && continue
############################################################################
# WRITING API : SALT # PEPPER # APPNAME=WHAT # EXTRA PARAM
# WRITING API # SALT # PEPPER # MAKING THE KEY EXIST #########
################### KEY GEN ###################################
echo ">>>>>>>>>>>>>> Application LaBureautique >><< APPNAME = $APPNAME <<<<<<<<<<<<<<<<<<<<"
@ -185,13 +186,8 @@ while true; do
PEPPER=$(urldecode ${arr[3]} | xargs)
[[ ! $PEPPER ]] && (echo "$HTTPCORS ERROR - PEPPER MISSING" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && continue
APPNAME=$(urldecode ${arr[4]} | xargs)
[[ ! $APPNAME ]] && (echo "$HTTPCORS ERROR - APPNAME MISSING" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && continue
WHAT=$(urldecode ${arr[5]} | xargs)
## SAVE "salt" "pepper" DEBUG REMOVE OR PASS ENCRYPT FOR SECURITY REASON
echo "PLAYER CREDENTIALS : \"$SALT\" \"$PEPPER\""
echo "PLAYER : \"$SALT\" \"$PEPPER\" : $APPNAME ($WHAT)"
echo "\"$SALT\" \"$PEPPER\"" > ~/.zen/tmp/coucou/${MOATS}.secret.june
# CALCULATING ${MOATS}.secret.key + G1PUB
@ -205,22 +201,24 @@ while true; do
rm -f ~/.zen/tmp/coucou/${MOATS}.${G1PUB}.ipns.key
${MY_PATH}/tools/keygen -t ipfs -o ~/.zen/tmp/coucou/${MOATS}.${G1PUB}.ipns.key "$SALT" "$PEPPER"
ASTRONAUTENS=$(ipfs key import ${G1PUB} -f pem-pkcs8-cleartext ~/.zen/tmp/coucou/${MOATS}.${G1PUB}.ipns.key )
echo "ASTRONAUTE TW : ${myHTTP}$HOSTP/ipns/${ASTRONAUTENS}"
[[ ! ${ASTRONAUTENS} ]] && (echo "$HTTPCORS ERROR - (╥☁╥ ) - ASTRONAUTENS COMPUTATION DISFUNCTON" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && continue
echo "TW ADDRESS : ${myHTTP}$HOSTP/ipns/${ASTRONAUTENS}"
echo
################### KEY GEN ###################################
#~ # Get PLAYER wallet amount
#~ ( ## SUB PROCESS
#~ COINS=$($MY_PATH/tools/jaklis/jaklis.py -k ~/.zen/tmp/coucou/${MOATS}.secret.key balance)
#~ echo "+++ WALLET BALANCE _ $COINS (G1) _"
#~ end=`date +%s`
#~ echo "G1WALLET (☓‿‿☓) Execution time was "`expr $end - $start` seconds.
#~ ) &
# Get PLAYER wallet amount
( ## SUB PROCESS
COINS=$($MY_PATH/tools/jaklis/jaklis.py -k ~/.zen/tmp/coucou/${MOATS}.secret.key balance)
echo "+++ WALLET BALANCE _ $COINS (G1) _"
end=`date +%s`
echo "G1WALLET (☓‿‿☓) Execution time was "`expr $end - $start` seconds.
) &
########################################
########################################
## ARCHIVE TOCTOC ${WHAT}S KEEP LOG
## ARCHIVE TOCTOC ${WHAT}S KEEP LOG (TODO : ERASE)
########################################
mkdir -p ~/.zen/game/players/.toctoc/
ISTHERE=$(ls -t ~/.zen/game/players/.toctoc/*.${G1PUB}.ipns.key 2>/dev/null | tail -n 1)
@ -288,11 +286,16 @@ while true; do
# G1PUB WITH NO EMAIL -> Open Gchange Profile & Update TW cache
########################################
if [[ "$APPNAME" == "g1pub" && ${arr[7]} == "" ]]; then
## NO EMAIL = REDIRECT TO GCHANGE PROFILE
sed "s~_TWLINK_~https://www.gchange.fr/#/app/user/${G1PUB}/~g" ~/.zen/Astroport.ONE/templates/index.302 > ~/.zen/tmp/coucou/${MOATS}.index.redirect
## https://git.p2p.legal/La_Bureautique/zeg1jeux/src/branch/main/lib/Fred.class.php#L81
echo "url='https://www.gchange.fr/#/app/user/"${G1PUB}"/'" >> ~/.zen/tmp/coucou/${MOATS}.index.redirect
echo "GCHANGE REDIRECTING https://www.gchange.fr/#/app/user/"${G1PUB}"/"
[[ ${WHAT} == "astro" ]] && REPLACE="$LIBRA/ipns/$ASTRONAUTENS" \
|| REPLACE="https://www.gchange.fr/#/app/user/${G1PUB}"
echo ${REPLACE}
## REDIRECT TO TW OR GCHANGE PROFILE
sed "s~_TWLINK_~${REPLACE}/~g" ~/.zen/Astroport.ONE/templates/index.302 > ~/.zen/tmp/coucou/${MOATS}.index.redirect
## USED BY https://git.p2p.legal/La_Bureautique/zeg1jeux/src/branch/main/lib/Fred.class.php#L81
echo "url='"${REPLACE}"'" >> ~/.zen/tmp/coucou/${MOATS}.index.redirect
### REPONSE=$(echo https://www.gchange.fr/#/app/user/${G1PUB}/ | ipfs add -q)
### ipfs name publish --allow-offline --key=${PORT} /ipfs/$REPONSE
### echo "SESSION ${myHTTP}${myHOST}:8080/ipns/$SESSIONNS "
@ -301,7 +304,7 @@ while true; do
${MY_PATH}/tools/TW.cache.sh ${ASTRONAUTENS} ${MOATS}
) &
end=`date +%s`
echo $APPNAME" (0‿‿0) Execution time was "`expr $end - $start` seconds.
echo $APPNAME" (0‿‿0) ${WHAT} Execution time was "`expr $end - $start` seconds.
continue
fi
########################################
@ -443,8 +446,8 @@ echo "" > ~/.zen/tmp/.ipfsgw.bad.twt # TODO move in 20h12.sh
###################################################################################################
###################################################################################################
# API ONE : ?salt=PHRASE%20UNE&pepper=PHRASE%20DEUX&g1pub=on&email/elastic=ELASTICID&pseudo=PROFILENAME
if [[ (${arr[6]} == "email" || ${arr[6]} == "elastic") && ${arr[7]} != "" ]]; then
# API ONE : ?salt=PHRASE%20UNE&pepper=PHRASE%20DEUX&g1pub=on&email=EMAIL&pseudo=PROFILENAME
if [[ ${arr[6]} == "email" && ${arr[7]} != "" ]]; then
[[ $APPNAME != "g1pub" ]] && (echo "$HTTPCORS ERROR - BAD COMMAND $APPNAME" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && echo "(☓‿‿☓) Execution time was "`expr $(date +%s) - $start` seconds. && continue
@ -452,31 +455,33 @@ echo "" > ~/.zen/tmp/.ipfsgw.bad.twt # TODO move in 20h12.sh
SALT=$(urldecode ${arr[1]} | xargs)
PEPPER=$(urldecode ${arr[3]} | xargs)
WHAT=$(urldecode ${arr[7]} | xargs)
# WHAT can contain urlencoded FullURL
EMAIL=$(urldecode ${arr[7]} | xargs)
PSEUDO=$(urldecode ${arr[9]} | xargs)
[[ ! ${WHAT} ]] && (echo "$HTTPCORS ERROR - MISSING ${WHAT} FOR ${WHAT} CONTACT" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && echo "(☓‿‿☓) Execution time was "`expr $(date +%s) - $start` seconds. && continue
[[ ! ${EMAIL} ]] && (echo "$HTTPCORS ERROR - MISSING ${EMAIL} FOR ${WHAT} CONTACT" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && echo "(☓‿‿☓) Execution time was "`expr $(date +%s) - $start` seconds. && continue
## CHECK WHAT IS EMAIL
if [[ "${WHAT}" =~ ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$ ]]; then
if [[ "${EMAIL}" =~ ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$ ]]; then
echo "VALID EMAIL OK"
else
echo "BAD EMAIL"
(echo "$HTTPCORS KO ${WHAT} : bad '" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && continue
(echo "$HTTPCORS KO ${EMAIL} : bad '" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && continue
fi
## CREATE PSEUDO FROM
if [[ ! $PSEUDO ]]; then
PSEUDO=$(echo ${WHAT} | cut -d '@' -f 1)
PSEUDO=$(echo ${EMAIL} | cut -d '@' -f 1)
PSEUDO=${PSEUDO,,}; PSEUDO=${PSEUDO%%[0-9]*}${RANDOM:0:3}
fi
if [[ ! -d ~/.zen/game/players/${WHAT} ]]; then
echo "# ASTRONAUT NEW VISA Create VISA.new.sh in background (~/.zen/tmp/email.${WHAT}.${MOATS}.txt)"
if [[ ! -d ~/.zen/game/players/${EMAIL} ]]; then
echo "# ASTRONAUT NEW VISA Create VISA.new.sh in background (~/.zen/tmp/email.${EMAIL}.${MOATS}.txt)"
(
startvisa=`date +%s`
$MY_PATH/tools/VISA.new.sh "$SALT" "$PEPPER" "${WHAT}" "$PSEUDO" > ~/.zen/tmp/email.${WHAT}.${MOATS}.txt
$MY_PATH/tools/mailjet.sh "${WHAT}" ~/.zen/tmp/email.${WHAT}.${MOATS}.txt
$MY_PATH/tools/VISA.new.sh "$SALT" "$PEPPER" "${EMAIL}" "$PSEUDO" "${WHAT}" > ~/.zen/tmp/email.${EMAIL}.${MOATS}.txt
$MY_PATH/tools/mailjet.sh "${EMAIL}" ~/.zen/tmp/email.${EMAIL}.${MOATS}.txt ## Send VISA.new log to EMAIL
end=`date +%s`
dur=`expr $end - $startvisa`
echo ${MOATS}:${G1PUB}:${PLAYER}:VISA:$dur >> ~/.zen/tmp/${IPFSNODEID}/_timings
@ -484,15 +489,15 @@ echo "" > ~/.zen/tmp/.ipfsgw.bad.twt # TODO move in 20h12.sh
) &
echo "$HTTPCORS - <meta http-equiv='refresh' content='3; url=\"http://"${myHOST}":8080/ipns/"$ASTRONAUTENS"\"'/>
<h1>BOOTING - ASTRONAUT $PSEUDO </h1> IPFS FORMATING - [$SALT + $PEPPER] (${WHAT})
<h1>BOOTING - ASTRONAUT $PSEUDO </h1> IPFS FORMATING - [$SALT + $PEPPER] (${EMAIL})
<br>- TW - http://${myHOST}:8080/ipns/$ASTRONAUTENS <br> - GW - /ipns/$IPFSNODEID" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &
continue
else
# ASTRONAUT EXISTING ${WHAT}
CHECK=$(cat ~/.zen/game/players/${WHAT}/secret.june | grep -w "$SALT")
[[ $CHECK ]] && CHECK=$(cat ~/.zen/game/players/${WHAT}/secret.june | grep -w "$PEPPER")
[[ ! $CHECK ]] && (echo "$HTTPCORS - WARNING - PLAYER ${WHAT} ALREADY HERE" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && echo "(☓‿‿☓) Execution time was "`expr $(date +%s) - $start` seconds. && continue
# ASTRONAUT EXISTING ${EMAIL}
CHECK=$(cat ~/.zen/game/players/${EMAIL}/secret.june | grep -w "$SALT")
[[ $CHECK ]] && CHECK=$(cat ~/.zen/game/players/${EMAIL}/secret.june | grep -w "$PEPPER")
[[ ! $CHECK ]] && (echo "$HTTPCORS - WARNING - PLAYER ${EMAIL} ALREADY HERE" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && echo "(☓‿‿☓) Execution time was "`expr $(date +%s) - $start` seconds. && continue
fi
###################################################################################################
@ -503,9 +508,9 @@ echo "" > ~/.zen/tmp/.ipfsgw.bad.twt # TODO move in 20h12.sh
##############################################
# VIDEOURL
# VIDEOURL : ADD URL TO 'CopierYoutube' tagged Tiddler : TODO
##############################################
if [[ $APPNAME == "videourl" ]]; then
if [[ $APPNAME == "CopierYoutube" ]]; then
echo "$HTTPCORS /ipns/${ASTRONAUTENS} ADDING ${WHAT}"| nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &
end=`date +%s`
echo $APPNAME "(☉_☉ ) ${WHAT} Execution time was "`expr $end - $start` seconds.

View File

@ -1 +1 @@
[{"title":"$:/ipfs/saver/api/http/local/5001","tags":"$:/ipfs/core $:/ipfs/saver/api","text":"http://127.0.0.1:5001"}]
[{"title":"$:/ipfs/saver/api/http/local/5001","tags":"$:/ipfs/core $:/ipfs/saver/api","text":"http://ipfs.localhost:5001"}]

View File

@ -1 +1 @@
[{"title":"$:/ipfs/saver/gateway/local/myip","tags":"$:/ipfs/core $:/ipfs/saver/gateway","text":"http://127.0.0.1:8080"}]
[{"title":"$:/ipfs/saver/gateway/local/myip","tags":"$:/ipfs/core $:/ipfs/saver/gateway","text":"http://ipfs.localhost:8080"}]

View File

@ -42,13 +42,13 @@ html {
<h1>Astroport</h1>
<h2>Internet Reboot !<br>Inscrivez-vous<br>
<form id="formlink" action = "http://127.0.0.1:1234" method = "GET">
<form id="formlink" action = "http://127.0.0.1:1234" method = "GET" enctype="application/x-www-form-urlencoded">
<br>
<b>Associez 2 phrases clefs et votre adresse email</b></br></br>
Phrase 1 : <input name=salt value=''></br>
Phrase 2 : <input name=pepper value=''></br></br>
Bitswap Ŋ1 (délégation de clef à 20h12) : <input type="checkbox" id="g1pub" name="g1pub" checked></br>
- Email -</br><input name=email value=''></br></br>
Lien : <input name=g1pub value=''></br>
Email -</br><input name=email value=''></br></br>
<input type='submit' value='(☼‿‿☼)'>
</form>
</h2>

File diff suppressed because one or more lines are too long

View File

@ -142,8 +142,8 @@ do
LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 2)
echo "$LIBRA/ipns/$ASTRONAUTENS"
echo "http://$myIP:8080/ipns/$ASTRONAUTENS ($YOU)"
[[ $YOU ]] && ipfs --timeout 12s cat /ipns/$ASTRONAUTENS > ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/index.html
[[ ! -s ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/index.html ]] && curl -m 12 -so ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/index.html "$LIBRA/ipns/$ASTRONAUTENS"
[[ $YOU ]] && ipfs --timeout 17s cat /ipns/$ASTRONAUTENS > ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/index.html
[[ ! -s ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/index.html ]] && curl -m 17 -so ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/index.html "$LIBRA/ipns/$ASTRONAUTENS"
## PLAYER TW EXISTING ?
if [ ! -s ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/index.html ]; then

View File

@ -1,57 +1,65 @@
#!/bin/bash
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
ASTRONAUTENS="$1"
MOATS="$2"
[[ ! $ASTRONAUTENS || ! $MOATS ]] && echo "ASTRONAUTENS & MOATS needed" && exit 1
[[ ! $ASTRONAUTENS || ! $MOATS ]] && echo "$(ME) : ASTRONAUTENS & MOATS needed" && exit 1
start=$(date +%s)
IPFSNODEID=$(ipfs id -f='<id>\n') || ( echo "IPFSNODEID MISSING" && exit 1 )
IPFSNODEID=$(ipfs id -f='<id>\n') || ( echo "$(ME) : IPFSNODEID MISSING" && exit 1 )
TUBE=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 3)
## GETTING LAST TW via IPFS
echo "IPFS : ipfs --timeout 12s cat /ipns/${ASTRONAUTENS}"\
echo "$(ME) : IPFS : ipfs --timeout 12s cat /ipns/${ASTRONAUTENS}"\
&& ipfs --timeout 12s cat /ipns/${ASTRONAUTENS} > ~/.zen/tmp/coucou/${MOATS}.astroindex.html
## GETTING LAST TW via HTTP
[[ ! -s ~/.zen/tmp/coucou/${MOATS}.astroindex.html ]] \
&& echo "WWW : $TUBE/ipns/${ASTRONAUTENS}" \
&& echo "$(ME) : WWW : $TUBE/ipns/${ASTRONAUTENS}" \
&& curl -m 12 -so ~/.zen/tmp/coucou/${MOATS}.astroindex.html "$TUBE/ipns/${ASTRONAUTENS}" \
|| curl -m 1 -so ~/.zen/tmp/${MOATS}.html "$TUBE/ipns/${ASTRONAUTENS}" ## Ask caching
### GOT TW !!
if [[ -s ~/.zen/tmp/coucou/${MOATS}.astroindex.html ]]; then
echo "GOT TW !!"
echo "$(ME) : GOT TW !!"
tiddlywiki --load ~/.zen/tmp/coucou/${MOATS}.astroindex.html --output ~/.zen/tmp --render '.' ${MOATS}'MadeInZion.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'MadeInZion'
[[ ! -s ~/.zen/tmp/${MOATS}MadeInZion.json ]] && echo "BAD TW (☓‿‿☓) Execution time was "`expr $(date +%s) - $start` seconds. && exit 1
[[ ! -s ~/.zen/tmp/${MOATS}MadeInZion.json ]] && echo "$(ME) : BAD TW (☓‿‿☓) Execution time was "`expr $(date +%s) - $start` seconds. && exit 1
PLAYER=$(cat ~/.zen/tmp/${MOATS}MadeInZion.json | jq -r .[].player)
## EMAIL STYLE
if [[ "${PLAYER}" =~ ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$ ]]; then
echo "VALID PLAYER (✜‿‿✜) $PLAYER "
echo "$(ME) : VALID PLAYER (✜‿‿✜) $PLAYER "
tiddlywiki --load ~/.zen/tmp/coucou/${MOATS}.astroindex.html --output ~/.zen/tmp --render '.' ${MOATS}'Astroport.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'Astroport'
[[ ! -s ~/.zen/tmp/${MOATS}Astroport.json ]] && echo "BAD TW (☓‿‿☓) Execution time was "`expr $(date +%s) - $start` seconds. && exit 1
espeak "Hello. $(cat ~/.zen/tmp/${MOATS}Astroport.json | jq -r .[].pseudo) Happy to Help you."
[[ ! -s ~/.zen/tmp/${MOATS}Astroport.json ]] && echo "$(ME) : BAD TW (☓‿‿☓) Execution time was "`expr $(date +%s) - $start` seconds. && exit 1
## EXPORT PLAYER VALUE TO CALLING SCRIPT
export PLAYER=$PLAYER
else
echo "BAD PLAYER"
echo "KO ${PLAYER} : (#__#) '" && exit 1
echo "$(ME) : BAD PLAYER"
echo "$(ME) : KO ${PLAYER} : (#__#) '" && exit 1
fi
## IN CACHE
echo "CACHING ~/.zen/tmp/$IPFSNODEID/$PLAYER/"
echo "$(ME) : CACHING ~/.zen/tmp/$IPFSNODEID/$PLAYER/"
mkdir -p ~/.zen/tmp/$IPFSNODEID/$PLAYER/
cp -f ~/.zen/tmp/coucou/${MOATS}.astroindex.html ~/.zen/tmp/$IPFSNODEID/$PLAYER/index.html
### NO TW !!
else
echo "(-__-) NOTHING (-__-)"
echo "$(ME) : (-__-) NOTHING (-__-)"
fi
echo "TW.cache.sh (0‿‿0) Execution time was "`expr $(date +%s) - $start` seconds.
dur=`expr $(date +%s) - $start`
[[ $XDG_SESSION_TYPE == 'x11' ]] && espeak "$dur seconds for $(cat ~/.zen/tmp/${MOATS}Astroport.json | jq -r .[].pseudo) TW caching"
echo "$(ME) : (0‿‿0) Execution time was $dur seconds."
exit 0

View File

@ -5,88 +5,103 @@
# 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
ME="${0##*/}"
! ipfs swarm peers >/dev/null 2>&1 && echo "Lancez 'ipfs daemon' SVP" && exit 1
################################################################################
MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
mkdir -p ~/.zen/tmp/${MOATS}
SALT="$1"
PEPPER="$2"
PLAYER="$3"
PSEUDO="$4"
## Fill UP TW with VIDEO URL
URL="$5"
################################################################################
YOU=$(ipfs swarm peers >/dev/null 2>&1 && echo "$USER" || ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 2)
MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
################################################################################
IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID)
################################################################################
myIP=$(hostname -I | awk '{print $1}' | head -n 1)
isLAN=$(echo $myIP | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
[[ ! $myIP || $isLAN ]] && myIP="ipfs.localhost"
################################################################################
## LOCAL
## CHECK if PLAYER resolve any ASTRONAUTENS
[[ ${PLAYER} ]] && ASTRONAUTENS=$(ipfs key list -l | grep -w "${PLAYER}" | cut -d ' ' -f 1)
[[ ${ASTRONAUTENS} ]] && echo "IPNS $PLAYER EXISTANT http://$myIP:8080/${ASTRONAUTENS} !! DO NOTHING - EXIT -" && exit 0
## Chargement TW !!!
if [[ $SALT != "" && PEPPER != "" ]]; then
ASTRO=""
ipfs key rm gchange 2>/dev/null
rm -f ~/.zen/tmp/gchange.key
${MY_PATH}/keygen -t ipfs -o ~/.zen/tmp/gchange.key "$SALT" "$PEPPER" 2>/dev/null
ASTRONAUTENS=$(ipfs key import gchange -f pem-pkcs8-cleartext ~/.zen/tmp/gchange.key 2>/dev/null)
${MY_PATH}/keygen -t ipfs -o ~/.zen/tmp/${MOATS}/player.key "$SALT" "$PEPPER" 2>/dev/null
ASTRONAUTENS=$(ipfs key import ${MOATS} -f pem-pkcs8-cleartext ~/.zen/tmp/${MOATS}/player.key 2>/dev/null)
echo "/ipns/${ASTRONAUTENS}"
mkdir -p ~/.zen/tmp/TW
rm -f ~/.zen/tmp/TW/index.html
ipfs key rm ${MOATS} 2>/dev/null ## CLEANING
## GLOBAL
## GETTING LAST TW via IPFS or HTTP GW
[[ $YOU ]] && echo "http://$myIP:8080/ipns/${ASTRONAUTENS} ($YOU)" && ipfs --timeout 30s cat /ipns/${ASTRONAUTENS} > ~/.zen/tmp/TW/index.html
[[ ! -s ~/.zen/tmp/TW/index.html ]] && echo "$LIBRA/ipns/${ASTRONAUTENS}" && curl -m 30 -so ~/.zen/tmp/TW/index.html "$LIBRA/ipns/${ASTRONAUTENS}"
mkdir -p ~/.zen/tmp/${MOATS}/TW
if [ ! -s ~/.zen/tmp/TW/index.html ]; then
rm -f ~/.zen/tmp/TW/index.html
echo "Aucun ancien TW détecté! CREATION DU TW Astronaute" ## Compte Gchange
## GETTING LAST TW via IPFS or HTTP GW
[[ $YOU ]] \
&& echo "ipfs --timeout 30s cat /ipns/${ASTRONAUTENS} > ~/.zen/tmp/${MOATS}/TW/index.html ($YOU)" \
&& ipfs --timeout 30s cat /ipns/${ASTRONAUTENS} > ~/.zen/tmp/${MOATS}/TW/index.html
[[ ! -s ~/.zen/tmp/${MOATS}/TW/index.html ]] \
&& echo "TRYING $LIBRA/ipns/${ASTRONAUTENS}" \
&& curl -m 30 -so ~/.zen/tmp/${MOATS}/TW/index.html "$LIBRA/ipns/${ASTRONAUTENS}"
#############################################
## AUCUN RESULTAT
if [ ! -s ~/.zen/tmp/${MOATS}/TW/index.html ]; then
rm -f ~/.zen/tmp/${MOATS}/TW/index.html
echo "CREATION TW Astronaute" ## Nouveau Compte Astronaute
else
#############################################
# TW : DATA TESTING & CACHE
rm -f ~/.zen/tmp/${MOATS}/Astroport.json
tiddlywiki --load ~/.zen/tmp/${MOATS}/TW/index.html --output ~/.zen/tmp/${MOATS} --render '.' 'Astroport.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'Astroport'
ASTROPORT=$(cat ~/.zen/tmp/${MOATS}/Astroport.json | jq -r .[].astroport)
# EXTRACTION & UPDATE myIP
rm -f ~/.zen/tmp/MadeInZion.json
tiddlywiki --load ~/.zen/tmp/TW/index.html --output ~/.zen/tmp --render '.' 'MadeInZion.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'MadeInZion'
OLDIP=$(cat ~/.zen/tmp/MadeInZion.json | jq -r .[].secret)
IPNSTAIL=$(echo $ASTROPORT | rev | cut -f 1 -d '/' | rev)
echo "TW ASTROPORT GATEWAY : ${ASTROPORT}"
[[ $IPNSTAIL == $IPFSNODEID ]] \
&& echo "UPDATING $PLAYER LOCAL CACHE ~/.zen/game/players/$PLAYER/ipfs/moa" \
&& mkdir -p ~/.zen/game/players/$PLAYER/ipfs/moa \
&& cp ~/.zen/tmp/${MOATS}/TW/index.html ~/.zen/game/players/$PLAYER/ipfs/moa/ \
|| echo "PLAYER on $ASTROPORT Station"
echo "TW OFFICIAL GATEWAY : http://$OLDIP:8080//ipns/${ASTRONAUTENS}"
if [[ ! -d ~/.zen/game/players/$PLAYER/ipfs/moa ]]; then
echo "UPDATE $PLAYER LOCAL COPY ~/.zen/game/players/$PLAYER/ipfs/moa"
mkdir -p ~/.zen/game/players/$PLAYER/ipfs/moa
[[ "$myIP" == "$OLDIP" ]] && cp ~/.zen/tmp/TW/index.html ~/.zen/game/players/$PLAYER/ipfs/moa/
fi
# DO NOT CONTINUE
echo "VISA ALREADY EXISTS"
echo "VISA ALREADY EXISTING"
rm -Rf ~/.zen/tmp/${MOATS}
exit 1
fi
fi
################################################################################
##################################################### # NEW PLAYER ###############
################################################################################
echo "=============================================
MadeInZion DIPLOMATIC PASSPORT
ASTROPORT DIPLOMATIC PASSPORT - MadeInZion VISA -
=============================================
A cryptographic key pair to control your P2P Digital Life.
+ Solar Punk garden forest terraforming game.
A Cryptographic Key to control your INTERNET
Adventure & Exploration P2P Terraforming Game.
=============================================
Bienvenue 'Astronaute'"; sleep 1
echo "Création de votre PSEUDO, votre PLAYER, avec PASS (6 chiffres)"
################################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
! ipfs swarm peers >/dev/null 2>&1 && echo "Lancez 'ipfs daemon' SVP" && exit 1
echo "Création de votre PLAYER, votre PSEUDO et PASS (6 chiffres)"
[[ $SALT == "" ]] && SALT=$(${MY_PATH}/diceware.sh 4 | xargs)
echo "-> SALT : $SALT"
@ -103,7 +118,7 @@ PSEUDO=${PSEUDO%%[0-9]*}
# PSEUDO=${PSEUDO,,} #lowercase
[[ ! $PLAYER ]] && PLAYER=${PSEUDO}${RANDOM:0:2}$(${MY_PATH}/diceware.sh 1 | xargs)${RANDOM:0:2} \
&& echo "$PLAYER ! A quelle adresse email vous joindre ?" && read OPLAYER && [[ $OPLAYER ]] && PLAYER=$OPLAYER
&& echo "$PLAYER ! VOTRE EMAIL SVP ?" && read OPLAYER && [[ $OPLAYER ]] && PLAYER=$OPLAYER
[[ -d ~/.zen/game/players/$PLAYER ]] && echo "FATAL ERROR $PLAYER NAME COLLISION. TRY AGAIN." && exit 1
[[ ! $PSEUDO ]] && PSEUDO=$PLAYER
@ -161,25 +176,24 @@ G1PUB=$(cat /tmp/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
PASsec=$(cat /tmp/enc.${PSEUDO}.sec | base58) && rm -f /tmp/${PSEUDO}.sec
qrencode -s 12 -o $HOME/.zen/game/players/$PLAYER/QRsec.png $PASsec
echo "Clef publique G1 est : $G1PUB"; sleep 1
echo "Votre Clef publique G1 est : $G1PUB"; sleep 1
### INITALISATION WIKI dans leurs répertoires de publication IPFS
############ TODO améliorer templates, sed, ajouter index.html, etc...
MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
echo
echo "***** Gestion du Canal TW Astronaute $PLAYER *****"
echo "***** Activation du Canal TW Astronaute $PLAYER *****"
mkdir -p ~/.zen/game/players/$PLAYER/ipfs/moa/
[[ -f ~/.zen/tmp/TW.html ]] && cp ~/.zen/tmp/TW.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html && echo "Restoring TW...." \
|| cp ~/.zen/Astroport.ONE/templates/twdefault.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
cp ~/.zen/Astroport.ONE/templates/twdefault.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~_BIRTHDATE_~${MOATS}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
# GET OLD VALUE
# INSERT ASTROPORT ADRESS
tiddlywiki --load ~/.zen/game/players/$PLAYER/ipfs/moa/index.html --output ~/.zen/tmp --render '.' 'Astroport.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'Astroport'
ASTROPORT=$(cat ~/.zen/tmp/Astroport.json | jq -r .[].astroport)
sed -i "s~$ASTROPORT~/ipns/${IPFSNODEID}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
# INSERT PLAYER DATA
sed -i "s~_PLAYER_~${PLAYER}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~_PSEUDO_~${PSEUDO}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~_WISHKEY_~${G1PUB}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
@ -193,25 +207,26 @@ G1PUB=$(cat /tmp/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
# La Clef IPNS porte comme nom G1PUB
sed -i "s~_MEDIAKEY_~${PLAYER}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~k2k4r8kxfnknsdf7tpyc46ks2jb3s9uvd3lqtcv9xlq9rsoem7jajd75~${ASTRONAUTENS}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~ipfs.infura.io~tube.copylaradio.com~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~ipfs.infura.io~ipfs.copylaradio.com~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
#
sed -i "s~127.0.0.1~$myIP~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html # 8080 & 5001 BEING THE RECORDING GATEWAY (WAN or ipfs.localhost)
#
echo "# CRYPTO ENCODING secret.dunikey -> TW _SECRET_ "
echo $myIP > ~/.zen/tmp/myIP
$MY_PATH/natools.py encrypt -p $G1PUB -i $HOME/.zen/game/players/$PLAYER/secret.dunikey -o $HOME/.zen/tmp/secret.dunikey.$G1PUB.enc
CRYPTIP=$(cat ~/.zen/tmp/secret.dunikey.$G1PUB.enc | base16)
sed -i "s~_SECRET_~$CRYPTIP~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
ENCODING=$(cat ~/.zen/tmp/secret.dunikey.$G1PUB.enc | base16)
sed -i "s~_SECRET_~$ENCODING~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
#
echo "# CRYPTO DECODING CRYPTIP -> myIP"
echo "# CRYPTO DECODING TEST"
tiddlywiki --load ~/.zen/game/players/$PLAYER/ipfs/moa/index.html --output ~/.zen/tmp --render '.' 'MadeInZion.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'MadeInZion'
cat ~/.zen/tmp/MadeInZion.json | jq -r .[].secret | base16 -d > ~/.zen/tmp/myIP.$G1PUB.enc.2
$MY_PATH/natools.py decrypt -f pubsec -k $HOME/.zen/game/players/$PLAYER/secret.dunikey -i $HOME/.zen/tmp/myIP.$G1PUB.enc.2 -o $HOME/.zen/tmp/myIP.2
#
## CRYPTO PROCESS VALIDATED
[[ -s ~/.zen/tmp/myIP.2 ]] && echo "$myIP _SECRET_ CRYPTIP SECURED" \
|| sed -i "s~$CRYPTIP~$myIP~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html # Revert to plaintext _SECRET_ myIP
[[ -s ~/.zen/tmp/myIP.2 ]] && echo "NATOOLS ENCODED secret LAODED" \
|| sed -i "s~$ENCODING~$myIP~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html # Revert to plaintext _SECRET_ myIP
rm -f ~/.zen/tmp/myIP.2