Improvments
This commit is contained in:
parent
d44813e192
commit
114144f6e9
|
@ -5,6 +5,10 @@ err () {
|
|||
printf '\033[31m%s\033[m\n' "$*" >&2
|
||||
}
|
||||
|
||||
# TODO: Fallbacks with wget, nc, bash
|
||||
command -v curl >/dev/null 2>&1 || { echo "Need curl"; exit 1; }
|
||||
command -v timeout >/dev/null 2>&1 || { echo "Need timeout(1)"; exit 1; }
|
||||
|
||||
curl () {
|
||||
output=$(timeout 5 curl -sfSL "$@") # strip trailing newline
|
||||
err=$? # save exit status
|
||||
|
@ -23,7 +27,10 @@ file=$(mktemp --tmpdir pubtmpXXXXXXXXXXXXXXX) # must not contain dot .
|
|||
if [ -z "$1" ]; then
|
||||
cat >"$file" # `pub` or `<file pub` or `echo bla | pub`
|
||||
else
|
||||
cp "$1" "$file" # `pub FILE`
|
||||
if ! cp "$1" "$file"; then # `pub FILE`
|
||||
err "cp failed!"
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
######################## PASTEBINS ####################
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#! /bin/sh -
|
||||
|
||||
command -v qrencode >/dev/null 2>&1 || { echo "Need qrencode"; exit 1; }
|
||||
|
||||
[ -t 1 ] &&
|
||||
exec qrencode -m2 -t ANSI256UTF8 "$@" ||
|
||||
exec qrencode -m2 -t UTF8 "$@"
|
||||
|
|
|
@ -3,6 +3,13 @@
|
|||
[ ! $# = 1 ] && { echo "Usage: torshare REGULAR_FILE"; exit 1; }
|
||||
target_file="$1"
|
||||
|
||||
command -v curl >/dev/null 2>&1 || { echo "Need curl"; exit 2; }
|
||||
command -v instant_tor >/dev/null 2>&1 || { echo "Need instant_tor"; exit 2; }
|
||||
command -v pub >/dev/null 2>&1 || { echo "Need pub"; exit 2; }
|
||||
command -v qr >/dev/null 2>&1 || { echo "Need qr"; exit 2; }
|
||||
command -v python3 >/dev/null 2>&1 || { echo "Need python3"; exit 2; }
|
||||
command -v readlink >/dev/null 2>&1 || { echo "Need readlink"; exit 2; }
|
||||
|
||||
urlencode () {
|
||||
str="$*"
|
||||
encoded=
|
||||
|
@ -20,14 +27,18 @@ urlencode () {
|
|||
printf %s "$encoded"
|
||||
}
|
||||
|
||||
tor_host="$(instant_tor --daemonize)"
|
||||
tor_host="$(instant_tor --daemonize)" || { echo "Failed to start tor proxy"; exit 3; }
|
||||
ln -sf "$(readlink -f -- "$target_file")" "/tmp/.tmptor/html/$(basename -- "$target_file")"
|
||||
|
||||
link="$(pub << GET_FILE_VIA_TOR
|
||||
#! /bin/sh -
|
||||
|
||||
if [ ! -f ./instant_tor ] || ! command -v instant_tor > /dev/null 2>&1; then
|
||||
wget -q https://timo.one/get_instant_tor/instant_tor || { echo "Failed to download instant_tor"; exit 1; }
|
||||
wget -qO instant_tor https://timo.one/get_instant_tor/instant_tor || {
|
||||
curl -sfkSL -o instant_tor https://timo.one/get_instant_tor/instant_tor || {
|
||||
echo "Failed to download instant_tor"; exit 1;
|
||||
}
|
||||
}
|
||||
fi
|
||||
if [ ! -f ./instant_tor ]; then
|
||||
if ! command -v instant_tor > /dev/null 2>&1; then
|
||||
|
@ -38,7 +49,7 @@ if [ ! -f ./instant_tor ]; then
|
|||
fi
|
||||
chmod +x ./instant_tor
|
||||
./instant_tor --daemonize || { printf '\033[42;30m%s\033[m\n' "Some error occured while starting tor proxy, trying to download anyways"; }
|
||||
curl -O --proxy socks5h://127.0.0.1:9050 "$tor_host/$(urlencode "$target_file")" || { echo "Some error occured downloading file"; exit 4; }
|
||||
curl -O --proxy socks5h://127.0.0.1:9050 "$tor_host/$(urlencode "$target_file")" || { echo "Some error occured downloading file"; exit 3; }
|
||||
echo "Successfully downloaded $target_file, size \$(wc -c < ./$(squote_escape "$target_file")) bytes."
|
||||
GET_FILE_VIA_TOR
|
||||
)"
|
||||
|
|
Loading…
Reference in New Issue