secret = CRYPTIP + 8080/5001 control tiddlers

This commit is contained in:
fred 2022-11-16 04:42:27 +01:00
parent 3fc454640d
commit 2234e599da
4 changed files with 118 additions and 37 deletions

View File

@ -385,8 +385,16 @@ echo "" > ~/.zen/tmp/.ipfsgw.bad.twt # TODO move in 20h12.sh
if [[ -s ~/.zen/tmp/coucou/${MOATS}.astroindex.html ]]; then
echo "GOT TW CACHE !!"
tiddlywiki --load ~/.zen/tmp/coucou/${MOATS}.astroindex.html --output ~/.zen/tmp --render '.' 'miz.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'MadeInZion'
OLDIP=$(cat ~/.zen/tmp/miz.json | jq -r .[].secret)
[[ ! $OLDIP ]] && (echo "$HTTPCORS 501 ERROR - SORRY - OUT OF SWARM#0 TW - CONTINUE " | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && echo "BAD TW (☓‿‿☓) Execution time was "`expr $(date +%s) - $start` seconds. && continue
CRYPTIP=$(cat ~/.zen/tmp/miz.json | jq -r .[].secret)
[[ ! $CRYPTIP ]] && (echo "$HTTPCORS 501 ERROR - SORRY - OUT OF SWARM#0 TW - CONTINUE " | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && echo "BAD TW (☓‿‿☓) Execution time was "`expr $(date +%s) - $start` seconds. && continue
#
# CRYPTO DECODING CRYPTIP -> myIP
rm -f ~/.zen/tmp/myIP.2
echo "$CRYPTIP" | base64 -d > ~/.zen/tmp/myIP.$G1PUB.enc.2
$MY_PATH/natools.py decrypt -f pubsec -k ~/.zen/tmp/coucou/${MOATS}.secret.key -i ~/.zen/tmp/myIP.$G1PUB.enc -o ~/.zen/tmp/myIP.2
OLDIP=$(cat ~/.zen/tmp/myIP.2)
[[ ! $OLDIP ]] && OLDIP=$CRYPTIP ## STILL CLEAR IP TW
echo "TW is on $OLDIP"
wasLAN=$(echo $OLDIP | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
@ -394,16 +402,31 @@ echo "" > ~/.zen/tmp/.ipfsgw.bad.twt # TODO move in 20h12.sh
|| TWIP=$myIP
# LOCKED TW BECOMING ACTIVE GATEWAY
TUBE=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 3)
if [[ $OLDIP == "_SECRET_" || $OLDIP == "$TUBE" || "$TWIP" == "$myIP" ]]; then
echo "_SECRET_ TW PUSHING TW" ## BECOMING OFFICIAL BECOME R/W TW
sed -i "s~$OLDIP~${myIP}~g" ~/.zen/tmp/coucou/${MOATS}.astroindex.html
[[ $OLDIP ! =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]] && TUBE=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 3)
# GET PLAYER FORM Dessin de $PLAYER (LE NOM DE LA CLEF IPNS EST DANS LE TITRE DE "Dessin de Moa" forgé à la création du TW)
if [[ $OLDIP == "_SECRET_" || $TUBE || "$TWIP" == "$myIP" ]]; then
echo "WAS $OLDIP ($TUBE) BECOMING TW GATEWAY : $myIP" ## BECOMING OFFICIAL BECOME R/W TW
###########################
# Modification Tiddlers de contrôle de GW & API
echo '[{"title":"$:/ipfs/saver/api/http/localhost/5001","tags":"$:/ipfs/core $:/ipfs/saver/api","text":"http://'$myIP':5001"}]' > ~/.zen/tmp/5001.json
echo '[{"title":"$:/ipfs/saver/gateway/http/localhost","tags":"$:/ipfs/core $:/ipfs/saver/gateway","text":"http://'$myIP':8080"}]' > ~/.zen/tmp/8080.json
tiddlywiki --load ~/.zen/tmp/coucou/${MOATS}.astroindex.html \
--import "$HOME/.zen/tmp/5001.json" "application/json" \
--import "$HOME/.zen/tmp/8080.json" "application/json" \
--output ~/.zen/tmp/coucou --render "$:/core/save/all" "${MOATS}.newindex.html" "text/plain"
[[ -s ~/.zen/tmp/coucou/${MOATS}.newindex.html ]] \
&& cp ~/.zen/tmp/coucou/${MOATS}.newindex.html ~/.zen/tmp/coucou/${MOATS}.astroindex.html \
&& rm ~/.zen/tmp/coucou/${MOATS}.newindex.html
###########################
# GET PLAYER FROM Dessin de $PLAYER (LE NOM DE LA CLEF IPNS EST DANS LE TITRE DE "Dessin de Moa" forgé à la création du TW)
tiddlywiki --load ~/.zen/tmp/coucou/${MOATS}.astroindex.html --output ~/.zen/tmp --render '.' 'MOA.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' '[tag[moa]]'
PLAYER=$(cat ~/.zen/tmp/MOA.json | jq -r .[].title | rev | cut -d ' ' -f 1 | rev)
PLAYER=$(cat ~/.zen/tmp/MOA.json | jq -r .[].president)
[[ ! $PLAYER ]] && (echo "$HTTPCORS ERROR - BAD moa TAG /ipns/${ASTRONAUTENS} - CONTINUE " | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && echo "BAD MOA (☓‿‿☓) Execution time was "`expr $(date +%s) - $start` seconds. && continue
[[ ! $PLAYER ]] && (echo "$HTTPCORS ERROR - BAD president TAG /ipns/${ASTRONAUTENS} - CONTINUE " | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && echo "BAD MOA (☓‿‿☓) Execution time was "`expr $(date +%s) - $start` seconds. && continue
## CREATE $PLAYER IPNS KEY (for next 20h12)
ipfs key import ${PLAYER} -f pem-pkcs8-cleartext ~/.zen/tmp/coucou/${MOATS}.${G1PUB}.ipns.key
@ -419,6 +442,7 @@ echo "" > ~/.zen/tmp/.ipfsgw.bad.twt # TODO move in 20h12.sh
## MEMORISE PLAYER Ŋ1 ZONE (TODO compare with VISA.new.sh)
echo "$PLAYER" > ~/.zen/game/players/$PLAYER/.player
echo "$G1PUB" > ~/.zen/game/players/$PLAYER/.g1pub
echo "${ASTRONAUTENS}" > ~/.zen/game/players/$PLAYER/.playerns
OLDIP=${myIP}
TWIP=${myIP}
fi

View File

@ -80,12 +80,36 @@ isLAN=$(echo $myIP | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(
#############################################################
## CHECK IF myIP IS ACTUAL OFFICIAL GATEWAY
tiddlywiki --load ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/index.html --output ~/.zen/tmp --render '.' 'miz.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'MadeInZion'
OLDIP=$(cat ~/.zen/tmp/miz.json | jq -r .[].secret)
[[ ! $OLDIP ]] && echo "(╥☁╥ ) ERROR - SORRY - TW IS BROKEN - (╥☁╥ ) " && continue
CRYPTIP=$(cat ~/.zen/tmp/miz.json | jq -r .[].secret)
[[ ! $CRYPTIP ]] && echo "(╥☁╥ ) ERROR - SORRY - CRYPTIP IS BROKEN - (╥☁╥ ) " && continue
#
# CRYPTO DECODING CRYPTIP -> myIP
rm -f ~/.zen/tmp/myIP.2
echo "$CRYPTIP" | base64 -d > ~/.zen/tmp/myIP.$G1PUB.enc.2
$MY_PATH/natools.py decrypt -f pubsec -k ~/.zen/game/players/$PLAYER/secret.dunikey -i ~/.zen/tmp/myIP.$G1PUB.enc -o ~/.zen/tmp/myIP.2
OLDIP=$(cat ~/.zen/tmp/myIP.2)
[[ ! $OLDIP ]] && OLDIP=$CRYPTIP ## STILL CLEAR IP TW ?
echo "TW is on $OLDIP"
[[ ! $OLDIP ]] && echo "(╥☁╥ ) ERROR - SORRY - TW IP IS BROKEN - (╥☁╥ ) " && continue
# WHO IS OFFICIAL TW GATEWAY.
if [[ ! -s ~/.zen/game/players/$PLAYER/ipfs/G1SSB/_g1.pubkey ]]; then
if [[ $OLDIP =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
[[ $OLDIP != $myIP && $OLDIP != "_SECRET_" ]] && ipfs key rm ${PLAYER} && echo "*** OFFICIAL GATEWAY : http://$OLDIP:8080/ipns/$ASTRONAUTENS - (⌐■_■) - ***" && continue
if [[ $OLDIP != $myIP && $OLDIP != "_SECRET_" ]]; then
# NOT MY PLAYER
echo "REMOVING PLAYER $PLAYER"
rm -Rf ~/.zen/game/players/$PLAYER/
ipfs key rm ${PLAYER}
ipfs key rm ${G1PUB}
echo "*** OFFICIAL GATEWAY : http://$OLDIP:8080/ipns/$ASTRONAUTENS ***" && continue
fi
fi
else
echo "OFFICIAL VISA - (⌐■_■) -"
fi
#############################################################
## OLDIP == myIP or TUBE !!
#############################################################
# Connect_PLAYER_To_Gchange.sh : Sync FRIENDS TW
@ -108,10 +132,25 @@ isLAN=$(echo $myIP | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(
##############################################################
####################
# REMOVE OFFCIAL : myIP becomes _SECRET_
sed -i "s~${myIP}~_SECRET_~g" ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/index.html
# PUT TUBE as 8080 & 5001
#sed -i "s~${OLDIP}~_SECRET_~g" ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/index.html
TUBE=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 3)
sed -i "s~_SECRET_~$TUBE~g" ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/index.html
# sed -i "s~_SECRET_~$TUBE~g" ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/index.html
###########################
# Modification Tiddlers de contrôle de GW & API
echo '[{"title":"$:/ipfs/saver/api/http/localhost/5001","tags":"$:/ipfs/core $:/ipfs/saver/api","text":"http://'$TUBE':5001"}]' > ~/.zen/tmp/5001.json
echo '[{"title":"$:/ipfs/saver/gateway/http/localhost","tags":"$:/ipfs/core $:/ipfs/saver/gateway","text":"http://'$TUBE':8080"}]' > ~/.zen/tmp/8080.json
tiddlywiki --load ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/index.html \
--import "$HOME/.zen/tmp/5001.json" "application/json" \
--import "$HOME/.zen/tmp/8080.json" "application/json" \
--output ~/.zen/tmp/${IPFSNODEID}/${PLAYER} --render "$:/core/save/all" "newindex.html" "text/plain"
[[ -s ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/newindex.html ]] \
&& cp ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/newindex.html ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/index.html \
&& rm ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/newindex.html
###########################
####################

View File

@ -58,11 +58,14 @@ do
## Get ${WISHNAME} TW
WISHNAME=$(cat ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/g1voeu/${PLAYER}.g1voeu.json | jq .[] | jq -r 'select(.wish=="'${WISH}'") | .title')
[[ ! ${WISHNAME} ]] && echo "WISH sans NOM - CONTINUE -" && continue
VOEUNS=$(cat ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/g1voeu/${PLAYER}.g1voeu.json | jq .[] | jq -r 'select(.wish=="'${WISH}'") | .ipns')
VOEUNS=$(cat ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/g1voeu/${PLAYER}.g1voeu.json | jq .[] | jq -r 'select(.wish=="'${WISH}'") | .wishns')
VOEUKEY=$(cat ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/g1voeu/${PLAYER}.g1voeu.json | jq .[] | jq -r 'select(.wish=="'${WISH}'") | .wish')
mkdir -p ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/g1voeu/${WISHNAME}/${WISH}
##########################################################################
##########################################################################
## RUN SPECIFIC G1Voeu ASTROBOT PROGRAM (like G1CopierYoutube.sh)
if [[ -s $MY_PATH/G1${WISHNAME}.sh ]]; then
echo "........................ Astrobot G1${WISHNAME}.sh program found !"
@ -72,8 +75,10 @@ do
else
echo "......................... G1${WISHNAME} No special program found !"
fi
##########################################################################
##########################################################################
## RUN TW search & copy treatment
## RUN TW Ŋ1 search & copy treatment
echo "*********************************"
##################################
## Search for [tag[G1${WISHNAME}]] in all Friends TW.

View File

@ -45,8 +45,8 @@ if [[ $SALT != "" && PEPPER != "" ]]; then
## GLOBAL
## GETTING LAST TW via IPFS or HTTP GW
[[ $YOU ]] && echo "http://$myIP:8080/ipns/${ASTRONAUTENS} ($YOU)" && ipfs --timeout 12s cat /ipns/${ASTRONAUTENS} > ~/.zen/tmp/TW/index.html
[[ ! -s ~/.zen/tmp/TW/index.html ]] && echo "$LIBRA/ipns/${ASTRONAUTENS}" && curl -m 12 -so ~/.zen/tmp/TW/index.html "$LIBRA/ipns/${ASTRONAUTENS}"
[[ $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}"
if [ ! -s ~/.zen/tmp/TW/index.html ]; then
rm -f ~/.zen/tmp/TW/index.html
@ -54,10 +54,11 @@ if [[ $SALT != "" && PEPPER != "" ]]; then
else
# EXTRACTION myIP
# EXTRACTION & UPDATE myIP
rm -f ~/.zen/tmp/miz.json
tiddlywiki --load ~/.zen/tmp/TW/index.html --output ~/.zen/tmp --render '.' 'miz.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'MadeInZion'
OLDIP=$(cat ~/.zen/tmp/miz.json | jq -r .[].secret)
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"
@ -162,19 +163,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 "Votre Clef publique G1 est : $G1PUB"; sleep 1
echo "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")
if [ ! -f ~/.zen/tmp/TW.html ]; then
echo "Nouveau Canal TW Astronaute"
echo "***** Gestion du Canal TW Astronaute $PLAYER *****"
mkdir -p ~/.zen/game/players/$PLAYER/ipfs/moa/
cp ~/.zen/Astroport.ONE/templates/twdefault.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
[[ -f ~/.zen/tmp/TW.html ]] && cp ~/.zen/tmp/TW.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
sed -i "s~_ASTROPORT_~/ipns/${IPFSNODEID}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
# GET OLD VALUE
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
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
@ -194,9 +200,25 @@ if [ ! -f ~/.zen/tmp/TW.html ]; then
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~127.0.0.1~$myIP~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~_SECRET_~$myIP~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html # IP of the Astronaut KeyKeeper Gateway
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 127.0.1.1)
#
# CRYPTO ENCODING myIP -> CRYPTIP
echo $myIP > ~/.zen/tmp/myIP
$MY_PATH/natools.py encrypt -p $G1PUB -i ~/.zen/tmp/myIP -o ~/.zen/tmp/myIP.$G1PUB.enc
CRYPTIP=$(cat ~/.zen/tmp/myIP.$G1PUB.enc | base64)
sed -i "s~_SECRET_~$CRYPTIP~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
#
# CRYPTO DECODING CRYPTIP -> myIP
tiddlywiki --load ~/.zen/game/players/$PLAYER/ipfs/moa/index.html --output ~/.zen/tmp --render '.' 'MadeInZion.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'MadeInZion'
CRYPTIP=$(cat ~/.zen/tmp/MadeInZion.json | jq -r .[].secret)
echo "$CRYPTIP" | base64 -d > ~/.zen/tmp/myIP.$G1PUB.enc.2
rm -f ~/.zen/tmp/myIP.2
$MY_PATH/natools.py decrypt -f pubsec -k ~/.zen/game/players/$PLAYER/secret.dunikey -i ~/.zen/tmp/myIP.$G1PUB.enc -o ~/.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
## ADD SYSTEM TW
tiddlywiki --verbose --load ~/.zen/game/players/$PLAYER/ipfs/moa/index.html \
@ -223,15 +245,6 @@ if [ ! -f ~/.zen/tmp/TW.html ]; then
IASTRO=$(ipfs add -Hq ~/.zen/game/players/$PLAYER/ID.png | tail -n 1)
sed -i "s~bafybeidhghlcx3zdzdah2pzddhoicywmydintj4mosgtygr6f2dlfwmg7a~${IASTRO}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
else
echo "BYPASS ASTRONAUT TW INIT"
echo "WARNING - TEMP TW EXISTING - COPYING AS OFFICIAL IPNS TW VAULT"
ASTRO="yes"
fi
## Copy Astro TW
[[ $ASTRO == "yes" ]] && cp ~/.zen/tmp/TW/index.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
echo "## PUBLISHING ${PLAYER} /ipns/${ASTRONAUTENS}/"
IPUSH=$(ipfs add -Hq ~/.zen/game/players/$PLAYER/ipfs/moa/index.html | tail -n 1)