PORT mode mitraillette

This commit is contained in:
fred 2023-09-09 23:53:11 +02:00
parent e4eaaa5728
commit 37445d7ba2
3 changed files with 31 additions and 33 deletions

View File

@ -13,8 +13,7 @@ MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
. "${MY_PATH}/tools/my.sh"
PORT=12345
[[ $(zIp) ]] && PORT=45780
PORT=45779
YOU=$(myIpfsApi); ## API of $USER running ipfs
echo "YOU=$YOU"
@ -39,7 +38,7 @@ Server: Astroport.ONE
Content-Type: text/html; charset=UTF-8
'
echo "_____________________ $PORT ________________________________ $(date)"
echo "LAUNCHING Astroport API Server - TUBE : $LIBRA - "
echo "LAUNCHING Astroport API Server : ASTROPORT : ${myASTROPORT}"
echo
echo "_________________________________________________________"
@ -52,43 +51,38 @@ while true; do
start=`date +%s`
MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
[[ $(zIp) ]] && PORT=45779
PORT=$(cat ~/.zen/tmp/PORT) || PORT=45779
# EACH VISITOR RECEIVE COMMAND RESPONSE ON
#~ ## RANDOM PORT = RESPONSE SOCKET & IPNS SESSION TOKEN
#~ [ ${PORT} -le 12345 ] && PORT=$((PORT+${RANDOM:0:2})) || PORT=$((PORT-${RANDOM:0:2}))
#~ ## RANDOM PORT SWAPPINESS AVOIDING COLLISION
#~ [ ${PORT} -eq 12345 ] && PORT=$((PORT+1)) ## AVOID _12345.sh SWARM SUBMAP PORT
# ZIP
if [[ $(zIp) ]]; then
PORT=$((PORT+1)) && [ ${PORT} -ge 45782 ] && PORT=45780 ## ♥Box : OPEN FIREWALL 1234 12345 45780 45781
else
# EACH VISITOR RECEIVE COMMAND RESPONSE ON
## RANDOM PORT = RESPONSE SOCKET & IPNS SESSION TOKEN
[ ${PORT} -le 12345 ] && PORT=$((PORT+${RANDOM:0:2})) || PORT=$((PORT-${RANDOM:0:2}))
## RANDOM PORT SWAPPINESS AVOIDING COLLISION
PORT=$((PORT+1)) && [ ${PORT} -ge 45781 ] && PORT=45780 ## ♥Box : OPEN FIREWALL 1234 12345 45780 45781 ... 45790
fi
[ ${PORT} -eq 12345 ] && PORT=$((PORT+1)) ## AVOID _12345.sh SWARM SUBMAP PORT
PORT=$((PORT+1)) && [ ${PORT} -ge 45791 ] && PORT=45780 ## WAN ASTROPORT 45780 45781 ... 45790
echo ${PORT} > ~/.zen/tmp/PORT
## CHECK PORT IS FREE & KILL OLD ONE
echo "SEARCHING FOR PORT ${PORT}"
ps axf --sort=+utime | grep -w "nc -l -p ${PORT}" | grep -v -E 'color=auto|grep'
pidportinuse=$(ps axf --sort=+utime | grep -w "nc -l -p ${PORT}" | grep -v -E 'color=auto|grep' | awk '{gsub(/^ +| +$/,"")} {print $0}' | tail -n 1 | cut -d " " -f 1)
[[ $pidportinuse ]] && kill -9 $pidportinuse && echo "$(date) KILLING LOST $pidportinuse"
### START MAP STATION 12345
## CHECK 12345 PORT RUNNING (STATION FoF MAP)
maprunning=$(ps auxf --sort=+utime | grep -w '_12345.sh' | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1)
[[ ! $maprunning ]] \
&& echo '(ᵔ◡◡ᵔ) LAUNCHING '${myASTROPORT}:'12345 (ᵔ◡◡ᵔ)' \
&& echo '(ᵔ◡◡ᵔ) MAP LAUNCHING http://'${myIP}':12345 (ᵔ◡◡ᵔ)' \
&& exec $MY_PATH/_12345.sh &
############### ACTIVATE USE ON QUICK IPFS DRIVE
### CREATE IPNS KEY - ACTIVATE WHITH ENOUGH BOOTSTRAP
#~ echo
#~ ipfs key rm ${PORT} > /dev/null 2>&1
#~ SESSIONNS=$(ipfs key gen ${PORT})
#~ echo "IPNS SESSION ${myIPFS}/ipns/$SESSIONNS CREATED"
### # USE IT #
### MIAM=$(echo ${PORT} | ipfs add -q)
### ipfs name publish --allow-offline -t 180s --key=${PORT} /ipfs/$MIAM &
###############
###############
# RESET VARIABLES
CMD="" THAT="" AND="" THIS="" APPNAME="" WHAT="" OBJ="" VAL=""
@ -96,10 +90,15 @@ while true; do
# REPLACE myHOST in http response template (fixing next API meeting point)
echo "$HTTPCORS" > ~/.zen/tmp/coucou/${MOATS}.myHOST.http
myHtml >> ~/.zen/tmp/coucou/${MOATS}.myHOST.http
sed -i -e "s~\"http://127.0.0.1:1234/\"~\"$(myIpfs)\"~g" \
-e "s~http://${myHOST}:12345~http://${myIP}:${PORT}~g" \
## REPLACE RESPONSE PORT
sed -i -e "s~http://127.0.0.1:12345~http://${myIP}:${PORT}~g" \
~/.zen/tmp/coucou/${MOATS}.myHOST.http
## WAN REDIRECT TO HTTPS:// + /${PORT}
[ -z "$isLAN" ] \
&& sed -i -e "s~http://${myIP}:${PORT}~${myASTROPORT}/${PORT}~g" ~/.zen/tmp/coucou/${MOATS}.myHOST.http
############################################################################
## SERVE LANDING REDIRECT PAGE ~/.zen/tmp/coucou/${MOATS}.myHOST.http on PORT 1234 (LOOP BLOCKING POINT)
############################################################################

