WAITING WITH SELF REDIRECT 12345

This commit is contained in:
fred 2022-10-07 02:16:53 +02:00
parent 1616c9bed4
commit bc4c734e7a
2 changed files with 25 additions and 7 deletions

View File

@ -17,7 +17,7 @@ MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID)
## CHECK FOR ANY ALREADY RUNNING nc
ncrunning=$(ps auxf --sort=+utime | grep -w nc | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1)
ncrunning=$(ps auxf --sort=+utime | grep -w 'nc -l -p 1234' | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1)
[[ $ncrunning ]] && echo "already running" && exit 1
myIP=$(hostname -I | awk '{print $1}' | head -n 1)
@ -40,7 +40,11 @@ while true; do
arr=(${URL//[=&]/ })
echo "PARAM : ${arr[0]} = ${arr[1]} & ${arr[2]} = ${arr[3]} & ${arr[4]} = ${arr[5]}"
#######################################
### WAITING WITH SELF REDIRECT
rm ~/.zen/tmp/index.redirect
###################################################################################################
while [[ ! -f ~/.zen/tmp/index.redirect && ! $(ps auxf --sort=+utime | grep -w 'nc -l -p 12345' | grep -v -E 'color=auto|grep') ]]; do cat $HOME/.zen/tmp/myIP.http | nc -l -p 12345 -q 1; done &
###################################################################################################
if [[ ${arr[0]} == "email" ]]; then
@ -225,9 +229,17 @@ while true; do
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)
# myIP replacement
sed -i "s~_SECRET_~$myIP~g" ~/.zen/tmp/TW/index.html
sed -i "s~$OLDIP~$myIP~g" ~/.zen/tmp/TW/index.html
##
if [[ ! d ~/.zen/game/players/$PLAYER/ipfs/moa ]]; then
echo "MISSING ASTRONAUT VISA"
echo "ASKING TO $OLDIP"
mkdir -p ~/.zen/game/players/$PLAYER/ipfs/moa
fi
# myIP replacement
sed -i "s~_SECRET_~$myIP~g" ~/.zen/tmp/TW/index.html
sed -i "s~$OLDIP~$myIP~g" ~/.zen/tmp/TW/index.html
cp ~/.zen/tmp/TW/index.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
@ -257,7 +269,9 @@ while true; do
# Injection TWLINK dans template de redirection.
sed "s~_TWLINK_~$TWLINK~g" ~/.zen/Astroport.ONE/templates/index.redirect > ~/.zen/tmp/index.redirect
## Lancement one shot http server
## Attente cloture WAITING 12345. Puis Lancement one shot http server
while [[ $(ps auxf --sort=+utime | grep -w 'nc -l -p 12345' | grep -v -E 'color=auto|grep') ]]; do sleep 0.5; done
cat ~/.zen/tmp/index.redirect | nc -l -p 12345 -q 1 &
###################################################################################################
@ -281,6 +295,10 @@ while true; do
[[ ${arr[2]} == "" ]] && continue
if [[ ${arr[2]} == "TX" ]]; then
echo "ASK FOR VISA TRANSFER FROM "
fi
fi
###################################################################################################

View File

@ -5,13 +5,13 @@ Content-Type: text/html; charset=UTF-8
<!doctype html>
<html>
<head>
<meta http-equiv="refresh" content="30; url='http://127.0.0.1:12345'" />
<meta http-equiv="refresh" content="3; url='http://127.0.0.1:12345'" />
</head>
<body>
<h1>ASTROPORT</h1>
<h2>Astronaute</h2>
<form action = "http://127.0.0.1:12345" method = "GET">
<input type='submit' value='OUVRIR VOTRE TW'>
<input type='submit' value='RECHERCHE TW'>
</form>
</body>
</html>