################################################################################ # Author: Fred (support@qo-op.com) # Version: 0.1 # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) ################################################################################ ################################################################################ ## API: UPLANET ## Dedicated to OSM2IPFS & UPlanet Client App # ?uplanet=EMAIL&zlat=LAT&zlon=LON&g1pub=PASS ## https://git.p2p.legal/qo-op/OSM2IPFS ################################################################################ MY_PATH="`dirname \"$0\"`" # relative MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized . "${MY_PATH}/../tools/my.sh" start=`date +%s` echo "PORT=$1 THAT=$2 AND=$3 THIS=$4 APPNAME=$5 WHAT=$6 OBJ=$7 VAL=$8 MOATS=$9 COOKIE=$10" PORT="$1" THAT="$2" AND="$3" THIS="$4" APPNAME="$5" WHAT="$6" OBJ="$7" VAL="$8" MOATS="$9" COOKIE="$10" ### transfer variables according to script HTTPCORS="HTTP/1.1 200 OK Access-Control-Allow-Origin: ${myASTROPORT} Access-Control-Allow-Credentials: true Access-Control-Allow-Methods: GET Server: Astroport.ONE Content-Type: text/html; charset=UTF-8 " function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; } ## CHECK FOR NOT PUBLISHING ALREADY (AVOID IPNS CRUSH) alreadypublishing=$(ps axf --sort=+utime | grep -w 'ipfs name publish --key=' | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) if [[ ${alreadypublishing} ]]; then echo "$HTTPCORS ERROR - (╥☁╥ ) - IPFS ALREADY PUBLISHING RETRY LATER" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 & exit 1 fi ## START MANAGING UPLANET LAT/LON & PLAYER mkdir -p ~/.zen/tmp/${MOATS}/ ## GET & VERIFY PARAM PLAYER=${THAT} [[ ${PLAYER} == "zlat" ]] && PLAYER="@" [[ ${AND} != "zlat" ]] \ && (echo "$HTTPCORS ERROR - BAD PARAMS" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && echo "(☓‿‿☓) Execution time was "`expr $(date +%s) - $start` seconds. && exit 0 LAT=${THIS} [[ ${LAT} == "0" ]] && LAT="0.00" input_number=${LAT} if [[ ! $input_number =~ ^-?[0-9]{1,3}(\.[0-9]{1,2})?$ ]]; then (echo "$HTTPCORS ERROR - BAD LAT $LAT" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && echo "(☓‿‿☓) Execution time was "`expr $(date +%s) - $start` seconds. && exit 0 else # If input_number has one decimal digit, add a trailing zero if [[ ${input_number} =~ ^-?[0-9]+\.[0-9]$ ]]; then input_number="${input_number}0" elif [[ ${input_number} =~ ^-?[0-9]+$ ]]; then # If input_number is an integer, add ".00" input_number="${input_number}.00" fi # Convert input_number to LAT with two decimal digits LAT="${input_number}" fi LON=${WHAT} [[ ${APPNAME} != "zlon" ]] \ && (echo "$HTTPCORS ERROR - BAD PARAMS" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && echo "(☓‿‿☓) Execution time was "`expr $(date +%s) - $start` seconds. && exit 0 [[ ${LON} == "0" ]] && LON="0.00" input_number=${LON} if [[ ! $input_number =~ ^-?[0-9]{1,3}(\.[0-9]{1,2})?$ ]]; then (echo "$HTTPCORS ERROR - BAD LON $LON" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && echo "(☓‿‿☓) Execution time was "`expr $(date +%s) - $start` seconds. && exit 0 else # If input_number has one decimal digit, add a trailing zero if [[ ${input_number} =~ ^-?[0-9]+\.[0-9]$ ]]; then input_number="${input_number}0" elif [[ ${input_number} =~ ^-?[0-9]+$ ]]; then # If input_number is an integer, add ".00" input_number="${input_number}.00" fi # Convert input_number to LAT with two decimal digits LON="${input_number}" fi # NOT RECEIVING PASS. WAS USED TO SECURE PLAYER UMAP KEY... (24s sectors strategy apply now) #~ PASS=$(echo "${RANDOM}${RANDOM}${RANDOM}${RANDOM}" | tail -c-7) #~ ## RECEIVED PASS ## CAN BE USED TO SELECT TW TEMPLATE #~ VAL="$(echo ${VAL} | detox --inline)" ## DETOX VAL #~ [[ ${OBJ} == "g1pub" && ${VAL} != "" ]] && PASS=${VAL} #~ echo "PASS for Umap $LAT $LON is $PASS" ############################################ #### TODO USE THIS PARAMETER TO SELECT TW TEMPLATE ### CHECK PLAYER EMAIL EMAIL="${PLAYER,,}" # lowercase [[ ! ${EMAIL} ]] && (echo "$HTTPCORS ERROR - MISSING ${EMAIL} FOR UPLANET LANDING" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && echo "(☓‿‿☓) Execution time was "`expr $(date +%s) - $start` seconds. && exit 0 ################################ START WORKING WITH KEYS ### SESSION "$LAT" "$LON" KEY ${MY_PATH}/../tools/keygen -t ipfs -o ~/.zen/tmp/${MOATS}/_ipns.priv "${YESTERDATE}${UPLANETNAME}${LAT}" "${YESTERDATE}${UPLANETNAME}${LON}" UMAPNS=$(ipfs key import ${MOATS} -f pem-pkcs8-cleartext ~/.zen/tmp/${MOATS}/_ipns.priv) ipfs key rm ${MOATS} && echo "$LAT" "$LON" "IPNS key identified" ### REDIR="${myIPFS}/ipns/${UMAPNS}" echo "Umap : $REDIR" ## CHECK WHAT IS EMAIL if [[ "${EMAIL}" =~ ^[a-zA-Z0-9.%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$ ]]; then echo "VALID ${EMAIL} EMAIL OK" ## CHECK if PLAYER exists in SWARM $($MY_PATH/../tools/search_for_this_email_in_players.sh ${EMAIL}) ## export ASTROTW and more echo "export ASTROPORT=${ASTROPORT} ASTROTW=${ASTROTW} ASTROG1=${ASTROG1} ASTROMAIL=${EMAIL} ASTROFEED=${FEEDNS}" [[ ${ASTROTW} ]] \ && (echo "$HTTPCORS " | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) \ && exit 0 else echo "BAD EMAIL $EMAIL $LAT $LON" echo "$HTTPCORS BAD EMAIL $EMAIL $LAT $LON - OPEN UMAP LINK - " | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 & exit 0 fi # UPLANET ############################################# ## OCCUPY COMMON CRYPTO KEY CYBERSPACE ## LAT="$LAT" LON="$LON" ###################################################### echo "UMAP = $LAT:$LON" echo "# CALCULATING UMAP G1PUB WALLET" ${MY_PATH}/../tools/keygen -t duniter -o ~/.zen/tmp/${MOATS}/_cesium.key "${UPLANETNAME}${LAT}" "${UPLANETNAME}${LON}" G1PUB=$(cat ~/.zen/tmp/${MOATS}/_cesium.key | grep 'pub:' | cut -d ' ' -f 2) [[ ! ${G1PUB} ]] && (echo "$HTTPCORS ERROR - (╥☁╥ ) - KEYGEN COMPUTATION DISFUNCTON" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && exit 1 echo "UMAP G1PUB : ${G1PUB}" echo "# CALCULATING UMAP IPNS ADDRESS" mkdir -p ~/.zen/tmp/${MOATS}/${G1PUB} mkdir -p ~/.zen/tmp/${MOATS}/${LAT}_${LON} ipfs key rm ${G1PUB} > /dev/null 2>&1 rm ~/.zen/tmp/${MOATS}/_ipns.priv 2>/dev/null ${MY_PATH}/../tools/keygen -t ipfs -o ~/.zen/tmp/${MOATS}/_ipns.priv "${TODATE}${UPLANETNAME}${LAT}" "${TODATE}${UPLANETNAME}${LON}" UMAPNS=$(ipfs key import ${G1PUB} -f pem-pkcs8-cleartext ~/.zen/tmp/${MOATS}/_ipns.priv ) [[ ! ${UMAPNS} ]] && (echo "$HTTPCORS ERROR - (╥☁╥ ) - UMAPNS COMPUTATION DISFUNCTON" | nc -l -p ${PORT} -q 1 > /dev/null 2>&1 &) && exit 1 echo "UMAPNS : ${myIPFS}/ipns/${UMAPNS}" ## ALL TEST PASSED -> CREATE ZENCARD + ASTROID #~ choose salt pepper with variable words count PPASS=$(${MY_PATH}/../tools/diceware.sh $(( $(./tools/getcoins_from_gratitude_box.sh) + 3 )) | xargs) NPASS=$(${MY_PATH}/../tools/diceware.sh $(( $(./tools/getcoins_from_gratitude_box.sh) + 3 )) | xargs) ## CREATE ASTRONAUTE TW ON CURRENT ASTROPORT ( echo VISA.new.sh "${PPASS}" "${NPASS}" "${EMAIL}" "UPlanet" "/ipns/${UMAPNS}" "${LAT}" "${LON}" ##### (☉_☉ ) ####### ${MY_PATH}/../RUNTIME/VISA.new.sh "${PPASS}" "${NPASS}" "${EMAIL}" "UPlanet" "/ipns/${UMAPNS}" "${LAT}" "${LON}" >> ~/.zen/tmp/email.${EMAIL}.${MOATS}.txt ## TO REMOVE : MONITOR ${MY_PATH}/../tools/mailjet.sh "support@qo-op.com" ~/.zen/tmp/email.${EMAIL}.${MOATS}.txt "LOG VISA.new $EMAIL" ## Send VISA.new log to EMAIL end=`date +%s` echo "(TW REGISTRATION) Operation time was "`expr $end - $start` seconds. ) & ######################################## ## Calculating TW IPNS ADDRESS TWADD=$(${MY_PATH}/../tools/keygen -t ipfs "${PPASS}" "${NPASS}") ## HTTP nc ON PORT RESPONSE echo "$HTTPCORS