View File

@ -123,8 +123,8 @@ header {
</form>
<div id="console"><a href="http://pad.p2p.legal/s/Astroport.ONE#Imagine" target="aframe"> CONSOLE ____________</a> <button onclick="document.getElementById('console').style.visibility = 'hidden';">close</button>
<iframe name="aframe" id="aframe" src="http://pad.p2p.legal/s/Astroport.ONE#Imagine" width="100%" height="100%"></iframe>
<div id="console"><a href="https://pad.p2p.legal/s/Astroport.ONE#Imagine" target="aframe"> CONSOLE ____________</a> <button onclick="document.getElementById('console').style.visibility = 'hidden';">close</button>
<iframe name="aframe" id="aframe" src="https://pad.p2p.legal/s/Astroport.ONE#Imagine" width="100%" height="100%"></iframe>
</div>
<br>

View File

@ -357,9 +357,8 @@ myReyalpResuPath() {
myHtml() {
local myHtml=$($RUN sed \
-e "s~\"http://127.0.0.1:1234\"~\"${myASTROPORT}\"~g" \
-e "s~http://127.0.0.1:8080~${myIPFS}~g" \
-e "s~http://127.0.0.1:12345~http://${myHOST}:12345~g" \
-e "s~\"http://127.0.0.1:1234\"~\"${myASTROPORT}\"~g" \
-e "s~http://127.0.0.1:33101~http://${myHOST}:33101~g" \
-e "s~https://ipfs.copylaradio.com~${myIPFSGW}~g" \
-e "s~http://g1billet.localhost:33101~${myG1BILLET}~g" \
@ -424,7 +423,7 @@ myASTROTUBE="https://$(myAstroTube)"
&& myG1BILLET="https://libra.copylaradio.com" \
|| true
## zIP :: PUT YOUR Internet Box IP IN ~/.zen/♥Box ( Forward PORTS 8080 4001 5001 33101 33102 1234 12345 45780 45781 )
## zIP :: PUT YOUR Internet Box IP IN ~/.zen/♥Box ( Forward PORTS 8080 4001 5001 33101 33102 1234 12345 45780 to 45790 )
[ -n "$(zIp)" ] \
&& myASTROPORT="http://$(zIp):1234" \
&& myAPI="http://$(zIp):5001" \