Last active
April 13, 2025 18:14
-
-
Save thiswillbeyourgithub/53befc8223f37aa929b35c6ebf8e6365 to your computer and use it in GitHub Desktop.
Revisions
-
thiswillbeyourgithub revised this gist
Apr 13, 2025 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ #!/bin/zsh # # Note : I will probably not be using this script anymore, I made wormrot.sh : https://github.com/thiswillbeyourgithub/wormrot # # USAGE: # 0. Create a new folder # 1. Install edgevpn via 'curl -s https://raw.githubusercontent.com/mudler/edgevpn/master/install.sh | sudo sh' @@ -162,8 +164,8 @@ edge_receive() { echo "Detected uncompressed file, untaring without compression..." tar -vxf "$pathoffile" -C "$extract_dir" fi echo "Done untaring $pathoffile into $extract_dir. Content of that dir:" ls -lvaAR "$extract_dir" echo "Content of metadata file:" cat "$extract_dir/metadata.json" -
thiswillbeyourgithub revised this gist
Apr 4, 2025 . 1 changed file with 48 additions and 32 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ #!/bin/zsh # # USAGE: # 0. Create a new folder @@ -39,7 +39,17 @@ uvx HumanReadableSeed@latest toread "$@" edge_send() { local compress=1 local pathoffile="" # Parse arguments for arg in "$@"; do if [[ "$arg" == "-c" || "$arg" == "--compress" ]]; then compress=1 elif [[ "$pathoffile" == "" && "$arg" != "send" ]]; then pathoffile="$arg" fi done # check if a file or a non empty dir if [ ! -f "$pathoffile" ] && ( [ ! -d "$pathoffile" ] || [ ! "$(ls -A "$pathoffile")" ] ) then @@ -58,31 +68,39 @@ edge_send() { echo "Error: Must supply a path" else echo "Creating metadata..." local metadata_file=$(mktemp --suffix="_metadata_${name}.json") filename=$(basename $pathoffile) metadata_filename=$(basename $metadata_file) if [[ "$compress" == "1" ]] then echo "Using file compression" local tar_file=$(mktemp --suffix="_${name}.tar.gz") tararg="-cvzf" else echo "Not using file compression" local tar_file=$(mktemp --suffix="_${name}.tar") tararg="-cvf" fi echo '{"filename": "'"$filename"'", "timestamp": "'$(date -Iseconds)'"}' > "$metadata_file" echo "Tar archive location: $tar_file" if [[ -d "$pathoffile" ]]; then echo "Creating tar for dir $pathoffile ..." # Get the directory containing the target parent_dir=$(dirname "$pathoffile") target_name=$(basename "$pathoffile") tar --transform="s/$filename/file/" --transform="s/$metadata_filename/metadata.json/" $tararg "$tar_file" -C "$parent_dir" "$target_name" -C "$(dirname $metadata_file)" "$(basename $metadata_file)" else echo "Creating tar for file $pathoffile ..." # Get the directory containing the target parent_dir=$(dirname "$pathoffile") target_name=$(basename "$pathoffile") tar --transform="s/$filename/file/" --transform="s/$metadata_filename/metadata.json/" $tararg "$tar_file" -C "$parent_dir" "$target_name" -C "$(dirname $metadata_file)" "$(basename $metadata_file)" fi echo "Done creating tar archive" echo "Cleaning up metadata file..." trash -v -- "$metadata_file" if [ ! -f "$tar_file" ] then @@ -98,15 +116,15 @@ edge_send() { echo "File transfer took $duration seconds." echo "Cleaning up tar archive..." trash -v -- "$tar_file" echo "File transfer complete." fi } edge_receive() { local human=$(get_mnemonic $EDGEVPNTOKEN) local name="EdgeVPN_file_$(echo $human | cut -c-30 | paste -sd ' ' - | sed 's/ /_/g')" local pathoffile=$(mktemp --suffix="_EdgeVPN_received_file.tar.gz") echo "\n" echo "Temporary file location: $pathoffile" echo "Human readable token:\n---\n$human\n---" @@ -127,39 +145,37 @@ edge_receive() { echo "Received file is empty. Deleting and retrying..." echo "" echo "" trash -v -- "$pathoffile" sleep 1 # Wait for X seconds before retrying fi done echo "Extracting contents..." local extract_dir=$(mktemp -d --suffix="_extracted_$(basename "$pathoffile" .tar.gz)") mkdir -p "$extract_dir" # Check if file is compressed using the file command if file "$pathoffile" | grep -q "gzip"; then echo "Detected gzip compressed file, untaring with compression..." tar -vxzf "$pathoffile" -C "$extract_dir" else echo "Detected uncompressed file, untaring without compression..." tar -vxf "$pathoffile" -C "$extract_dir" fi echo "Done untaring $pathoffile into $extract_dir" ls -lvaR "$extract_dir" echo "Content of metadata file:" cat "$extract_dir/metadata.json" filename=$(cat "$extract_dir/metadata.json" | jq -r '.["filename"]') trash -v -- "$extract_dir/metadata.json" echo "Moving file to ./$filename ..." && \ mv -v "$extract_dir"/file ./$filename &&\ echo "Cleaning up temporary files..." &&\ trash -v -- "$extract_dir" &&\ trash -v -- "$pathoffile" &&\ echo "File transfer and extraction complete." } @@ -170,7 +186,7 @@ eval $(uvx ShellArgParser@latest $@) if [[ "$ARGS_1" == "send" ]] then edge_send "$@" elif [[ "$ARGS_1" == "receive" ]] then edge_receive -
thiswillbeyourgithub revised this gist
Mar 29, 2025 . 1 changed file with 9 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -136,14 +136,14 @@ edge_receive() { local extract_dir="/tmp/extracted_$(basename "$pathoffile" .tar.gz)" mkdir -p "$extract_dir" # Check if file is compressed using the file command if file "$pathoffile" | grep -q "gzip"; then echo "Detected gzip compressed file, untaring with compression..." tar -xzf "$pathoffile" -C "$extract_dir" else echo "Detected uncompressed file, untaring without compression..." tar -xf "$pathoffile" -C "$extract_dir" fi echo "Done untaring" if [[ -f "$extract_dir/metadata_${name}.json" ]]; then @@ -153,9 +153,9 @@ edge_receive() { else echo "No metadata file found." fi echo "Moving extracted files to current directory..." mv "$extract_dir"/* . echo "Cleaning up temporary files..." rm -ri -- "$extract_dir" -
thiswillbeyourgithub revised this gist
Jan 7, 2025 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -153,9 +153,9 @@ edge_receive() { else echo "No metadata file found." fi # # echo "Moving extracted files to current directory..." # mv "$extract_dir"/* . echo "Cleaning up temporary files..." rm -ri -- "$extract_dir" -
thiswillbeyourgithub revised this gist
Jan 5, 2025 . 1 changed file with 4 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,10 +2,10 @@ # # USAGE: # 0. Create a new folder # 1. Install edgevpn via 'curl -s https://raw.githubusercontent.com/mudler/edgevpn/master/install.sh | sudo sh' # 2. Put this script in the same folder, with name "edge_vpn_file_scripts.sh" # 3. Run "chmod +x edge_vpn_file_scripts.sh" # 4. Put your edgevpn token inside the environment variable called EDGEVPNTOKEN # 5. add those alias to your shell: # alias edge_send="path_to_here/edge_vpn_file_scripts.sh send" # alias edge_receive="path_to_here/edge_vpn_file_scripts.sh receive" @@ -38,8 +38,6 @@ uvx HumanReadableSeed@latest toread "$@" # # extra_args="$extra_args --libp2p-log-level=debug" # info edge_send() { local pathoffile=$ARGS_2 # check if a file or a non empty dir @@ -94,7 +92,7 @@ edge_send() { echo "Sending the tar archive..." start_time=$(date +%s) expect -c "set timeout -1; spawn edgevpn file-send $extra_args --name \"$name\" --path \"$tar_file\" ; expect \") Done handling \" {puts \"File successfully sent\"; sleep 3; exit 0}" end_time=$(date +%s) duration=$((end_time - start_time)) echo "File transfer took $duration seconds." @@ -118,7 +116,7 @@ edge_receive() { # retry as long as the file is of size 0 while true; do edgevpn file-receive $extra_args --name "$name" --path "$pathoffile" if [[ -s "$pathoffile" ]]; then echo "File received successfully." break -
thiswillbeyourgithub revised this gist
Dec 26, 2024 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,9 @@ # 2. On deviceB simply run `edge_receive` # 3. When the second command exits, you can stop the first one. # # Note: # - it can take some time for each device to find each other. I've had even 10-20 minutes! # - the temporary file is stored in /tmp so normally is only taking up ram, not disk space get_mnemonic() { @@ -40,9 +42,10 @@ edgevpn_binary="$(dirname $0)/edgevpn" edge_send() { local pathoffile=$ARGS_2 # check if a file or a non empty dir if [ ! -f "$pathoffile" ] && ( [ ! -d "$pathoffile" ] || [ ! "$(ls -A "$pathoffile")" ] ) then echo "File not found at '""$pathoffile""'" exit 1 fi local human=$(get_mnemonic $EDGEVPNTOKEN) -
thiswillbeyourgithub revised this gist
Dec 6, 2024 . No changes.There are no files selected for viewing
-
thiswillbeyourgithub revised this gist
Dec 4, 2024 . 1 changed file with 19 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,23 @@ #!/usr/bin/zsh # # USAGE: # 0. Create a new folder # 1. Put the edgevpn binary file inside this folder, and name this binary "edgevpn" # 2. Put this script in the same folder, with name "edge_vpn_file_scripts.sh" # 3. Run "chmod +x edge_vpn_file_scripts.sh" # 4. Put your edgevpn token inside the environment variable EDGEVPNTOKEN # 5. add those alias to your shell: # alias edge_send="path_to_here/edge_vpn_file_scripts.sh send" # alias edge_receive="path_to_here/edge_vpn_file_scripts.sh receive" # 6. Repeat for every device you want to be able to exchange files. # # Now, to send a file from deviceA to deviceB, do: # 1. On deviceA run `edge_send path_to_file` (optional: add `--compress` at the end) # 2. On deviceB simply run `edge_receive` # 3. When the second command exits, you can stop the first one. # # Note: it can take some time for each device to find each other. I've had even 10-20 minutes! get_mnemonic() { # note: this function turns the token into words reversibly -
thiswillbeyourgithub revised this gist
Dec 4, 2024 . 1 changed file with 12 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,7 +20,12 @@ uvx HumanReadableSeed@latest toread "$@" edgevpn_binary="$(dirname $0)/edgevpn" edge_send() { local pathoffile=$ARGS_2 if [ ! -f "$pathoffile" ] then echo "File not found at '" "$pathoffile" "'" exit 1 fi local human=$(get_mnemonic $EDGEVPNTOKEN) local name="EdgeVPN_file_$(echo $human | cut -c-30 | paste -sd ' ' - | sed 's/ /_/g')" echo "\n" @@ -59,6 +64,12 @@ edge_send() { echo "Cleaning up metadata file..." rm -- "$metadata_file" if [ ! -f "$tar_file" ] then echo "Tar output not found at '" "$tar_file" "', something went wrong" exit 1 fi echo "Sending the tar archive..." start_time=$(date +%s) expect -c "set timeout -1; spawn $edgevpn_binary file-send $extra_args --name \"$name\" --path \"$tar_file\" ; expect \") Done handling \" {puts \"File successfully sent\"; sleep 3; exit 0}" -
thiswillbeyourgithub revised this gist
Dec 4, 2024 . 1 changed file with 20 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,5 @@ #!/usr/bin/zsh get_mnemonic() { # note: this function turns the token into words reversibly # source: https://github.com/thiswillbeyourgithub/HumanReadableSeed @@ -19,8 +16,11 @@ uvx HumanReadableSeed@latest toread "$@" # extra_args="$extra_args --log-level=debug" # info # # extra_args="$extra_args --libp2p-log-level=debug" # info edgevpn_binary="$(dirname $0)/edgevpn" edge_send() { local pathoffile=$ARGS_1 local human=$(get_mnemonic $EDGEVPNTOKEN) local name="EdgeVPN_file_$(echo $human | cut -c-30 | paste -sd ' ' - | sed 's/ /_/g')" echo "\n" @@ -34,7 +34,7 @@ edge_send() { else echo "Creating metadata..." local metadata_file="/tmp/metadata_${name}.json" if [[ "$ARGS_COMPRESS" == "1" ]] then echo "Using file compression" local tar_file="/tmp/${name}.tar.gz" @@ -61,7 +61,7 @@ edge_send() { echo "Sending the tar archive..." start_time=$(date +%s) expect -c "set timeout -1; spawn $edgevpn_binary file-send $extra_args --name \"$name\" --path \"$tar_file\" ; expect \") Done handling \" {puts \"File successfully sent\"; sleep 3; exit 0}" end_time=$(date +%s) duration=$((end_time - start_time)) echo "File transfer took $duration seconds." @@ -85,7 +85,7 @@ edge_receive() { # retry as long as the file is of size 0 while true; do $edgevpn_binary file-receive $extra_args --name "$name" --path "$pathoffile" if [[ -s "$pathoffile" ]]; then echo "File received successfully." break @@ -133,3 +133,16 @@ edge_receive() { echo "File transfer and extraction complete." } # parse arguments eval $(uvx ShellArgParser@latest $@) if [[ "$ARGS_1" == "send" ]] then edge_send elif [[ "$ARGS_1" == "receive" ]] then edge_receive else echo "Unexpected first argument, not 'send' nor 'receive'" fi -
thiswillbeyourgithub revised this gist
Oct 16, 2024 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/usr/bin/zsh # true to use compression for tar COMPRESS="false" get_mnemonic() { # note: this function turns the token into words reversibly @@ -57,7 +57,7 @@ edge_send() { echo "Done creating tar archive" echo "Cleaning up metadata file..." rm -- "$metadata_file" echo "Sending the tar archive..." start_time=$(date +%s) @@ -67,7 +67,7 @@ edge_send() { echo "File transfer took $duration seconds." echo "Cleaning up tar archive..." rm -- "$tar_file" echo "File transfer complete." fi @@ -96,7 +96,7 @@ edge_receive() { echo "Received file is empty. Deleting and retrying..." echo "" echo "" rm -- "$pathoffile" sleep 1 # Wait for X seconds before retrying fi done @@ -118,7 +118,7 @@ edge_receive() { if [[ -f "$extract_dir/metadata_${name}.json" ]]; then echo "Metadata found:" cat "$extract_dir/metadata_${name}.json" rm -- "$extract_dir/metadata_${name}.json" else echo "No metadata file found." fi -
thiswillbeyourgithub revised this gist
Oct 12, 2024 . 1 changed file with 11 additions and 26 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,24 +4,9 @@ COMPRESS="true" get_mnemonic() { # note: this function turns the token into words reversibly # source: https://github.com/thiswillbeyourgithub/HumanReadableSeed uvx HumanReadableSeed@latest toread "$@" } # extra_args="" # default values @@ -37,7 +22,7 @@ for i in range(0, len(words), 4): edge_send() { local pathoffile=$1 local human=$(get_mnemonic $EDGEVPNTOKEN) local name="EdgeVPN_file_$(echo $human | cut -c-30 | paste -sd ' ' - | sed 's/ /_/g')" echo "\n" echo "File to send: $pathoffile" echo "Human readable token:\n---\n$human\n---" @@ -72,7 +57,7 @@ edge_send() { echo "Done creating tar archive" echo "Cleaning up metadata file..." rm -i -- "$metadata_file" echo "Sending the tar archive..." start_time=$(date +%s) @@ -82,14 +67,14 @@ edge_send() { echo "File transfer took $duration seconds." echo "Cleaning up tar archive..." rm -i -- "$tar_file" echo "File transfer complete." fi } edge_receive() { local human=$(get_mnemonic $EDGEVPNTOKEN) local name="EdgeVPN_file_$(echo $human | cut -c-30 | paste -sd ' ' - | sed 's/ /_/g')" local pathoffile="/tmp/EdgeVPN_received_file_$(date +'%Y%m%d_%H%M%S').tar.gz" echo "\n" echo "Temporary file location: $pathoffile" @@ -111,7 +96,7 @@ edge_receive() { echo "Received file is empty. Deleting and retrying..." echo "" echo "" rm -i -- "$pathoffile" sleep 1 # Wait for X seconds before retrying fi done @@ -133,7 +118,7 @@ edge_receive() { if [[ -f "$extract_dir/metadata_${name}.json" ]]; then echo "Metadata found:" cat "$extract_dir/metadata_${name}.json" rm -i -- "$extract_dir/metadata_${name}.json" else echo "No metadata file found." fi @@ -142,8 +127,8 @@ edge_receive() { mv "$extract_dir"/* . echo "Cleaning up temporary files..." rm -ri -- "$extract_dir" rm -i -- "$pathoffile" echo "File transfer and extraction complete." } -
thiswillbeyourgithub revised this gist
Sep 30, 2024 . 1 changed file with 54 additions and 22 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,8 @@ #!/usr/bin/zsh # true to use compression for tar COMPRESS="true" get_mnemonic() { # note: this function turns any string into human readable english words. It cannot be used in reverse and is only meant for quick visual confirmation python -c " @@ -21,6 +24,16 @@ for i in range(0, len(words), 4): " "$@" } # extra_args="" # default values # # extra_args="$extra_args --low-profile=false" # true # # extra_args="$extra_args --discovery-interval=10" # 720 # extra_args="$extra_args --ledger-announce-interval=10" # 10 # # extra_args="$extra_args --autorelay-discovery-interval=1m" # 5m # extra_args="$extra_args --ledger-synchronization-interval=10" # 10 # # extra_args="$extra_args --aliveness-healthcheck-interval=30" # 120 # extra_args="$extra_args --log-level=debug" # info # # extra_args="$extra_args --libp2p-log-level=debug" # info edge_send() { local pathoffile=$1 local human=$(get_mnemonic $EDGEVPNTOKEN) @@ -35,32 +48,42 @@ edge_send() { echo "Error: Must supply a path" else echo "Creating metadata..." local metadata_file="/tmp/metadata_${name}.json" if [[ "$COMPRESS" == "true" ]] then echo "Using file compression" local tar_file="/tmp/${name}.tar.gz" tararg="-czf" else echo "Not using file compression" local tar_file="/tmp/${name}.tar" tararg="-cf" fi echo '{"filename": "'"$pathoffile"'", "timestamp": "'$(date -Iseconds)'"}' > "$metadata_file" echo "Tar archive location: $tar_file" if [[ -d "$pathoffile" ]]; then echo "Creating tar for dir $pathoffile ..." tar $tararg "$tar_file" "$pathoffile" "$metadata_file" else echo "Creating tar for file $pathoffile ..." tar $tararg "$tar_file" "$pathoffile" "$metadata_file" fi echo "Done creating tar archive" echo "Cleaning up metadata file..." rm "$metadata_file" echo "Sending the tar archive..." start_time=$(date +%s) expect -c "set timeout -1; spawn edgevpn file-send $extra_args --name \"$name\" --path \"$tar_file\" ; expect \") Done handling \" {puts \"File successfully sent\"; sleep 3; exit 0}" end_time=$(date +%s) duration=$((end_time - start_time)) echo "File transfer took $duration seconds." echo "Cleaning up tar archive..." rm "$tar_file" echo "File transfer complete." fi } @@ -77,7 +100,7 @@ edge_receive() { # retry as long as the file is of size 0 while true; do edgevpn file-receive $extra_args --name "$name" --path "$pathoffile" if [[ -s "$pathoffile" ]]; then echo "File received successfully." break @@ -92,27 +115,36 @@ edge_receive() { sleep 1 # Wait for X seconds before retrying fi done echo "Extracting contents..." local extract_dir="/tmp/extracted_$(basename "$pathoffile" .tar.gz)" mkdir -p "$extract_dir" # trying with and without encryption { echo "Untaring file as if compressed..." tar -xzf "$pathoffile" -C "$extract_dir" } || { echo "Error, retrying as uncompressed..." tar -xf "$pathoffile" -C "$extract_dir" } echo "Done untaring" if [[ -f "$extract_dir/metadata_${name}.json" ]]; then echo "Metadata found:" cat "$extract_dir/metadata_${name}.json" rm "$extract_dir/metadata_${name}.json" else echo "No metadata file found." fi echo "Moving extracted files to current directory..." mv "$extract_dir"/* . echo "Cleaning up temporary files..." rm -r "$extract_dir" rm "$pathoffile" echo "File transfer and extraction complete." } -
thiswillbeyourgithub revised this gist
Sep 11, 2024 . 1 changed file with 44 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,35 @@ #!/usr/bin/zsh get_mnemonic() { # note: this function turns any string into human readable english words. It cannot be used in reverse and is only meant for quick visual confirmation python -c " import sys import base64 import hashlib from mnemonic import Mnemonic input_data = base64.b64decode(sys.argv[1]) sha256_hash = hashlib.sha256(input_data).digest() first_16_bytes = sha256_hash[:16] m = Mnemonic('english') # m.to_mnemonic accepts lengths 16, 20, 24, 28, 32 words = m.to_mnemonic(first_16_bytes).title().split(' ') for i in range(0, len(words), 4): w = words[i:i+4] print(' '.join(w)) " "$@" } edge_send() { local pathoffile=$1 local human=$(get_mnemonic $EDGEVPNTOKEN) local name="EdgeVPN_file_$(echo $human | paste -sd ' ' - | sed 's/ /_/g')" echo "\n" echo "File to send: $pathoffile" echo "Human readable token:\n---\n$human\n---" echo "\n" if [[ -z "$pathoffile" ]] then echo "Error: Must supply a path" @@ -40,22 +65,31 @@ edge_send() { fi } edge_receive() { local human=$(get_mnemonic $EDGEVPNTOKEN) local name="EdgeVPN_file_$(echo $human | paste -sd ' ' - | sed 's/ /_/g')" local pathoffile="/tmp/EdgeVPN_received_file_$(date +'%Y%m%d_%H%M%S').tar.gz" echo "\n" echo "Temporary file location: $pathoffile" echo "Human readable token:\n---\n$human\n---" echo "\n" echo "Waiting for file..." # retry as long as the file is of size 0 while true; do edgevpn file-receive --name "$name" --path "$pathoffile" if [[ -s "$pathoffile" ]]; then echo "File received successfully." break elif [[ -z "$pathoffile" ]]; then echo "Didn't receive a file. Crashing" return else echo "Received file is empty. Deleting and retrying..." echo "" echo "" rm "$pathoffile" sleep 1 # Wait for X seconds before retrying fi done -
thiswillbeyourgithub revised this gist
Sep 11, 2024 . 1 changed file with 5 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,8 +27,11 @@ edge_send() { echo "Sending file..." # edgevpn file-send --name "$name" --path "${name}.tar.gz" start_time=$(date +%s) expect -c "set timeout -1; spawn edgevpn file-send --name \"$name\" --path \"${name}.tar.gz\" ; expect \"(file $name) Done handling \" {puts \"File successfully sent\"; sleep 3; exit 0}" end_time=$(date +%s) duration=$((end_time - start_time)) echo "File transfer took $duration seconds." echo "Cleaning up tar archive..." rm "${name}.tar.gz" -
thiswillbeyourgithub revised this gist
Sep 11, 2024 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,9 @@ edge_send() { rm "$metadata_file" echo "Sending file..." # edgevpn file-send --name "$name" --path "${name}.tar.gz" expect -c "set timeout -1; spawn edgevpn file-send --name \"$name\" --path \"${name}.tar.gz\" ; expect \"(file $name) Done handling \" {puts \"File successfully sent\"; sleep 5; exit 0}" echo "Cleaning up tar archive..." rm "${name}.tar.gz" -
thiswillbeyourgithub revised this gist
Sep 10, 2024 . 1 changed file with 17 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ edge_send() { local name=$(echo $EDGEVPNTOKEN | sha256sum) local name="edgevpn_file_${name:0:20}" local pathoffile=$1 echo "Edge token:\n$EDGEVPNTOKEN\nName: $name\nPath: $pathoffile\n\n" if [[ -z "$pathoffile" ]] @@ -11,15 +11,15 @@ edge_send() { else echo "Creating metadata..." local metadata_file="metadata_${name}.json" echo '{"filename": "'"$pathoffile"'", "timestamp": "'$(date -Iseconds)'"}' > "$metadata_file" echo "Creating tar archive..." if [[ -d "$pathoffile" ]]; then echo "Sending directory: $pathoffile" tar -czf "${name}.tar.gz" "$pathoffile" "$metadata_file" else echo "Sending file: $pathoffile" tar -czf "${name}.tar.gz" "$pathoffile" "$metadata_file" fi echo "Cleaning up metadata file..." @@ -36,12 +36,23 @@ edge_send() { } edge_receive() { local name=$(echo $EDGEVPNTOKEN | sha256sum) local name="edgevpn_file_${name:0:20}" local pathoffile="/tmp/edgevpn_transfer.$(date +'%Y%m%d_%H%M%S').tar.gz" echo "Edge token:\n$EDGEVPNTOKEN\nName: $name\nPath: $pathoffile\n\n" echo "Receiving file..." while true; do edgevpn file-receive --name "$name" --path "$pathoffile" if [[ -s "$pathoffile" ]]; then echo "File received successfully." break else echo "Received file is empty. Deleting and retrying..." rm "$pathoffile" sleep 5 # Wait for 5 seconds before retrying fi done echo "Extracting contents..." local extract_dir="/tmp/extracted_$(basename "$pathoffile" .tar.gz)" -
thiswillbeyourgithub created this gist
Sep 10, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,68 @@ #!/usr/bin/zsh edge_send() { local name=$(echo $EDGEVPNTOKEN | sha256sum) local name=${name:0:20} local pathoffile=$1 echo "Edge token:\n$EDGEVPNTOKEN\nName: $name\nPath: $pathoffile\n\n" if [[ -z "$pathoffile" ]] then echo "Error: Must supply a path" else echo "Creating metadata..." local metadata_file="metadata_${name}.json" echo '{"filename": "'"$(basename "$pathoffile")"'", "timestamp": "'$(date -Iseconds)'"}' > "$metadata_file" echo "Creating tar archive..." if [[ -d "$pathoffile" ]]; then echo "Sending directory: $pathoffile" tar -czf "${name}.tar.gz" -C "$(dirname "$pathoffile")" "$(basename "$pathoffile")" "$metadata_file" else echo "Sending file: $pathoffile" tar -czf "${name}.tar.gz" -C "$(dirname "$pathoffile")" "$(basename "$pathoffile")" "$metadata_file" fi echo "Cleaning up metadata file..." rm "$metadata_file" echo "Sending file..." edgevpn file-send --name "$name" --path "${name}.tar.gz" echo "Cleaning up tar archive..." rm "${name}.tar.gz" echo "File transfer complete." fi } edge_receive() { local name=$(echo $EDGEVPNTOKEN | sha256sum) local name=${name:0:20} local pathoffile="/tmp/edgevpn_transfer.$(date +'%Y%m%d_%H%M%S').tar.gz" echo "Edge token:\n$EDGEVPNTOKEN\nName: $name\nPath: $pathoffile\n\n" echo "Receiving file..." edgevpn file-receive --name "$name" --path "$pathoffile" echo "Extracting contents..." local extract_dir="/tmp/extracted_$(basename "$pathoffile" .tar.gz)" mkdir -p "$extract_dir" tar -xzf "$pathoffile" -C "$extract_dir" if [[ -f "$extract_dir/metadata_${name}.json" ]]; then echo "Metadata found:" cat "$extract_dir/metadata_${name}.json" rm "$extract_dir/metadata_${name}.json" else echo "No metadata file found." fi echo "Moving extracted files to current directory..." mv "$extract_dir"/* . echo "Cleaning up temporary files..." rm -r "$extract_dir" rm "$pathoffile" echo "File transfer and extraction complete." }