#!/bin/bash # Simple bash client for linux if [ "$#" != 3 ] || { [ "$1" != "download" ] && [ "$1" != "upload" ];} then echo "Usage: $0 [download|upload] FILENAME SERVERNAME"; exit 1; fi f=$2; s=$3 if [ "$1" = "download" ] then c=$(dig +short txt "$f".count."$s"|tr -d \") for i in $(seq 0 "$c"); do echo -n "$(dig +short txt "$f"."$i"."$s"|tr -d \")"; done | base64 -d > "$f" else i=0; d=$(base64 -w 0 < "$f"); id=$(sha256sum "$f" | cut -d" " -f1 | base64 -w 0 | cut -c1-6) while true; do u=".$i-${id}u.$s"; ((i++)); x=$((63-${#u})) if [ $x -lt ${#d} ] then p=${d:0:$x}; d=${d:$x}; dig +short txt "$p$u" else dig +short txt "$d$u"; exit 0 fi done fi # Minimal working example for download in case you have to type it all manually mwe() { f=$1; s=$2; c=$(dig +short txt "$f".count."$s"|tr -d \") for i in $(seq 0 "$c"); do echo -n "$(dig +short txt "$f"."$i"."$s"|tr -d \")"; done | base64 -d > "$f" }