hidden files, allow ips

This commit is contained in:
Q
2024-01-14 09:25:24 +02:00
parent 10ba7ef02b
commit 4eab9a34cd
6 changed files with 155 additions and 69 deletions

View File

@@ -17,6 +17,8 @@ _help() {
-d max days to keep (default 30)
-m max downloads to keep (default 9999, -1 to disable)
-p password
--hidden hidden file (from listings)
--allow comma separated list of ip addresses, accepts *
Filename:
When writing to share:
@@ -88,7 +90,7 @@ _write() {
[[ -d "$FILE" ]] && {
[[ "${NAME,,}" = *".tar" ]] || NAME="${NAME}".tar
_write_folder "$NAME" "$FILE"
tar c "$2" | _write_stdin "$NAME"
return $?
}
@@ -96,28 +98,9 @@ _write() {
_msg "No such file"
exit 1
}
_write_file "$NAME" "$FILE"
cat "$FILE" | _write_stdin "$NAME"
}
_write_folder() { # name, file
tar c "$2" | \
curl -fL -w "\n" -g --upload-file - \
-H "Name: $1" \
-H "Max-Downloads: $MAXDL" \
-H "Expires-Days: $MAXDAYS" \
-H "Secret: $MFL_TOKEN" \
-H "Password: $PASSWORD" \
"$MFL_ROOTURL"/upload | cat
}
_write_file() { # name, file
curl -fL -w "\n" -g --upload-file "$2" \
-H "Name: $1" \
-H "Max-Downloads: $MAXDL" \
-H "Expires-Days: $MAXDAYS" \
-H "Secret: $MFL_TOKEN" \
-H "Password: $PASSWORD" \
"$MFL_ROOTURL"/upload | cat
}
_write_stdin() { # name
cat - | \
curl -fL -w "\n" -g --upload-file - \
@@ -125,7 +108,9 @@ _write_stdin() { # name
-H "Max-Downloads: $MAXDL" \
-H "Expires-Days: $MAXDAYS" \
-H "Secret: $MFL_TOKEN" \
-H "Hidden: $HIDDEN" \
-H "Password: $PASSWORD" \
-H "Allowed-IP: $ALLOWED" \
"$MFL_ROOTURL"/upload | cat
}
@@ -218,6 +203,8 @@ done
MAXDL=9999
MAXDAYS=30
HIDDEN=false
ALLOWED=""
CMD=list
# if stdin comes from stream, default to write
[ -t 0 ] || CMD=help
@@ -226,6 +213,8 @@ for (( i=2; i<=$#; i++ )); do
[[ "${!i}" = "-m" ]] && { MAXDL=${!j}; i=$j; continue; }
[[ "${!i}" = "-d" ]] && { MAXDAYS=${!j}; i=$j; continue; }
[[ "${!i}" = "-p" ]] && { PASSWORD=${!j}; i=$j; continue; }
[[ "${!i}" = "--allow" ]] && { ALLOWED="${!j}"; i=$j; continue; }
[[ "${!i}" = "--hidden" ]] && { HIDDEN=true; continue; }
if [[ -z "$FILE" ]]; then
FILE="${!i}"
continue