From ee819a8629abfe89c23f44b44c073c27e1a1ff3c Mon Sep 17 00:00:00 2001 From: fbt Date: Mon, 19 Oct 2015 00:35:04 +0300 Subject: [PATCH 1/6] 8fw.eu --- sup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sup b/sup index c6bca90..aba2193 100755 --- a/sup +++ b/sup @@ -13,7 +13,7 @@ fi cfg_url_regex='^[A-Za-z]([A-Za-z0-9+.-]+)?://.+' cfg_tmp_dir="$XDG_RUNTIME_DIR/sup"; TEMPDIR="$cfg_tmp_dir" -cfg_service_url='https://zfh.so' +cfg_service_url='https://8fw.eu' cfg_screenshot_ext='png' [[ -f $HOME/.suprc ]] && { source "$HOME/.suprc"; } From a4e0a119a89abf4abb0be419b9084810f1066377 Mon Sep 17 00:00:00 2001 From: fbt Date: Tue, 20 Oct 2015 21:38:29 +0300 Subject: [PATCH 2/6] Another default domain change --- sup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sup b/sup index aba2193..16f3c43 100755 --- a/sup +++ b/sup @@ -13,7 +13,7 @@ fi cfg_url_regex='^[A-Za-z]([A-Za-z0-9+.-]+)?://.+' cfg_tmp_dir="$XDG_RUNTIME_DIR/sup"; TEMPDIR="$cfg_tmp_dir" -cfg_service_url='https://8fw.eu' +cfg_service_url='https://8fw.me' cfg_screenshot_ext='png' [[ -f $HOME/.suprc ]] && { source "$HOME/.suprc"; } From 8befbdf3daa50e93386be9ed9db3fc5f5a1d6e03 Mon Sep 17 00:00:00 2001 From: fbt Date: Fri, 13 Nov 2015 05:08:55 +0300 Subject: [PATCH 3/6] max filesize --- sup | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/sup b/sup index 16f3c43..512fab2 100755 --- a/sup +++ b/sup @@ -15,6 +15,7 @@ cfg_url_regex='^[A-Za-z]([A-Za-z0-9+.-]+)?://.+' cfg_tmp_dir="$XDG_RUNTIME_DIR/sup"; TEMPDIR="$cfg_tmp_dir" cfg_service_url='https://8fw.me' cfg_screenshot_ext='png' +cfg_max_filesize='200M' [[ -f $HOME/.suprc ]] && { source "$HOME/.suprc"; } @@ -42,10 +43,12 @@ sup.usage() { -D # Delay the shot by seconds. -p # Make the file private. Requires \$secret to be set in the config. -u # Generate a shortlink from URL. + -m # Maximum filesize (in megabytes) Config options (~/.suprc): secret # Your personal token. Get it at https://zfh.so/settings_form cfg_screenshot_ext # Screenshot file type, used by scrot. + cfg_max_filesize # Maximum filesize in megabytes. # Others are self-explanatory: cfg_url_regex cfg_tmp_dir @@ -63,6 +66,22 @@ sup.get_hash() { read file_hash _ < <( sha1sum "$1" ) } +sup.get_max_filesize() { + if [[ $cfg_max_filesize =~ ^[0-9]+[BKMG]?$ ]]; then + max_filesize_base="${cfg_max_filesize//[BKMG]/}" + + case "$cfg_max_filesize" in + *K) max_filesize_bytes=$(( max_filesize_base * 1024 ));; + *M) max_filesize_bytes=$(( max_filesize_base * 1024 * 1024 ));; + *G) max_filesize_bytes=$(( max_filesize_base * 1024 * 1024 * 1024 ));; + *) max_filesize_bytes=$max_filesize_base;; + esac + else + sup.err "Wrong cfg_max_filesize: $cfg_max_filesize" + return 1 + fi +} + sup.upload() { if (( flag_scrot )); then flag_rm=1 @@ -79,10 +98,19 @@ sup.upload() { flag_rm=1 file=$(sup.mktemp "$cfg_tmp_dir") - curl -skL "$target" > "$file" || { - sup.err "Could not download file." + sup.get_max_filesize || { return 1; } + + curl --max-filesize "$max_filesize_bytes" -skL "$target" > "$file" + curl_result=$? + + if (( curl_result )); then + case "$curl_result" in + 63) sup.err "File exceeds cfg_max_filesize";; + *) sup.err "Could not download file.";; + esac + return 1 - } + fi else file="$target" From b264c94a859bc96f3f3b5eb08a89477394f08917 Mon Sep 17 00:00:00 2001 From: fbt Date: Fri, 13 Nov 2015 05:13:12 +0300 Subject: [PATCH 4/6] taaaabs --- sup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sup b/sup index 512fab2..c961d38 100755 --- a/sup +++ b/sup @@ -43,7 +43,7 @@ sup.usage() { -D # Delay the shot by seconds. -p # Make the file private. Requires \$secret to be set in the config. -u # Generate a shortlink from URL. - -m # Maximum filesize (in megabytes) + -m # Maximum filesize (in megabytes) Config options (~/.suprc): secret # Your personal token. Get it at https://zfh.so/settings_form From 84ac5fb315414cd41f0aaa70a788e2d1d129a49a Mon Sep 17 00:00:00 2001 From: fbt Date: Fri, 13 Nov 2015 05:13:45 +0300 Subject: [PATCH 5/6] actually not in megabytes --- sup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sup b/sup index c961d38..d4a5fae 100755 --- a/sup +++ b/sup @@ -43,7 +43,7 @@ sup.usage() { -D # Delay the shot by seconds. -p # Make the file private. Requires \$secret to be set in the config. -u # Generate a shortlink from URL. - -m # Maximum filesize (in megabytes) + -m # Maximum filesize (takes K, M and G suffixes) Config options (~/.suprc): secret # Your personal token. Get it at https://zfh.so/settings_form From 6a42269dbc3ce10fd44cd6b59948ecdcb2708f36 Mon Sep 17 00:00:00 2001 From: fbt Date: Fri, 13 Nov 2015 05:14:26 +0300 Subject: [PATCH 6/6] README --- README.md | 1 + sup | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index eece29d..12ce803 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ A very simple tool to upload files to the zfh.so file hosting -F # Make a fullscreen shot instead of prompting for a window/area. Implies -s. -D # Delay the shot by seconds. -p # Make the file private. Requires $secret to be set in the config. + -m # Maximum filesize (takes K, M and G suffixes). Config options (~/.suprc): secret # Your personal token. Get it at https://zfh.so/settings_form diff --git a/sup b/sup index d4a5fae..9188601 100755 --- a/sup +++ b/sup @@ -43,7 +43,7 @@ sup.usage() { -D # Delay the shot by seconds. -p # Make the file private. Requires \$secret to be set in the config. -u # Generate a shortlink from URL. - -m # Maximum filesize (takes K, M and G suffixes) + -m # Maximum filesize (takes K, M and G suffixes). Config options (~/.suprc): secret # Your personal token. Get it at https://zfh.so/settings_form