From 53f66c53ebd263fd4ede5754c9302e7039159b5e Mon Sep 17 00:00:00 2001 From: Lukas Wurzinger Date: Wed, 9 Apr 2025 01:17:58 +0200 Subject: [PATCH] fixes --- README.md | 26 ++++++++++++++++++++++++++ taft | 47 +++++++++++++++++++++++++++-------------------- 2 files changed, 53 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 12326d9..f339a80 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,31 @@ # taft — Totally Adequate File Transfer A simple wrapper around nc(1) and tar(1). +taft's main focus is speed, so no encryption is involved, to minimize overhead. +If you're looking for a *secure* way to transfer files, go with sftp(1) instead. *Named after William Howard Taft, [America's greatest president by volume](https://idlewords.com/talks/website_obesity.htm)*. + +## Usage + +Destination host: + +``` +$ mkdir destination; cd destination +$ taft receive +``` + +Source host: + +``` +$ mkdir source; cd source +$ touch a b c +$ taft send 192.168.178.42 # destination IP address +./ +./c +./b +./a +``` + +The default port is 1337. +It can be changed via the `-p` or `--port` option. diff --git a/taft b/taft index a1f143b..7a5ff77 100644 --- a/taft +++ b/taft @@ -22,6 +22,8 @@ port=1337 path=. tarflags=() ncflags=() +verbose=false +compress=none while true; do case $1 in (-p | --port) @@ -33,25 +35,11 @@ while true; do shift 2 ;; (-v | --verbose) - tarflags+=(--verbose) - ncflags+=(-v) + verbose=true shift ;; (-c | --compress) - algo=$2 - case $algo in - (none) - ;; - (xz) - tarflags+=(--xz) - ;; - (zstd) - tarflags+=(--zstd) - ;; - (*) - error 'invalid compression algorithm' - ;; - esac + compress=$2 shift 2 ;; (--) @@ -61,6 +49,25 @@ while true; do esac done +if "$verbose"; then + tarflags+=(--verbose --verbose) + ncflags+=(-v) +fi + +case $compress in + (none) + ;; + (xz) + tarflags+=(--xz) + ;; + (zstd) + tarflags+=(--zstd) + ;; + (*) + error 'invalid compression algorithm' + ;; +esac + if (( $# == 0 )); then error 'a subcommand is required' fi @@ -68,7 +75,7 @@ fi subcommand=$1 case $subcommand in - (send) + (s | send) shift if (( $# < 1 )); then @@ -81,16 +88,16 @@ case $subcommand in dest=$1 - tar --create "${tarflags[@]}" -- "$path" | nc -q 1 "${ncflags[@]}" -- "$dest" "$port" + tar --verbose --create "${tarflags[@]}" -- "$path" | nc -q 1 "${ncflags[@]}" -- "$dest" "$port" ;; - (recv | receive) + (r | recv | receive) shift if (( $# > 0 )); then error 'too many arguments' fi - nc -q 1 -l -p "$port" "${ncflags[@]}" | tar --extract "${tarflags[@]}" + nc -q 1 -l -p "$port" "${ncflags[@]}" | tar --verbose --extract "${tarflags[@]}" ;; (*) error 'invalid subcommand'