diff --git a/Cargo.lock b/Cargo.lock index 341de29603..a02d0a0183 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -254,9 +254,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.1.8" +version = "4.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d7ae14b20b94cb02149ed21a86c423859cbe18dc7ed69845cace50e52b40a5" +checksum = "9a9d6ada83c1edcce028902ea27dd929069c70df4c7600b131b4d9a1ad2879cc" dependencies = [ "bitflags", "clap_derive", @@ -270,9 +270,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.1.8" +version = "4.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44bec8e5c9d09e439c4335b1af0abaab56dcf3b94999a936e1bb47b9134288f0" +checksum = "fddf67631444a3a3e3e5ac51c36a5e01335302de677bd78759eaa90ab1f46644" dependencies = [ "heck", "proc-macro-error", @@ -283,9 +283,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "350b9cf31731f9957399229e9b2adc51eeabdfbe9d71d9a0552275fd12710d09" +checksum = "033f6b7a4acb1f358c742aaca805c939ee73b4c6209ae4318ec7aca81c42e646" dependencies = [ "os_str_bytes", ] @@ -1068,10 +1068,11 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.6" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3" +checksum = "76e86b86ae312accbf05ade23ce76b625e0e47a255712b7414037385a1c05380" dependencies = [ + "hermit-abi 0.3.1", "libc", "windows-sys 0.45.0", ] @@ -2534,12 +2535,11 @@ checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" [[package]] name = "walkdir" -version = "2.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698" dependencies = [ "same-file", - "winapi", "winapi-util", ] diff --git a/openwrt/aliyundrive-webdav/files/aliyundrive-webdav.config b/openwrt/aliyundrive-webdav/files/aliyundrive-webdav.config index c1626dbcf8..b480cea8f7 100644 --- a/openwrt/aliyundrive-webdav/files/aliyundrive-webdav.config +++ b/openwrt/aliyundrive-webdav/files/aliyundrive-webdav.config @@ -17,3 +17,4 @@ config server option tls_key '' option skip_upload_same_size '0' option prefer_http_download '0' + option redirect '0' diff --git a/openwrt/aliyundrive-webdav/files/aliyundrive-webdav.init b/openwrt/aliyundrive-webdav/files/aliyundrive-webdav.init index 65b3a67a85..c7895fcd10 100755 --- a/openwrt/aliyundrive-webdav/files/aliyundrive-webdav.init +++ b/openwrt/aliyundrive-webdav/files/aliyundrive-webdav.init @@ -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 diff --git a/openwrt/luci-app-aliyundrive-webdav/luasrc/model/cbi/aliyundrive-webdav/client.lua b/openwrt/luci-app-aliyundrive-webdav/luasrc/model/cbi/aliyundrive-webdav/client.lua index bd0241a5b2..ce745ba3e0 100644 --- a/openwrt/luci-app-aliyundrive-webdav/luasrc/model/cbi/aliyundrive-webdav/client.lua +++ b/openwrt/luci-app-aliyundrive-webdav/luasrc/model/cbi/aliyundrive-webdav/client.lua @@ -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" diff --git a/openwrt/luci-app-aliyundrive-webdav/po/zh-cn/aliyundrive-webdav.po b/openwrt/luci-app-aliyundrive-webdav/po/zh-cn/aliyundrive-webdav.po index 12ad978019..53b4473f72 100644 --- a/openwrt/luci-app-aliyundrive-webdav/po/zh-cn/aliyundrive-webdav.po +++ b/openwrt/luci-app-aliyundrive-webdav/po/zh-cn/aliyundrive-webdav.po @@ -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 重定向" diff --git a/src/main.rs b/src/main.rs index 3916fcc5a5..6ff3833b5e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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, @@ -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); }