Skip to content

Commit

Permalink
Merge pull request #776 from messense/redirect
Browse files Browse the repository at this point in the history
Add `--redirect` option
  • Loading branch information
messense committed Mar 17, 2023
2 parents 12ef8ab + d05a2f4 commit fa4a5f3
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 12 deletions.
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions openwrt/aliyundrive-webdav/files/aliyundrive-webdav.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ config server
option tls_key ''
option skip_upload_same_size '0'
option prefer_http_download '0'
option redirect '0'
7 changes: 7 additions & 0 deletions openwrt/aliyundrive-webdav/files/aliyundrive-webdav.init
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ start_service() {
*) ;;
esac

case "$(uci_get_by_type server redirect 0)" in
1|on|true|yes|enabled)
extra_options="$extra_options --redirect"
;;
*) ;;
esac

if [[ ! -z "$tls_cert" && ! -z "$tls_key" ]]; then
extra_options="$extra_options --tls-cert $tls_cert --tls-key $tls_key"
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ prefer_http_download = e:option(Flag, "prefer_http_download", translate("Prefer
prefer_http_download.description = translate("Prefer downloading files using HTTP instead of HTTPS protocol")
prefer_http_download.rmempty = false

redirect = e:option(Flag, "redirect", translate("Enable 302 Redirect"))
redirect.description = translate("Enable 302 redirect when possible")
redirect.rmempty = false

upload_buffer_size = e:option(Value, "upload_buffer_size", translate("Upload Buffer Size"))
upload_buffer_size.default = "16777216"
upload_buffer_size.datatype = "uinteger"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,9 @@ msgstr "使用 HTTP 下载"

msgid "Prefer downloading files using HTTP instead of HTTPS protocol"
msgstr "优先使用 HTTP 而不是 HTTPS 协议下载,低端设备上降低 CPU 占用"

msgid "Enable 302 Redirect"
msgstr "启用 302 重定向"

msgid "Enable 302 redirect when possible"
msgstr "在可能的情况下启用 302 重定向"
5 changes: 4 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ struct Opt {
/// Prefer downloading using HTTP protocol
#[arg(long)]
prefer_http_download: bool,
/// Enable 302 redirect when possible
#[arg(long, hide = true)]
redirect: bool,

#[command(subcommand)]
subcommands: Option<Commands>,
Expand Down Expand Up @@ -257,7 +260,7 @@ async fn main() -> anyhow::Result<()> {
.locksystem(MemLs::new())
.read_buf_size(opt.read_buffer_size)
.autoindex(opt.auto_index)
.redirect(false);
.redirect(opt.redirect);
if let Some(prefix) = opt.strip_prefix {
dav_server_builder = dav_server_builder.strip_prefix(prefix);
}
Expand Down

0 comments on commit fa4a5f3

Please sign in to comment.