forked from STI/Astroport.ONE
Merge branch 'master' into fix
This commit is contained in:
commit
e26d685118
|
@ -13,9 +13,11 @@ echo "$ME RUNNING"
|
||||||
# Download video, add to ipfs and import new tiddler
|
# Download video, add to ipfs and import new tiddler
|
||||||
# Publish !!
|
# Publish !!
|
||||||
|
|
||||||
|
## TODO USE API 1234 & new_file_in_astroport.sh FOR TW
|
||||||
|
|
||||||
# ASTROBOT FIRST PROCESS
|
# ASTROBOT FIRST PROCESS
|
||||||
# "Copier youtube" + (voeu) => CopierYoutube (G1Voeu G1CopierYoutube) = ASTROBOT copy Ŋ1 "(G1CopierYoutube)"
|
# "Copier youtube" + (voeu) => CopierYoutube (G1Voeu G1CopierYoutube) = ASTROBOT copy Ŋ1 "(G1CopierYoutube)"
|
||||||
|
IPFSNODEID=$(ipfs id -f='<id>\n')
|
||||||
|
|
||||||
INDEX="$1"
|
INDEX="$1"
|
||||||
[[ ! $INDEX ]] && echo "ERROR - Please provide path to source TW index.html" && exit 1
|
[[ ! $INDEX ]] && echo "ERROR - Please provide path to source TW index.html" && exit 1
|
||||||
|
@ -26,53 +28,78 @@ WISHKEY="$2" ## IPNS KEY NAME - G1PUB - PLAYER ...
|
||||||
TWNS=$(ipfs key list -l | grep -w $WISHKEY | cut -d ' ' -f1)
|
TWNS=$(ipfs key list -l | grep -w $WISHKEY | cut -d ' ' -f1)
|
||||||
[[ ! $TWNS ]] && echo "ERROR - Clef IPNS $WISHKEY introuvable!" && exit 1
|
[[ ! $TWNS ]] && echo "ERROR - Clef IPNS $WISHKEY introuvable!" && exit 1
|
||||||
|
|
||||||
# Extract tag=tube from TW into ~/.zen/tmp/$WISHKEY/CopierYoutube.json
|
# Extract tag=tube from TW
|
||||||
MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
|
MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
|
||||||
mkdir -p ~/.zen/tmp/$WISHKEY
|
mkdir -p ~/.zen/tmp/$IPFSNODEID
|
||||||
|
|
||||||
###################################################################
|
###################################################################
|
||||||
## TODO BOUCLER SUR LES INDEX des G1Astronautes G1Ami
|
## TODO BOUCLER SUR LES INDEX des G1Astronautes G1Ami
|
||||||
###################################################################
|
###################################################################
|
||||||
rm -f ~/.zen/tmp/$WISHKEY/CopierYoutube.json
|
rm -f ~/.zen/tmp/CopierYoutube.json
|
||||||
tiddlywiki --load ${INDEX} \
|
tiddlywiki --load ${INDEX} \
|
||||||
--output ~/.zen/tmp/$WISHKEY \
|
--output ~/.zen/tmp \
|
||||||
--render '.' 'CopierYoutube.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' '[tag[CopierYoutube]]'
|
--render '.' 'CopierYoutube.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' '[tag[CopierYoutube]]'
|
||||||
|
|
||||||
echo "cat ~/.zen/tmp/$WISHKEY/CopierYoutube.json"
|
echo "cat ~/.zen/tmp/CopierYoutube.json | jq -r"
|
||||||
|
|
||||||
|
### MAKE CACHE REFRESH FUNCTION
|
||||||
|
#~ #############################
|
||||||
|
#~ ## Refresh _12345.sh IPNS Memories
|
||||||
|
#~ # ipfs name publish --key "MySwarm_$IPFSNODEID" --allow-offline /ipfs/$SWARMH
|
||||||
|
#~ MySwarm=$(ipfs key list -l | grep "MySwarm_$IPFSNODEID" | cut -d ' ' -f 1)
|
||||||
|
#~ if [[ $MySwarm ]]; then
|
||||||
|
#~ #############################
|
||||||
|
#~ mkdir -p ~/.zen/tmp/$MySwarm && rm -Rf ~/.zen/tmp/$MySwarm/*.*
|
||||||
|
|
||||||
|
#~ echo "## Getting Station MySwarm /ipns/$MySwarm"
|
||||||
|
#~ ipfs --timeout 12s get -o ~/.zen/tmp/$MySwarm /ipns/$MySwarm
|
||||||
|
|
||||||
|
#~ echo "## Rebuild ~/.zen/tmp/$IPFSNODEID/yt-dlp.command & yt-dlp.cache"
|
||||||
|
#~ cat ~/.zen/tmp/$MySwarm/*/yt-dlp.command ~/.zen/tmp/$IPFSNODEID/yt-dlp.command | sort | uniq > ~/.zen/tmp/$IPFSNODEID/yt-dlp.command
|
||||||
|
#~ cat ~/.zen/tmp/$MySwarm/*/yt-dlp.cache ~/.zen/tmp/$IPFSNODEID/yt-dlp.cache | sort | uniq > ~/.zen/tmp/$IPFSNODEID/yt-dlp.cache
|
||||||
|
|
||||||
|
#~ #############################
|
||||||
|
#~ fi
|
||||||
|
|
||||||
###################################################################
|
###################################################################
|
||||||
## TEXT TREATMENT
|
## TEXT TREATMENT
|
||||||
## For this TAG, specific extract URL from text field and copy all video from links into tid.json
|
## For this TAG, specific extract URL from text field and copy all video from links into tid.json
|
||||||
for YURL in $(cat ~/.zen/tmp/$WISHKEY/CopierYoutube.json | jq -r '.[].text' | grep 'http'); do
|
for YURL in $(cat ~/.zen/tmp/CopierYoutube.json | jq -r '.[].text' | grep 'http'); do
|
||||||
echo "Detected $YURL"
|
echo "Detected $YURL"
|
||||||
echo "Extracting video playlist"
|
echo "Extracting video playlist"
|
||||||
|
|
||||||
### GETTING ALL VIDEO IDs (for playlist copy)
|
### yt-dlp.command
|
||||||
yt-dlp --print "%(id)s" "${YURL}" >> ~/.zen/tmp/$WISHKEY/ytids.$MOATS
|
[[ ! $(cat ~/.zen/tmp/$IPFSNODEID/yt-dlp.command 2>/dev/null | grep "$YURL") ]] \
|
||||||
|
&& echo "$WISHKEY&$YURL" >> ~/.zen/tmp/$IPFSNODEID/yt-dlp.command
|
||||||
|
|
||||||
|
yt-dlp --print "%(id)s&%(webpage_url)s" "${YURL}" >> ~/.zen/tmp/$IPFSNODEID/yt-dlp.cache.$WISHKEY
|
||||||
|
|
||||||
done # FINISH YURL loop
|
done # FINISH YURL loop
|
||||||
|
|
||||||
echo "cat ~/.zen/tmp/$WISHKEY/ytids.$MOATS"
|
## SORT UNIQ CACHE
|
||||||
|
cat ~/.zen/tmp/$IPFSNODEID/yt-dlp.cache.$WISHKEY | sort | uniq > ~/.zen/tmp/yt-dlp.cache
|
||||||
|
cp ~/.zen/tmp/yt-dlp.cache ~/.zen/tmp/$IPFSNODEID/yt-dlp.cache.$WISHKEY
|
||||||
|
|
||||||
###################################################################
|
###################################################################
|
||||||
[[ ! -s ~/.zen/tmp/$WISHKEY/ytids.$MOATS ]] && echo "AUCUN YOUTUBEID pour CopierYoutube" && exit 0
|
[[ ! -s ~/.zen/tmp/$IPFSNODEID/yt-dlp.cache.$WISHKEY ]] && echo "AUCUN YOUTUBEID pour CopierYoutube" && exit 0
|
||||||
###################################################################
|
###################################################################
|
||||||
|
|
||||||
###################################################################
|
###################################################################
|
||||||
# PROCESS YOUTUBEID VIDEO DOWNLOAD AND CREATE TIDDLER in TW
|
# PROCESS YOUTUBEID VIDEO DOWNLOAD AND CREATE TIDDLER in TW
|
||||||
###################################################################
|
###################################################################
|
||||||
while read YID;
|
while read LINE;
|
||||||
do
|
do
|
||||||
|
|
||||||
[[ -f ~/.zen/tmp/$WISHKEY/$YID.TW.json ]] && echo "Tiddler json already existing : ~/.zen/tmp/$WISHKEY/$YID.TW.json" && continue
|
YID=$(echo "$LINE" | cut -d '&' -f 2)
|
||||||
|
[[ -s ~/.zen/tmp/$IPFSNODEID/$YID.TW.json ]] && echo "Tiddler json already existing : ~/.zen/tmp/$IPFSNODEID/$YID.TW.json" && continue ## TODO :: CHECK IF ALREADY YOURS OR NOT :: THEN ADD2TW / SEND MESSAGE ?
|
||||||
|
|
||||||
# SINGLE VIDEO YURL
|
# SINGLE VIDEO YURL
|
||||||
ZYURL="https://www.youtube.com/watch?v=$YID";
|
ZYURL=$(echo "$LINE" | cut -d '&' -f 3-)
|
||||||
echo "YOUTUBE : $ZYURL"
|
echo "COPIE : $ZYURL"
|
||||||
|
|
||||||
TITLE="$(yt-dlp --print "%(title)s" "${ZYURL}")"
|
TITLE="$(yt-dlp --print "%(title)s" "${ZYURL}")"
|
||||||
TITLE=${TITLE//[^A-zÀ-ÿ0-9 ]/}
|
TITLE=${TITLE//[^A-zÀ-ÿ0-9 ]/}
|
||||||
[[ ! $TITLE ]] && continue
|
[[ ! $TITLE ]] && echo "NO TITLE" && continue
|
||||||
|
|
||||||
echo ".... Downloading $TITLE.mp4"
|
echo ".... Downloading $TITLE.mp4"
|
||||||
|
|
||||||
|
@ -80,14 +107,18 @@ while read YID;
|
||||||
# SUBS ? --write-subs --write-auto-subs --sub-langs "fr, en, en-orig" --embed-subs
|
# SUBS ? --write-subs --write-auto-subs --sub-langs "fr, en, en-orig" --embed-subs
|
||||||
# (bv*[height<=720][vcodec~='^((he|a)vc|h26[45])']+ba)
|
# (bv*[height<=720][vcodec~='^((he|a)vc|h26[45])']+ba)
|
||||||
# TODO : DELAY COPY OPERATION... Astro can download quicker at 03:00 AM
|
# TODO : DELAY COPY OPERATION... Astro can download quicker at 03:00 AM
|
||||||
echo "yt-dlp -f \"(bv*[ext=mp4][height<=720]+ba/b[height<=720])\" --no-mtime --embed-thumbnail --add-metadata -o \"$HOME/.zen/tmp/$WISHKEY/$TITLE.%(ext)s\" ${ZYURL}"
|
echo "yt-dlp -f \"(bv*[ext=mp4][height<=720]+ba/b[height<=720])\" --no-mtime --embed-thumbnail --add-metadata -o \"$HOME/.zen/tmp/yt-dlp/$TITLE.%(ext)s\" ${ZYURL}"
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
## COPY FROM YOUTUBE (TODO DOUBLE COPY & MKV to MP4 OPTIMISATION)
|
## COPY FROM YOUTUBE (TODO DOUBLE COPY & MKV to MP4 OPTIMISATION)
|
||||||
|
## EXTRA PARAM TO TRY
|
||||||
|
# --cookies-from-browser browser (xdg-settings get default-web-browser) allow member copies
|
||||||
|
# --dateafter DATE --download-archive myarchive.txt
|
||||||
yt-dlp -f "(bv*[ext=mp4][height<=720]+ba/b[height<=720])" \
|
yt-dlp -f "(bv*[ext=mp4][height<=720]+ba/b[height<=720])" \
|
||||||
|
--download-archive $HOME/.zen/.yt-dlp.list \
|
||||||
-S "filesize:700M" --no-mtime --embed-thumbnail --add-metadata \
|
-S "filesize:700M" --no-mtime --embed-thumbnail --add-metadata \
|
||||||
--write-subs --write-auto-subs --sub-langs "fr, en, en-orig" --embed-subs \
|
--write-subs --write-auto-subs --sub-langs "fr, en, en-orig" --embed-subs \
|
||||||
-o "$HOME/.zen/tmp/$WISHKEY/$TITLE.%(ext)s" ${ZYURL}
|
-o "$HOME/.zen/tmp/yt-dlp/$TITLE.%(ext)s" ${ZYURL}
|
||||||
################################################################################
|
################################################################################
|
||||||
### ADAPT TO TW RYTHM (DELAY COPY?)
|
### ADAPT TO TW RYTHM (DELAY COPY?)
|
||||||
echo
|
echo
|
||||||
|
@ -96,21 +127,21 @@ while read YID;
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
### CHECK RESULT CONVERT MKV TO MP4
|
### CHECK RESULT CONVERT MKV TO MP4
|
||||||
[[ ! -f "$HOME/.zen/tmp/$WISHKEY/$ZFILE" ]] && ffmpeg -loglevel quiet -i "$HOME/.zen/tmp/$WISHKEY/$TITLE.mkv" -c:v libx264 -c:a aac "$HOME/.zen/tmp/$WISHKEY/$TITLE.mp4" # TRY TO CONVERT MKV TO MP4
|
[[ ! -f "$HOME/.zen/tmp/yt-dlp/$ZFILE" ]] && ffmpeg -loglevel quiet -i "$HOME/.zen/tmp/yt-dlp/$TITLE.mkv" -c:v libx264 -c:a aac "$HOME/.zen/tmp/yt-dlp/$TITLE.mp4" # TRY TO CONVERT MKV TO MP4
|
||||||
[[ ! -f "$HOME/.zen/tmp/$WISHKEY/$ZFILE" ]] && echo "No FILE -- CONTINUE --" && continue
|
[[ ! -f "$HOME/.zen/tmp/yt-dlp/$ZFILE" ]] && echo "No FILE -- CONTINUE --" && continue
|
||||||
echo
|
echo
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
echo "FOUND : ~/.zen/tmp/$WISHKEY/$ZFILE"
|
echo "FOUND : ~/.zen/tmp/yt-dlp/$ZFILE"
|
||||||
FILE_BSIZE=$(du -b "$HOME/.zen/tmp/$WISHKEY/$ZFILE" | awk '{print $1}')
|
FILE_BSIZE=$(du -b "$HOME/.zen/tmp/yt-dlp/$ZFILE" | awk '{print $1}')
|
||||||
FILE_SIZE=$(echo "${FILE_BSIZE}" | awk '{ split( "B KB MB GB TB PB" , v ); s=1; while( $1>1024 ){ $1/=1024; s++ } printf "%.2f %s", $1, v[s] }')
|
FILE_SIZE=$(echo "${FILE_BSIZE}" | awk '{ split( "B KB MB GB TB PB" , v ); s=1; while( $1>1024 ){ $1/=1024; s++ } printf "%.2f %s", $1, v[s] }')
|
||||||
echo "FILE SIZE = $FILE_SIZE ($FILE_BSIZE octets)"
|
echo "FILE SIZE = $FILE_SIZE ($FILE_BSIZE octets)"
|
||||||
|
|
||||||
echo "Adding to IPFS"
|
echo "Adding to IPFS"
|
||||||
ILINK=$(ipfs add -q "$HOME/.zen/tmp/$WISHKEY/$ZFILE" | tail -n 1)
|
ILINK=$(ipfs add -q "$HOME/.zen/tmp/yt-dlp/$ZFILE" | tail -n 1)
|
||||||
echo "/ipfs/$ILINK <=> $ZFILE"
|
echo "/ipfs/$ILINK <=> $ZFILE"
|
||||||
|
|
||||||
MIME=$(file --mime-type -b "$HOME/.zen/tmp/$WISHKEY/$ZFILE")
|
MIME=$(file --mime-type -b "$HOME/.zen/tmp/yt-dlp/$ZFILE")
|
||||||
|
|
||||||
## ADD TAGS
|
## ADD TAGS
|
||||||
SEC=$(yt-dlp --print "%(duration)s" "${ZYURL}")
|
SEC=$(yt-dlp --print "%(duration)s" "${ZYURL}")
|
||||||
|
@ -138,7 +169,7 @@ while read YID;
|
||||||
"tags": "'ipfs G1CopierYoutube ${WISHKEY} ${EXTRATAG} ${MIME}'"
|
"tags": "'ipfs G1CopierYoutube ${WISHKEY} ${EXTRATAG} ${MIME}'"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
' > "$HOME/.zen/tmp/$WISHKEY/$YID.TW.json"
|
' > "$HOME/.zen/tmp/$IPFSNODEID/$YID.TW.json"
|
||||||
|
|
||||||
|
|
||||||
#################################################################
|
#################################################################
|
||||||
|
@ -147,22 +178,23 @@ while read YID;
|
||||||
echo "=========================="
|
echo "=========================="
|
||||||
echo "Adding $YID tiddler to TW /ipns/$TWNS "
|
echo "Adding $YID tiddler to TW /ipns/$TWNS "
|
||||||
|
|
||||||
rm -f ~/.zen/tmp/$WISHKEY/newindex.html
|
rm -f ~/.zen/tmp/$IPFSNODEID/newindex.html
|
||||||
|
|
||||||
echo ">>> Importing $HOME/.zen/tmp/$WISHKEY/$YID.TW.json"
|
echo ">>> Importing $HOME/.zen/tmp/$IPFSNODEID/$YID.TW.json"
|
||||||
|
|
||||||
tiddlywiki --load $INDEX \
|
tiddlywiki --load $INDEX \
|
||||||
--import "$HOME/.zen/tmp/$WISHKEY/$YID.TW.json" "application/json" \
|
--import "$HOME/.zen/tmp/$IPFSNODEID/$YID.TW.json" "application/json" \
|
||||||
--deletetiddlers '[tag[CopierYoutube]]' \
|
--output ~/.zen/tmp/$IPFSNODEID --render "$:/core/save/all" "newindex.html" "text/plain"
|
||||||
--output ~/.zen/tmp/$WISHKEY --render "$:/core/save/all" "newindex.html" "text/plain"
|
|
||||||
|
|
||||||
if [[ -s ~/.zen/tmp/$WISHKEY/newindex.html ]]; then
|
# --deletetiddlers '[tag[CopierYoutube]]' ### REFRESH CHANNEL COPY
|
||||||
|
|
||||||
|
if [[ -s ~/.zen/tmp/$IPFSNODEID/newindex.html ]]; then
|
||||||
echo "$$$ Mise à jour $INDEX"
|
echo "$$$ Mise à jour $INDEX"
|
||||||
cp ~/.zen/tmp/$WISHKEY/newindex.html $INDEX
|
cp ~/.zen/tmp/$IPFSNODEID/newindex.html $INDEX
|
||||||
else
|
else
|
||||||
echo "Problem with tiddlywiki command. Missing ~/.zen/tmp/$WISHKEY/newindex.html"
|
echo "Problem with tiddlywiki command. Missing ~/.zen/tmp/$IPFSNODEID/newindex.html"
|
||||||
echo "XXXXXXXXXXXXXXXXXXXXXXX"
|
echo "XXXXXXXXXXXXXXXXXXXXXXX"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done < ~/.zen/tmp/$WISHKEY/ytids.$MOATS # FINISH YID loop 1
|
done < ~/.zen/tmp/$IPFSNODEID/yt-dlp.cache.$WISHKEY # FINISH YID loop 1
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -77,7 +77,7 @@ while true; do
|
||||||
ls ~/.zen/tmp/swarm
|
ls ~/.zen/tmp/swarm
|
||||||
BSIZE=$(du -b ~/.zen/tmp/swarm | tail -n 1 | cut -f 1)
|
BSIZE=$(du -b ~/.zen/tmp/swarm | tail -n 1 | cut -f 1)
|
||||||
|
|
||||||
## SIZE MODIFIED
|
## SIZE MODIFIED => PUBLISH MySwarm_$IPFSNODEID
|
||||||
[[ $BSIZE != $(cat ~/.zen/tmp/swarm/.bsize) ]] \
|
[[ $BSIZE != $(cat ~/.zen/tmp/swarm/.bsize) ]] \
|
||||||
&& echo $BSIZE > ~/.zen/tmp/swarm/.bsize \
|
&& echo $BSIZE > ~/.zen/tmp/swarm/.bsize \
|
||||||
&& SWARMH=$(ipfs add -rwq ~/.zen/tmp/swarm/* | tail -n 1 ) \
|
&& SWARMH=$(ipfs add -rwq ~/.zen/tmp/swarm/* | tail -n 1 ) \
|
||||||
|
@ -85,7 +85,7 @@ while true; do
|
||||||
|
|
||||||
|
|
||||||
############# PUBLISH IPFSNODEID BALISE
|
############# PUBLISH IPFSNODEID BALISE
|
||||||
# Clean Empty
|
# Clean Empty Directory (inode dependancy BUG ??)
|
||||||
du -b ~/.zen/tmp/${IPFSNODEID} > /tmp/du
|
du -b ~/.zen/tmp/${IPFSNODEID} > /tmp/du
|
||||||
while read branch; do [[ $branch =~ "4096" ]] && rmdir $(echo $branch | cut -f 2 -d ' '); done < /tmp/du
|
while read branch; do [[ $branch =~ "4096" ]] && rmdir $(echo $branch | cut -f 2 -d ' '); done < /tmp/du
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@ log() {
|
||||||
}
|
}
|
||||||
|
|
||||||
zen() {
|
zen() {
|
||||||
rm -rf /home/zen/.zen/tmp \
|
mkdir -p /dev/shm/tmp \
|
||||||
&& mkdir -p /dev/shm/tmp \
|
&& rm -rf /home/zen/.zen/tmp \
|
||||||
&& ln -s /dev/shm/tmp /home/zen/.zen/tmp
|
&& ln -s /dev/shm/tmp /home/zen/.zen/tmp
|
||||||
[ -d "$ASTROPORT_DIR" ] && cd "$ASTROPORT_DIR" && git pull -q || git clone -q "$ASTROPORT_REPO" "$ASTROPORT_DIR"
|
[ -d "$ASTROPORT_DIR" ] && cd "$ASTROPORT_DIR" && git pull -q || git clone -q "$ASTROPORT_REPO" "$ASTROPORT_DIR"
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,6 +231,8 @@ echo "$USER ALL=(ALL) NOPASSWD:/usr/bin/apt-get" | (sudo su -c 'EDITOR="tee" vis
|
||||||
echo "$USER ALL=(ALL) NOPASSWD:/usr/bin/apt" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/apt')
|
echo "$USER ALL=(ALL) NOPASSWD:/usr/bin/apt" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/apt')
|
||||||
## USED FOR "systemctl restart ipfs"
|
## USED FOR "systemctl restart ipfs"
|
||||||
echo "$USER ALL=(ALL) NOPASSWD:/bin/systemctl" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/systemctl')
|
echo "$USER ALL=(ALL) NOPASSWD:/bin/systemctl" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/systemctl')
|
||||||
|
## USED FOR "systemctl restart ipfs"
|
||||||
|
echo "$USER ALL=(ALL) NOPASSWD:/usr/local/bin/youtube-dl" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/youtube-dl')
|
||||||
|
|
||||||
## brother_ql_print
|
## brother_ql_print
|
||||||
echo "$USER ALL=(ALL) NOPASSWD:/usr/local/bin/brother_ql_print" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/brother_ql_print')
|
echo "$USER ALL=(ALL) NOPASSWD:/usr/local/bin/brother_ql_print" | (sudo su -c 'EDITOR="tee" visudo -f /etc/sudoers.d/brother_ql_print')
|
||||||
|
|
|
@ -84,7 +84,7 @@ echo "Getting received stars"
|
||||||
-k ~/.zen/game/players/${PLAYER}/secret.dunikey \
|
-k ~/.zen/game/players/${PLAYER}/secret.dunikey \
|
||||||
-n "https://data.gchange.fr" stars > ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/received_stars.json
|
-n "https://data.gchange.fr" stars > ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/received_stars.json
|
||||||
|
|
||||||
cat ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/received_stars.json | jq -r '.likes[].issuer' | uniq > ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/liking_me
|
cat ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/received_stars.json | jq -r '.likes[].issuer' | sort | uniq > ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/liking_me
|
||||||
echo "cat ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/received_stars.json | jq -r"
|
echo "cat ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/received_stars.json | jq -r"
|
||||||
|
|
||||||
for liking_me in $(cat ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/liking_me | sort | uniq);
|
for liking_me in $(cat ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/liking_me | sort | uniq);
|
||||||
|
@ -97,14 +97,13 @@ do
|
||||||
echo "TW ? http://tube.copylaradio.com:8080/ipns/$ASTRONAUTENS "
|
echo "TW ? http://tube.copylaradio.com:8080/ipns/$ASTRONAUTENS "
|
||||||
|
|
||||||
##### CHECKING IF WE LIKE EACH OTHER Ŋ1 LEVEL
|
##### CHECKING IF WE LIKE EACH OTHER Ŋ1 LEVEL
|
||||||
|
echo "Receiving Stars : cat ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/${liking_me}.Gstars.json | jq -r"
|
||||||
################################## JAKLIS LIKING_ME stars
|
################################## JAKLIS LIKING_ME stars
|
||||||
~/.zen/Astroport.ONE/tools/timeout.sh -t 20 \
|
~/.zen/Astroport.ONE/tools/timeout.sh -t 20 \
|
||||||
~/.zen/Astroport.ONE/tools/jaklis/jaklis.py \
|
~/.zen/Astroport.ONE/tools/jaklis/jaklis.py \
|
||||||
-k ~/.zen/game/players/${PLAYER}/secret.dunikey \
|
-k ~/.zen/game/players/${PLAYER}/secret.dunikey \
|
||||||
-n "https://data.gchange.fr" \
|
-n "https://data.gchange.fr" \
|
||||||
stars -p ${liking_me} > ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/${liking_me}.Gstars.json
|
stars -p ${liking_me} > ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/${liking_me}.Gstars.json
|
||||||
|
|
||||||
echo "Got Stars - DEBUG - cat ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/${liking_me}.Gstars.json | jq -r"
|
|
||||||
## ZOMBIE PROTECTION
|
## ZOMBIE PROTECTION
|
||||||
[[ "$?" == "0" && ! -s ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/${liking_me}.Gstars.json ]] && rm -Rf ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me} && echo "${liking_me} is a ZOMBIE..." && continue
|
[[ "$?" == "0" && ! -s ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/${liking_me}.Gstars.json ]] && rm -Rf ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me} && echo "${liking_me} is a ZOMBIE..." && continue
|
||||||
|
|
||||||
|
@ -127,8 +126,15 @@ do
|
||||||
cp ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/${liking_me}.Gstars.json ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/ && rm -f ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/${liking_me}.Gstars.json
|
cp ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/${liking_me}.Gstars.json ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/ && rm -f ~/.zen/tmp/${IPFSNODEID}/${PLAYER}/${liking_me}.Gstars.json
|
||||||
echo "$my_star_level" > ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/stars.level && echo "***** $my_star_level STARS *****"
|
echo "$my_star_level" > ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/stars.level && echo "***** $my_star_level STARS *****"
|
||||||
|
|
||||||
|
## GET FRIEND GCHANGE PROFILE
|
||||||
|
${MY_PATH}/timeout.sh -t 20 \
|
||||||
|
${MY_PATH}/jaklis/jaklis.py get \
|
||||||
|
-p ${liking_me} > ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/gchange.json
|
||||||
|
|
||||||
|
FRIENDTITLE=$(cat ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/gchange.json | jq -r '.title')
|
||||||
|
|
||||||
## GET FRIEND TW !!
|
## GET FRIEND TW !!
|
||||||
echo "Getting latest online TW..."
|
echo "Getting $FRIENDTITLE latest online TW..."
|
||||||
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);
|
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)
|
LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 2)
|
||||||
echo "$LIBRA/ipns/$ASTRONAUTENS"
|
echo "$LIBRA/ipns/$ASTRONAUTENS"
|
||||||
|
@ -139,18 +145,14 @@ do
|
||||||
## PLAYER TW EXISTING ?
|
## PLAYER TW EXISTING ?
|
||||||
if [ ! -s ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/index.html ]; then
|
if [ ! -s ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/index.html ]; then
|
||||||
|
|
||||||
# # # # # # # # # # # # # # #
|
|
||||||
## AUCUN VISA ASTRONAUTE ENVOYER UN MESSAGE PAR GCHANGE
|
## AUCUN VISA ASTRONAUTE ENVOYER UN MESSAGE PAR GCHANGE
|
||||||
echo "AUCUN TW ACTIF. ENVOYONS LUI UN MESSAGE..."
|
echo "AUCUN TW ACTIF. ENVOYONS LUI UN MESSAGE..."
|
||||||
$MY_PATH/jaklis/jaklis.py -k ~/.zen/game/players/${PLAYER}/secret.dunikey -n "https://data.gchange.fr" send -d "${liking_me}" -t "BRO !" -m ">>> (◕‿‿◕) <<< https://astroport.copylaradio.com >>> (◕‿‿◕) <<<"
|
$MY_PATH/jaklis/jaklis.py -k ~/.zen/game/players/${PLAYER}/secret.dunikey -n "https://data.gchange.fr" send -d "${liking_me}" -t "BRO !" -m ">>> (◕‿‿◕) <<< https://astroport.copylaradio.com >>> (◕‿‿◕) <<<"
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
echo "COOL MON AMI PUBLIE SUR IPFS"
|
echo "COOL MON AMI EST SUR IPFS"
|
||||||
ls -al ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/index.html
|
ls -al ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/index.html
|
||||||
# # # # # # # # # # # # # # # TODO
|
|
||||||
# CHECK Dessin de Moa ?? (DIS)CONNECT PLAYERS
|
|
||||||
# # # # # # # # # # # # # # #
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -158,15 +160,14 @@ do
|
||||||
# SCRAPING DONNE LE BON COIN
|
# SCRAPING DONNE LE BON COIN
|
||||||
# https://www.leboncoin.fr/recherche?text=donne&locations=Toulouse__43.59743304757555_1.4471155185604894_10000_5000&owner_type=private&sort=time&donation=1
|
# https://www.leboncoin.fr/recherche?text=donne&locations=Toulouse__43.59743304757555_1.4471155185604894_10000_5000&owner_type=private&sort=time&donation=1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Get Ŋ2 LEVEL
|
## Get Ŋ2 LEVEL
|
||||||
echo "(°▃▃°) (°▃▃°) (°▃▃°) Ŋ2 scraping ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/friend_of_friend.json"
|
echo "(°▃▃°) (°▃▃°) (°▃▃°) Ŋ2 scraping ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/friend_of_friend.json"
|
||||||
for nid in $(cat ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/${liking_me}.Gstars.json | jq -r '.likes[].issuer');
|
for nid in $(cat ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/${liking_me}.Gstars.json | jq -r '.likes[].issuer');
|
||||||
do
|
do
|
||||||
|
|
||||||
echo "Ami(s) de cet Ami $linking_me : $nid"
|
echo "Ami(s) de cet Ami $linking_me : $nid"
|
||||||
friend_of_friend=$(cat ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/${liking_me}.Gstars.json | jq -r '.likes[] | select(.issuer | strings | test("'$nid'"))')
|
friend_of_friend=$(cat ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/${liking_me}.Gstars.json | jq -r '.likes[] | select(.issuer | strings | test("'$nid'"))')
|
||||||
echo "$friend_of_friend" | jq -r > ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/friend_of_friend.json
|
echo "$friend_of_friend" | jq -r > ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/FoF_$nid.json
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
#!/bin/bash
|
||||||
|
################################################################################
|
||||||
|
# Author: Fred (support@qo-op.com)
|
||||||
|
# Version: 0.2
|
||||||
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
||||||
|
################################################################################
|
||||||
|
# Activate SUPPORT MODE: open ssh over IPFS
|
||||||
|
MY_PATH="`dirname \"$0\"`" # relative
|
||||||
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
||||||
|
########################################################################
|
||||||
|
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) || er+=" ipfs daemon not running"
|
||||||
|
IPFSNODEID=$(cat ~/.ipfs/config | jq -r .Identity.PeerID) || er+=" ipfs id problem"
|
||||||
|
[[ "$YOU" == "" || "$IPFSNODEID" == "" ]] && echo "ERROR : $er " && exit 1
|
||||||
|
########################################################################
|
||||||
|
|
||||||
|
# Make Station publish SSH port on "/x/ssh-$(hostname)"
|
||||||
|
zuid="$(hostname)"
|
||||||
|
if [[ $zuid ]]
|
||||||
|
then
|
||||||
|
if [[ ! $(cat ~/.ssh/authorized_keys | grep "fred@ONELOVE") ]]
|
||||||
|
then
|
||||||
|
echo "# ADD fred@ONELOVE to ~/.ssh/authorized_keys"
|
||||||
|
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFLHW8P88C/B7622yXzdAn1ZcTBfE1A4wMqajBwAoHwUVTOUaYfvkiSxbzb5H9dPTAXhQU6ZfuLa70kTo1m2b9TKH0tD6hR3RiKJ0NIjCHYEypcPGpLmHaZWnBKPq3IUU24qFVdUJxnTkDdFUszYMNoV4nqlXY/ZYdNpic8L1jPPyfOLLfPFkuSxagyQj4FGJq77UQE5j+skMJS3ISkazNTLqOCGLFJ5qtBC11BvQaCJ4cQ2Ss7ejPYhpx16NLJfg9VtG4dv9ZebEIl2pf7niiQGSPrDMFWHuQcGAuHt/patr0BcvfvD3Gv+qNsVfAJCNZ2U5NHEMKIhgj1ilNPEw7 fred@ONELOVE" >> ~/.ssh/authorized_keys
|
||||||
|
fi
|
||||||
|
echo "Lanching /x/ssh-$zuid"
|
||||||
|
[[ ! $(ipfs p2p ls | grep "/x/ssh-$zuid") ]] && ipfs p2p listen /x/ssh-$zuid /ip4/127.0.0.1/tcp/22
|
||||||
|
# echo "echo \"ssh-$zuid local port please?\"; read lport; ipfs p2p forward /x/ssh-$zuid /ip4/127.0.0.1/tcp/$lport /p2p/$IPFSNODEID" >> ~/.zen/tmp/$IPFSNODEID/astroport/port
|
||||||
|
fi
|
||||||
|
|
||||||
|
ipfs p2p ls
|
||||||
|
|
||||||
|
## CONNECT WITH COMMAND
|
||||||
|
## ipfs cat /ipns/$IPFSNODEID/.$IPFSNODEID/x_ssh-$zuid.sh | bash
|
||||||
|
rm ~/.zen/tmp/$IPFSNODEID/x_ssh-$zuid.sh >/dev/null 2>&1
|
||||||
|
if [[ ! -f ~/.zen/tmp/$IPFSNODEID/x_ssh-$zuid.sh ]]; then
|
||||||
|
PORT=12345
|
||||||
|
[ ${PORT} -eq 12345 ] && PORT=$((PORT+${RANDOM:0:3})) || PORT=$((PORT-${RANDOM:0:3}))
|
||||||
|
echo "[[ ! \$(ipfs p2p ls | grep x/ssh-$zuid) ]] && ipfs --timeout=5s ping -n 1 /p2p/$IPFSNODEID && ipfs p2p forward /x/ssh-$zuid /ip4/127.0.0.1/tcp/$PORT /p2p/$IPFSNODEID && ssh $USER@127.0.0.1 -p $PORT" > ~/.zen/tmp/$IPFSNODEID/x_ssh-$zuid.sh
|
||||||
|
fi
|
||||||
|
cat ~/.zen/tmp/$IPFSNODEID/x_ssh-$zuid.sh
|
||||||
|
|
||||||
|
## THIS PORT FORWARDING HUB COULD BE MADE MORE CONTROLABLE USING FRIENDSHIP LEVEL & IPFS BALISES
|
||||||
|
|
|
@ -25,8 +25,8 @@ messfile="$2" # FICHIER A AJOUTER AU CORPS MESSAGE
|
||||||
|
|
||||||
[[ ! $1 ]] && mail="support@qo-op.com"
|
[[ ! $1 ]] && mail="support@qo-op.com"
|
||||||
|
|
||||||
SUBJECT="[(♥‿‿♥)] Astronaute. Message Station Astroport.ONE"
|
SUBJECT="[(♥‿‿♥)] Message Station Astroport : $(hostname)"
|
||||||
MESSAGE="( ◕‿◕)\n\n Bonjour $PLAYER\n\n\n Activez votre TW https://astroport.copylaradio.com .\n\nAstroport\n$IPFSNODEID"
|
MESSAGE="( ◕‿◕)\n\n Bonjour $PLAYER\n\n\n Activez votre TW https://astroport.copylaradio.com .\n\nAstroport\n($IPFSNODEID)"
|
||||||
|
|
||||||
echo "From: support@g1sms.fr
|
echo "From: support@g1sms.fr
|
||||||
To: EMAIL
|
To: EMAIL
|
||||||
|
|
|
@ -98,7 +98,7 @@ PLAYER=$(cat ~/.zen/game/players/.current/.player 2>/dev/null);
|
||||||
|
|
||||||
# NOT CURRENT PLAYER (CHECK FOR TW & KEY
|
# NOT CURRENT PLAYER (CHECK FOR TW & KEY
|
||||||
[[ $G1PUB != $(cat ~/.zen/game/players/.current/.g1pub 2>/dev/null) ]] \
|
[[ $G1PUB != $(cat ~/.zen/game/players/.current/.g1pub 2>/dev/null) ]] \
|
||||||
&& [[ $(ipfs key list -l | grep -v $G1PUB) ]] \
|
&& [[ $(ipfs key list -l | grep -w $G1PUB) ]] \
|
||||||
&& echo "(ᵔ◡◡ᵔ) INVITATION $G1PUB" \
|
&& echo "(ᵔ◡◡ᵔ) INVITATION $G1PUB" \
|
||||||
&& ASTRONS=$($MY_PATH/tools/g1_to_ipfs.py "$G1PUB") \
|
&& ASTRONS=$($MY_PATH/tools/g1_to_ipfs.py "$G1PUB") \
|
||||||
&& $MY_PATH/tools/TW.cache.sh $ASTRONS $MOATS \
|
&& $MY_PATH/tools/TW.cache.sh $ASTRONS $MOATS \
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
export {b58,b16, saltPass2seed, seed2keyPair,idSecPass2rawAll, raw2b58, idSecPass2cleanKeys}
|
||||||
|
import {nacl} from "./vendors/nacl.js";
|
||||||
|
|
||||||
|
async function idSecPass2rawAll(idSec,pass) {
|
||||||
|
const rawSeed = await saltPass2seed(idSec,pass);
|
||||||
|
const keyPair = seed2keyPair(rawSeed);
|
||||||
|
return {
|
||||||
|
seed:rawSeed,
|
||||||
|
publicKey:keyPair.publicKey,
|
||||||
|
secretKey:keyPair.secretKey
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function raw2b58(raws){
|
||||||
|
const res = {};
|
||||||
|
for(let r in raws) res[r] = b58.encode(raws[r]);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
async function idSecPass2cleanKeys(idSec,pass){
|
||||||
|
const raw = await idSecPass2rawAll(idSec,pass);
|
||||||
|
return Object.assign(raw2b58(raw),{idSec,password:pass});
|
||||||
|
}
|
||||||
|
function seed2keyPair(seed){
|
||||||
|
return nacl.sign.keyPair.fromSeed(seed);
|
||||||
|
}
|
||||||
|
import scrypt from "./vendors/scrypt.js";
|
||||||
|
async function saltPass2seed(idSec,pass) {
|
||||||
|
const options = {
|
||||||
|
logN: 12,
|
||||||
|
r: 16,
|
||||||
|
p: 1,
|
||||||
|
//dkLen: 32,
|
||||||
|
encoding: 'binary'
|
||||||
|
};
|
||||||
|
return await scrypt(pass.normalize('NFKC'), idSec.normalize('NFKC'), options);
|
||||||
|
}
|
||||||
|
//inspired by bs58 and base-x module
|
||||||
|
const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
||||||
|
const b58 = basex(ALPHABET);
|
||||||
|
const b16 = basex('0123456789abcdef');
|
||||||
|
function basex (ALPHABET) {
|
||||||
|
const ALPHABET_MAP = {};
|
||||||
|
const BASE = ALPHABET.length;
|
||||||
|
const LEADER = ALPHABET.charAt(0);
|
||||||
|
// pre-compute lookup table
|
||||||
|
for (let z = 0; z < ALPHABET.length; z++) {
|
||||||
|
let x = ALPHABET.charAt(z);
|
||||||
|
if (ALPHABET_MAP[x] !== undefined) throw new TypeError(x + ' is ambiguous');
|
||||||
|
ALPHABET_MAP[x] = z;
|
||||||
|
}
|
||||||
|
function encode (source) {
|
||||||
|
if (source.length === 0) return '';
|
||||||
|
const digits = [0];
|
||||||
|
for (let i = 0; i < source.length; ++i) {
|
||||||
|
let carry = source[i];
|
||||||
|
for (let j = 0; j < digits.length; ++j) {
|
||||||
|
carry += digits[j] << 8;
|
||||||
|
digits[j] = carry % BASE;
|
||||||
|
carry = (carry / BASE) | 0;
|
||||||
|
}
|
||||||
|
while (carry > 0) { digits.push(carry % BASE); carry = (carry / BASE) | 0; }
|
||||||
|
}
|
||||||
|
let string = '';
|
||||||
|
for (let k = 0; source[k] === 0 && k < source.length - 1; ++k) string += LEADER; // deal with leading zeros
|
||||||
|
for (let q = digits.length - 1; q >= 0; --q) string += ALPHABET[digits[q]]; // convert digits to a string
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function decodeUnsafe (string) {
|
||||||
|
if (typeof string !== 'string') throw new TypeError('Expected String');
|
||||||
|
if (string.length === 0) return new Uint8Array(0);
|
||||||
|
const bytes = [0];
|
||||||
|
for (let i = 0; i < string.length; i++) {
|
||||||
|
const value = ALPHABET_MAP[string[i]];
|
||||||
|
if (value === undefined) return ;
|
||||||
|
let carry = value;
|
||||||
|
for (let j = 0; j < bytes.length; ++j) {
|
||||||
|
carry += bytes[j] * BASE;
|
||||||
|
bytes[j] = carry & 0xff;
|
||||||
|
carry >>= 8;
|
||||||
|
}
|
||||||
|
while (carry > 0) { bytes.push(carry & 0xff); carry >>= 8; }
|
||||||
|
}
|
||||||
|
for (let k = 0; string[k] === LEADER && k < string.length - 1; ++k) bytes.push(0); // deal with leading zeros
|
||||||
|
return new Uint8Array(bytes.reverse());
|
||||||
|
}
|
||||||
|
function decode (string) {
|
||||||
|
const buffer = decodeUnsafe(string);
|
||||||
|
if (buffer) return buffer;
|
||||||
|
throw new Error('Non-base' + BASE + ' character')
|
||||||
|
}
|
||||||
|
return { encode, decodeUnsafe, decode }
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,70 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<title>idSec+password or seed or keys => file.dunikey</title>
|
||||||
|
<link rel="icon" type="image/png" sizes="16x16" href="img/favicon.png">
|
||||||
|
<link rel="canonical" href="https://gsper.duniter.io/dunikey.html"/>
|
||||||
|
|
||||||
|
<meta property="og:type" content="website" />
|
||||||
|
<meta property="og:locale" content="fr_FR" />
|
||||||
|
<meta property="og:title" content="idSec+password or seed or keys => file.dunikey" />
|
||||||
|
<meta property="og:site_name" content="gsper.duniter.io" />
|
||||||
|
<meta property="og:url" content="https://gsper.duniter.io/dunikey.html" />
|
||||||
|
<meta property="og:image" content="https://gsper.duniter.io/img/gsper-logo.png" />
|
||||||
|
<meta property="og:description" content="Converti vos secrets d'authentification pour générer un fichier d'authentification file.dunikey" />
|
||||||
|
<style>
|
||||||
|
* {font-family: sans-serif; box-sizing: border-box; margin: 0; padding: 0}
|
||||||
|
h1{font-weight: normal; width: 100%; text-align: center; line-height: 70px;}
|
||||||
|
fieldset {margin: 10px;}
|
||||||
|
.logic {margin-left: 50px;}
|
||||||
|
input{border: 0; padding: 5px;width: 100%; line-height: 60px; font-size: 16px;}
|
||||||
|
button {width: 100%; height: 32px}
|
||||||
|
.gift {position: absolute; top: 10px; left: 10px;}
|
||||||
|
.gift a{text-decoration-color: rgba(0%,0%,100%,0.2); color: rgba(0%,0%,100%,0.7);}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>DunikeyMaker</h1>
|
||||||
|
<fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<input id="idSec" type="password" placeholder="Identifiant secret"/>
|
||||||
|
<input id="pass" type="password" placeholder="Mot de passe"/>
|
||||||
|
</fieldset>
|
||||||
|
<div class="logic">ou</div>
|
||||||
|
<fieldset>
|
||||||
|
<input id="seed" type="text" placeholder="Seed"/>
|
||||||
|
</fieldset>
|
||||||
|
<div class="logic">ou</div>
|
||||||
|
<fieldset>
|
||||||
|
<input id="secretkey" type="text" placeholder="Clef privée (ou secrète)"/>
|
||||||
|
<input id="pubkey" type="text" placeholder="Clef publique"/>
|
||||||
|
</fieldset>
|
||||||
|
</fieldset>
|
||||||
|
<div class="logic">et</div>
|
||||||
|
<fieldset>
|
||||||
|
<input id="filename" type="text" placeholder="Nom du fichier à générer"/>
|
||||||
|
<button id="compute">Générer le fichier .dunikey.yml</button>
|
||||||
|
</fieldset>
|
||||||
|
<div class="gift">
|
||||||
|
<a href="https://cesium.g1.1000i100.fr/#/app/wot/2sZF6j2PkxBDNAqUde7Dgo5x3crkerZpQ4rBqqJGn8QT/1000i100" target="_blank">Ǧ'spère vous avoir été utile.<br/>
|
||||||
|
Soutenez mon travail avec un don !<br/>
|
||||||
|
👤 : 1000i100 🔑 : 2sZF6j2P
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<footer>
|
||||||
|
<a href="https://git.duniter.org/tools/gsper" id="sourceRibbon" title="Fork me !">
|
||||||
|
<span>AGPL-3.0</span>
|
||||||
|
<span>Logiciel Libre</span>
|
||||||
|
<span>Remonter aux sources</span>
|
||||||
|
<style>
|
||||||
|
#sourceRibbon {position: fixed; top: 15px; right: -110px; z-index: 500; transform: rotate(45deg); text-align: center;width: 300px; box-shadow: 0 0 5px #000; text-decoration: none;}
|
||||||
|
#sourceRibbon span {background-color: #0A0; color: white; font-family: sans-serif; display: block; padding: 1px 30px; font-size: 9pt; margin: -1px; text-shadow: 0 0 3px rgba(0,0,0,.5);}
|
||||||
|
#sourceRibbon span + span {background-color: #06A; font-size: 11pt;}
|
||||||
|
#sourceRibbon span + span + span {background-color: #E80; font-size: 10pt;}
|
||||||
|
</style>
|
||||||
|
</a>
|
||||||
|
</footer>
|
||||||
|
<script type="module" src="dunikey.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,54 @@
|
||||||
|
import * as dKey from "./crypto.js";
|
||||||
|
|
||||||
|
addEventsListeners([
|
||||||
|
document.getElementById("idSec"),
|
||||||
|
document.getElementById("pass"),
|
||||||
|
], "keyup change",
|
||||||
|
async function () {
|
||||||
|
const idSec = document.getElementById("idSec").value;
|
||||||
|
const pass = document.getElementById("pass").value;
|
||||||
|
const keys = await dKey.idSecPass2cleanKeys(idSec, pass);
|
||||||
|
document.getElementById("seed").value = keys.seed;
|
||||||
|
document.getElementById("secretkey").value = keys.secretKey;
|
||||||
|
document.getElementById("pubkey").value = keys.publicKey;
|
||||||
|
|
||||||
|
});
|
||||||
|
addEventsListeners([
|
||||||
|
document.getElementById("seed"),
|
||||||
|
], "keyup change",
|
||||||
|
async function () {
|
||||||
|
let rawSeed;
|
||||||
|
const seed = document.getElementById("seed").value;
|
||||||
|
console.log(seed.length);
|
||||||
|
if (seed.length === 64) rawSeed = dKey.b16.decode(seed);
|
||||||
|
else rawSeed = dKey.b58.decode(seed);
|
||||||
|
const keys = await dKey.seed2keyPair(rawSeed);
|
||||||
|
document.getElementById("secretkey").value = dKey.b58.encode(keys.secretKey);
|
||||||
|
document.getElementById("pubkey").value = dKey.b58.encode(keys.publicKey);
|
||||||
|
});
|
||||||
|
addEventsListeners([
|
||||||
|
document.getElementById("compute"),
|
||||||
|
], "click",
|
||||||
|
async function () {
|
||||||
|
const filename = document.getElementById("filename").value;
|
||||||
|
const secretkey = document.getElementById("secretkey").value;
|
||||||
|
const pubkey = document.getElementById("pubkey").value;
|
||||||
|
exportAsFile(filename, `pub: ${pubkey}\nsec: ${secretkey}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
function exportAsFile(fileName, data) {
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.setAttribute('download', fileName + '.dunikey.yml');
|
||||||
|
a.setAttribute('href', 'data:text/yaml;charset=utf-8,' + encodeURIComponent(data));
|
||||||
|
clickOn(a);
|
||||||
|
}
|
||||||
|
function clickOn(element) {
|
||||||
|
const event = new MouseEvent('click', {'view': window, 'bubbles': true, 'cancelable': true});
|
||||||
|
element.dispatchEvent(event);
|
||||||
|
}
|
||||||
|
function addEventsListeners(triggerNodes, events, functions) {
|
||||||
|
if (!triggerNodes.length) triggerNodes = [triggerNodes];
|
||||||
|
if (typeof events !== "object") events = events.split(" ");
|
||||||
|
if (typeof functions !== "object") functions = [functions];
|
||||||
|
for (let n of triggerNodes) events.forEach(e => functions.forEach(f => n.addEventListener(e, f)));
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
275
www/index.html
275
www/index.html
|
@ -1,275 +0,0 @@
|
||||||
<html class=" rrghhqet idc0_344 cadefrffwk ftnryedt"><head>
|
|
||||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
||||||
<title>Upload files to Astroport</title>
|
|
||||||
<style>
|
|
||||||
a, a:hover, a:visited, a:active {
|
|
||||||
color: #fff;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
border: 0;
|
|
||||||
margin: 0;
|
|
||||||
|
|
||||||
font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;
|
|
||||||
|
|
||||||
background-color: #041d2f;
|
|
||||||
color: #fff;
|
|
||||||
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
min-height: 100vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type=text] {
|
|
||||||
width: 500px;
|
|
||||||
height: 50px;
|
|
||||||
text-align: center;
|
|
||||||
margin: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type=file] {
|
|
||||||
width: 0.1px;
|
|
||||||
height: 0.1px;
|
|
||||||
opacity: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
position: absolute;
|
|
||||||
z-index: -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type=file] + label {
|
|
||||||
display: inline-block;
|
|
||||||
|
|
||||||
font-size: 1.25em;
|
|
||||||
font-weight: 700;
|
|
||||||
|
|
||||||
color: #333;
|
|
||||||
background-color: #fff;
|
|
||||||
border-radius: 5px;
|
|
||||||
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type=file]:focus + label,
|
|
||||||
input[type=file] + label:hover {
|
|
||||||
background-color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
label {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
button {
|
|
||||||
width: 500px;
|
|
||||||
height: 50px;
|
|
||||||
text-align: center;
|
|
||||||
margin: 5px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
|
||||||
flex: 1;
|
|
||||||
margin: 10px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.informations {
|
|
||||||
font-size: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.image {
|
|
||||||
display: block;
|
|
||||||
margin: 0 auto;
|
|
||||||
height: 300px;
|
|
||||||
margin-bottom: 40px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wrapWithDirectoryContainer {
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.footer {
|
|
||||||
text-align: center;
|
|
||||||
margin: 10px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<script src="ipfs.js"></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="content">
|
|
||||||
<img src="./logo-astroport.png" class="image">
|
|
||||||
|
|
||||||
<div id="informations" class="informations">
|
|
||||||
Téléverser un fichier vers Astroport
|
|
||||||
</div>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<form>
|
|
||||||
<input id="file" type="file">
|
|
||||||
<label for="file">Choose a file</label>
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
|
|
||||||
<div class="wrapWithDirectoryContainer">
|
|
||||||
<input id="wrapWithDirectory" type="checkbox">
|
|
||||||
<label for="wrapWithDirectory">Wrap with a directory (recommended)</label>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function cacheIt (appName, hash, nodeId = '') {
|
|
||||||
|
|
||||||
var gatewayProtocol = 'http';
|
|
||||||
|
|
||||||
var gatewayDomain = 'ipfs.localhost';
|
|
||||||
|
|
||||||
var gatewayPort = '1234';
|
|
||||||
|
|
||||||
var salt = 'totodu56';
|
|
||||||
var pepper = 'totodu56';
|
|
||||||
|
|
||||||
var query = 'salt='+ salt
|
|
||||||
query += '&pepper='+ pepper
|
|
||||||
query += '&' + appName
|
|
||||||
query += '&nodeid=' + nodeId
|
|
||||||
query += '&dataid=' + hash;
|
|
||||||
|
|
||||||
var fullURL = 'http://'+ gatewayDomain +':'+ gatewayPort + '/?' + query;
|
|
||||||
console.log(fullURL)
|
|
||||||
|
|
||||||
const controller = new AbortController()
|
|
||||||
const timeoutId = setTimeout( () => {
|
|
||||||
controller.abort()
|
|
||||||
}, 15000)
|
|
||||||
var fetchOpts = {
|
|
||||||
method: 'GET',
|
|
||||||
headers: {
|
|
||||||
'Accept': 'text/html'
|
|
||||||
// ,'Content-Type': 'text/html'
|
|
||||||
// // ,'Access-Control-Allow-Origin': '*',
|
|
||||||
// ,'Origin': 'la-bureautique'
|
|
||||||
// ,'Referrer-Policy': 'unsafe-url'
|
|
||||||
// ,'Redirect': 'manual'
|
|
||||||
},
|
|
||||||
signal: controller.signal
|
|
||||||
}
|
|
||||||
|
|
||||||
fetch(fullURL, fetchOpts)
|
|
||||||
.then(reponse => {
|
|
||||||
return reponse.text()
|
|
||||||
})
|
|
||||||
.then(html => {
|
|
||||||
// console.log(html)
|
|
||||||
|
|
||||||
var regex = /url='([^']+)/i;
|
|
||||||
var redirectURL = html.match(regex)[1]
|
|
||||||
|
|
||||||
return redirectURL
|
|
||||||
})
|
|
||||||
.then(url => {
|
|
||||||
|
|
||||||
console.log(url)
|
|
||||||
})
|
|
||||||
|
|
||||||
// JSON.stringify(json)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function ipfs_init() {
|
|
||||||
|
|
||||||
const node = await window.IpfsCore.create(
|
|
||||||
|
|
||||||
{
|
|
||||||
config: {
|
|
||||||
Addresses: {
|
|
||||||
Swarm: [
|
|
||||||
'/dns4/wrtc-star1.par.dwebops.pub/tcp/443/wss/p2p-webrtc-star',
|
|
||||||
'/dns4/wrtc-star2.sjc.dwebops.pub/tcp/443/wss/p2p-webrtc-star'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Discovery": {
|
|
||||||
"MDNS": {
|
|
||||||
"Enabled": false,
|
|
||||||
"Interval": 10
|
|
||||||
},
|
|
||||||
"webRTCStar": {
|
|
||||||
"Enabled": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Bootstrap": [
|
|
||||||
"/dns4/wss0.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic",
|
|
||||||
"/dns4/wss1.bootstrap.libp2p.io/tcp/443/wss/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
let nodeId = await node.id();
|
|
||||||
console.log('node id :', nodeId)
|
|
||||||
nodeId = nodeId.id
|
|
||||||
console.log(nodeId)
|
|
||||||
const version = await node.version();
|
|
||||||
console.log('Version:', version.version);
|
|
||||||
|
|
||||||
async function ipfs_upload(file, wrapWithDirectory) {
|
|
||||||
|
|
||||||
const fileAdded = await node.add(
|
|
||||||
{
|
|
||||||
path: file.name,
|
|
||||||
content: file
|
|
||||||
},
|
|
||||||
{
|
|
||||||
wrapWithDirectory,
|
|
||||||
progress: bytesAdded => document.getElementById('informations').innerHTML = `Sending... ${Math.round((bytesAdded / file.size) * 100)}%`
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const cid = fileAdded.cid.toString();
|
|
||||||
var salt = 'totodu56';
|
|
||||||
var pepper = 'totodu56';
|
|
||||||
|
|
||||||
document.getElementById('informations').innerHTML = [
|
|
||||||
'Prêt à enregistrer !',
|
|
||||||
'',
|
|
||||||
'Son Hash (CID) est :',
|
|
||||||
`<a href="http://libra.copylaradio.com:1234/?salt=${salt}&pepper=${pepper}&testcraft=on&nodeid=${nodeId}&dataid=${cid}" target="reboot">${cid}</a>`,
|
|
||||||
'(cliquez pour demander enregistrement)'
|
|
||||||
].join('<br />');
|
|
||||||
|
|
||||||
cacheIt('testcraft=on', cid, nodeId)
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById('file').disabled = false;
|
|
||||||
|
|
||||||
document.getElementById('file').addEventListener('change', async event => {
|
|
||||||
|
|
||||||
event.preventDefault();
|
|
||||||
document.getElementById('file').disabled = true;
|
|
||||||
|
|
||||||
const fileInput = document.getElementById('file');
|
|
||||||
|
|
||||||
if (!fileInput.files.length) {
|
|
||||||
|
|
||||||
alert('You have to select a file first');
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
const wrapWithDirectory = document.getElementById('wrapWithDirectory').checked;
|
|
||||||
|
|
||||||
await ipfs_upload(fileInput.files[0], wrapWithDirectory)
|
|
||||||
.catch(error => alert(error.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
document.getElementById('file').disabled = false;
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ipfs_init();
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</body></html>
|
|
|
@ -0,0 +1 @@
|
||||||
|
dunikey.html
|
|
@ -0,0 +1,275 @@
|
||||||
|
<html class=" rrghhqet idc0_344 cadefrffwk ftnryedt"><head>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
|
<title>Upload files to Astroport</title>
|
||||||
|
<style>
|
||||||
|
a, a:hover, a:visited, a:active {
|
||||||
|
color: #fff;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
border: 0;
|
||||||
|
margin: 0;
|
||||||
|
|
||||||
|
font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;
|
||||||
|
|
||||||
|
background-color: #041d2f;
|
||||||
|
color: #fff;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=text] {
|
||||||
|
width: 500px;
|
||||||
|
height: 50px;
|
||||||
|
text-align: center;
|
||||||
|
margin: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=file] {
|
||||||
|
width: 0.1px;
|
||||||
|
height: 0.1px;
|
||||||
|
opacity: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
position: absolute;
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=file] + label {
|
||||||
|
display: inline-block;
|
||||||
|
|
||||||
|
font-size: 1.25em;
|
||||||
|
font-weight: 700;
|
||||||
|
|
||||||
|
color: #333;
|
||||||
|
background-color: #fff;
|
||||||
|
border-radius: 5px;
|
||||||
|
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=file]:focus + label,
|
||||||
|
input[type=file] + label:hover {
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
width: 500px;
|
||||||
|
height: 50px;
|
||||||
|
text-align: center;
|
||||||
|
margin: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
flex: 1;
|
||||||
|
margin: 10px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.informations {
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.image {
|
||||||
|
display: block;
|
||||||
|
margin: 0 auto;
|
||||||
|
height: 300px;
|
||||||
|
margin-bottom: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wrapWithDirectoryContainer {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
text-align: center;
|
||||||
|
margin: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script src="ipfs.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="content">
|
||||||
|
<img src="./logo-astroport.png" class="image">
|
||||||
|
|
||||||
|
<div id="informations" class="informations">
|
||||||
|
Téléverser un fichier vers Astroport
|
||||||
|
</div>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<form>
|
||||||
|
<input id="file" type="file">
|
||||||
|
<label for="file">Choose a file</label>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<div class="wrapWithDirectoryContainer">
|
||||||
|
<input id="wrapWithDirectory" type="checkbox">
|
||||||
|
<label for="wrapWithDirectory">Wrap with a directory (recommended)</label>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function cacheIt (appName, hash, nodeId = '') {
|
||||||
|
|
||||||
|
var gatewayProtocol = 'http';
|
||||||
|
|
||||||
|
var gatewayDomain = 'ipfs.localhost';
|
||||||
|
|
||||||
|
var gatewayPort = '1234';
|
||||||
|
|
||||||
|
var salt = 'totodu56';
|
||||||
|
var pepper = 'totodu56';
|
||||||
|
|
||||||
|
var query = 'salt='+ salt
|
||||||
|
query += '&pepper='+ pepper
|
||||||
|
query += '&' + appName
|
||||||
|
query += '&nodeid=' + nodeId
|
||||||
|
query += '&dataid=' + hash;
|
||||||
|
|
||||||
|
var fullURL = 'http://'+ gatewayDomain +':'+ gatewayPort + '/?' + query;
|
||||||
|
console.log(fullURL)
|
||||||
|
|
||||||
|
const controller = new AbortController()
|
||||||
|
const timeoutId = setTimeout( () => {
|
||||||
|
controller.abort()
|
||||||
|
}, 15000)
|
||||||
|
var fetchOpts = {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'text/html'
|
||||||
|
// ,'Content-Type': 'text/html'
|
||||||
|
// // ,'Access-Control-Allow-Origin': '*',
|
||||||
|
// ,'Origin': 'la-bureautique'
|
||||||
|
// ,'Referrer-Policy': 'unsafe-url'
|
||||||
|
// ,'Redirect': 'manual'
|
||||||
|
},
|
||||||
|
signal: controller.signal
|
||||||
|
}
|
||||||
|
|
||||||
|
fetch(fullURL, fetchOpts)
|
||||||
|
.then(reponse => {
|
||||||
|
return reponse.text()
|
||||||
|
})
|
||||||
|
.then(html => {
|
||||||
|
// console.log(html)
|
||||||
|
|
||||||
|
var regex = /url='([^']+)/i;
|
||||||
|
var redirectURL = html.match(regex)[1]
|
||||||
|
|
||||||
|
return redirectURL
|
||||||
|
})
|
||||||
|
.then(url => {
|
||||||
|
|
||||||
|
console.log(url)
|
||||||
|
})
|
||||||
|
|
||||||
|
// JSON.stringify(json)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function ipfs_init() {
|
||||||
|
|
||||||
|
const node = await window.IpfsCore.create(
|
||||||
|
|
||||||
|
{
|
||||||
|
config: {
|
||||||
|
Addresses: {
|
||||||
|
Swarm: [
|
||||||
|
'/dns4/wrtc-star1.par.dwebops.pub/tcp/443/wss/p2p-webrtc-star',
|
||||||
|
'/dns4/wrtc-star2.sjc.dwebops.pub/tcp/443/wss/p2p-webrtc-star'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Discovery": {
|
||||||
|
"MDNS": {
|
||||||
|
"Enabled": false,
|
||||||
|
"Interval": 10
|
||||||
|
},
|
||||||
|
"webRTCStar": {
|
||||||
|
"Enabled": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Bootstrap": [
|
||||||
|
"/dns4/wss0.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmZMxNdpMkewiVZLMRxaNxUeZpDUb34pWjZ1kZvsd16Zic",
|
||||||
|
"/dns4/wss1.bootstrap.libp2p.io/tcp/443/wss/ipfs/Qmbut9Ywz9YEDrz8ySBSgWyJk41Uvm2QJPhwDJzJyGFsD6"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
let nodeId = await node.id();
|
||||||
|
console.log('node id :', nodeId)
|
||||||
|
nodeId = nodeId.id
|
||||||
|
console.log(nodeId)
|
||||||
|
const version = await node.version();
|
||||||
|
console.log('Version:', version.version);
|
||||||
|
|
||||||
|
async function ipfs_upload(file, wrapWithDirectory) {
|
||||||
|
|
||||||
|
const fileAdded = await node.add(
|
||||||
|
{
|
||||||
|
path: file.name,
|
||||||
|
content: file
|
||||||
|
},
|
||||||
|
{
|
||||||
|
wrapWithDirectory,
|
||||||
|
progress: bytesAdded => document.getElementById('informations').innerHTML = `Sending... ${Math.round((bytesAdded / file.size) * 100)}%`
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const cid = fileAdded.cid.toString();
|
||||||
|
var salt = 'totodu56';
|
||||||
|
var pepper = 'totodu56';
|
||||||
|
|
||||||
|
document.getElementById('informations').innerHTML = [
|
||||||
|
'Prêt à enregistrer !',
|
||||||
|
'',
|
||||||
|
'Son Hash (CID) est :',
|
||||||
|
`<a href="http://libra.copylaradio.com:1234/?salt=${salt}&pepper=${pepper}&testcraft=on&nodeid=${nodeId}&dataid=${cid}" target="reboot">${cid}</a>`,
|
||||||
|
'(cliquez pour demander enregistrement)'
|
||||||
|
].join('<br />');
|
||||||
|
|
||||||
|
cacheIt('testcraft=on', cid, nodeId)
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('file').disabled = false;
|
||||||
|
|
||||||
|
document.getElementById('file').addEventListener('change', async event => {
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
document.getElementById('file').disabled = true;
|
||||||
|
|
||||||
|
const fileInput = document.getElementById('file');
|
||||||
|
|
||||||
|
if (!fileInput.files.length) {
|
||||||
|
|
||||||
|
alert('You have to select a file first');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
const wrapWithDirectory = document.getElementById('wrapWithDirectory').checked;
|
||||||
|
|
||||||
|
await ipfs_upload(fileInput.files[0], wrapWithDirectory)
|
||||||
|
.catch(error => alert(error.toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('file').disabled = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ipfs_init();
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body></html>
|
Loading…
Reference in New Issue