From 20a36131611e909f2e47b33ed5873172cca496b6 Mon Sep 17 00:00:00 2001 From: sbwml <984419930@qq.com> Date: Fri, 9 Sep 2022 17:50:05 +0800 Subject: [PATCH 01/16] alist: bump to 3.0.0-beta.0 --- alist/Makefile | 23 ++++++----- alist/files/assets/circle_center.svg | 10 ----- alist/files/assets/http_can_circle.svg | 10 ----- ...ert-feat-clear-temp-file-while-start.patch | 38 ------------------- 4 files changed, 13 insertions(+), 68 deletions(-) delete mode 100644 alist/files/assets/circle_center.svg delete mode 100644 alist/files/assets/http_can_circle.svg delete mode 100644 alist/patches/0001-Revert-feat-clear-temp-file-while-start.patch diff --git a/alist/Makefile b/alist/Makefile index daf521ba..e376ebf9 100644 --- a/alist/Makefile +++ b/alist/Makefile @@ -7,13 +7,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=alist -PKG_VERSION:=2.6.4 -PKG_WEB_VERSION:=2.6.4 +PKG_VERSION:=3.0.0-beta.0 +PKG_WEB_VERSION:=3.0.0-beta.0 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://codeload.github.com/alist-org/alist/tar.gz/v$(PKG_VERSION)? -PKG_HASH:=3860f5cec5d809159c55498874c472386cd6142a932a5e7bbfb3b0f569e3e12b +PKG_HASH:=971f69bbc4fe550d4dc7f10a40290d48f8a019878ea4719da473b68297571804 PKG_LICENSE:=GPL-3.0 PKG_LICENSE_FILE:=LICENSE @@ -22,8 +22,8 @@ PKG_MAINTAINER:=sbwml define Download/$(PKG_NAME)-web FILE:=$(PKG_NAME)-web-$(PKG_WEB_VERSION).tar.gz URL_FILE:=dist.tar.gz - URL:=https://github.com/alist-org/web-v2/releases/download/$(PKG_WEB_VERSION)/ - HASH:=4189ce3c523e6b8f6bba55faefabc926f6ef793c8755c5c2a2d3f75532fb2243 + URL:=https://github.com/alist-org/alist-web/releases/download/$(PKG_WEB_VERSION)/ + HASH:=050abbc1568bd4098027a29f8956916a6f96fd69f8989e253d021deca579d32c endef PKG_CONFIG_DEPENDS:=CONFIG_ALIST_COMPRESS_UPX @@ -32,10 +32,13 @@ PKG_BUILD_DEPENDS:=golang/host PKG_BUILD_PARALLEL:=1 PKG_USE_MIPS16:=0 -GO_PKG:=github.com/Xhofe/alist -ALIST_PKG:=github.com/Xhofe/alist/conf +PKG_ALIST:=github.com/alist-org/alist/v3/internal/conf +GO_PKG:=github.com/alist-org/alist GO_PKG_LDFLAGS:=-w -s -GO_PKG_LDFLAGS_X:=$(ALIST_PKG).GitTag=v$(PKG_VERSION)-$(ARCH) +GO_PKG_LDFLAGS_X:= \ + $(PKG_ALIST).Version=v$(PKG_VERSION)-$(ARCH) \ + $(PKG_ALIST).WebVersion=$(PKG_WEB_VERSION) \ + $(PKG_ALIST).BuiltAt=$(shell date "+%F %T %z") include $(INCLUDE_DIR)/package.mk include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk @@ -66,8 +69,8 @@ endef define Build/Prepare $(call Build/Prepare/Default) $(eval $(call Download,$(PKG_NAME)-web)) - $(TAR) --strip-components=1 -C $(PKG_BUILD_DIR)/public -xzf $(DL_DIR)/$(PKG_NAME)-web-$(PKG_WEB_VERSION).tar.gz - $(CP) ./files/assets/. $(PKG_BUILD_DIR)/public/assets/ + $(TAR) --strip-components=1 -C $(PKG_BUILD_DIR)/public/dist -xzf $(DL_DIR)/$(PKG_NAME)-web-$(PKG_WEB_VERSION).tar.gz + $(CP) ./files/assets/. $(PKG_BUILD_DIR)/public/dist/assets/ endef define Build/Compile diff --git a/alist/files/assets/circle_center.svg b/alist/files/assets/circle_center.svg deleted file mode 100644 index bc49a26c..00000000 --- a/alist/files/assets/circle_center.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/alist/files/assets/http_can_circle.svg b/alist/files/assets/http_can_circle.svg deleted file mode 100644 index cab3c49f..00000000 --- a/alist/files/assets/http_can_circle.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/alist/patches/0001-Revert-feat-clear-temp-file-while-start.patch b/alist/patches/0001-Revert-feat-clear-temp-file-while-start.patch deleted file mode 100644 index 7aaf37d1..00000000 --- a/alist/patches/0001-Revert-feat-clear-temp-file-while-start.patch +++ /dev/null @@ -1,38 +0,0 @@ -From fdcb81f6ba8b8d7546a6742e9566487e12815499 Mon Sep 17 00:00:00 2001 -From: sbwml -Date: Thu, 28 Apr 2022 11:10:53 +0800 -Subject: [PATCH] Revert "feat: clear temp file while start" - -This reverts commit 24d031d57875d3c6a9624fa7334c6eac1c9111fb. ---- - bootstrap/conf.go | 7 +------ - 1 file changed, 1 insertion(+), 6 deletions(-) - -diff --git a/bootstrap/conf.go b/bootstrap/conf.go -index 5c9a1b3..f4d87d4 100644 ---- a/bootstrap/conf.go -+++ b/bootstrap/conf.go -@@ -7,7 +7,6 @@ import ( - log "github.com/sirupsen/logrus" - "io/ioutil" - "os" -- "path/filepath" - ) - - // InitConf init config -@@ -47,11 +46,7 @@ func InitConf() { - if !conf.Conf.Force { - confFromEnv() - } -- err := os.RemoveAll(filepath.Join(conf.Conf.TempDir)) -- if err != nil { -- log.Errorln("failed delete temp file:", err) -- } -- err = os.MkdirAll(conf.Conf.TempDir, 0700) -+ err := os.MkdirAll(conf.Conf.TempDir, 0700) - if err != nil { - log.Fatalf("create temp dir error: %s", err.Error()) - } --- -2.34.1 - From 4d00052697ad17c0a59602cc89a5dd868c77575e Mon Sep 17 00:00:00 2001 From: sbwml <984419930@qq.com> Date: Fri, 9 Sep 2022 19:22:50 +0800 Subject: [PATCH 02/16] luci-app-alist: update for v3 --- luci-app-alist/Makefile | 4 ++-- luci-app-alist/luasrc/model/cbi/alist.lua | 27 +++++++--------------- luci-app-alist/po/zh-cn/alist.po | 9 -------- luci-app-alist/root/etc/alist/data.db | Bin 28672 -> 36864 bytes luci-app-alist/root/etc/config/alist | 4 +--- luci-app-alist/root/etc/init.d/alist | 8 +++---- 6 files changed, 14 insertions(+), 38 deletions(-) diff --git a/luci-app-alist/Makefile b/luci-app-alist/Makefile index 11ebc459..27d4822d 100644 --- a/luci-app-alist/Makefile +++ b/luci-app-alist/Makefile @@ -6,11 +6,11 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-alist -PKG_VERSION:=1.0.4 +PKG_VERSION:=1.0.5 PKG_RELEASE:=1 LUCI_TITLE:=LuCI support for alist -LUCI_DEPENDS:=+alist +luci-compat +LUCI_DEPENDS:=+alist define Package/$(PKG_NAME)/conffiles /etc/alist diff --git a/luci-app-alist/luasrc/model/cbi/alist.lua b/luci-app-alist/luasrc/model/cbi/alist.lua index be84605f..9a15cbde 100644 --- a/luci-app-alist/luasrc/model/cbi/alist.lua +++ b/luci-app-alist/luasrc/model/cbi/alist.lua @@ -2,10 +2,10 @@ local m, s local sys = require "luci.sys" if sys.call("pidof alist >/dev/null") == 0 then - local password = sys.exec("/usr/bin/alist --conf /etc/alist/config.json -password | awk '{print $3}'") - m = Map("alist", translate("Alist"), translate("A file list program that supports multiple storage.") .. " " .. translate("manage password:") .. "" .. password .. "" .. "
" .. [[]] .. translate("User Manual") .. [[]]) + local password = sys.exec("/usr/bin/alist --conf /etc/alist/config.json -password |& tail -1 | awk -F': ' '{print $2}'") + m = Map("alist", translate("Alist"), translate("A file list program that supports multiple storage.") .. " " .. translate("manage password:") .. "" .. password .. "" .. "
" .. [[]] .. translate("User Manual") .. [[]]) else - m = Map("alist", translate("Alist"), translate("A file list program that supports multiple storage.") .. "
" .. [[]] .. translate("User Manual") .. [[]]) + m = Map("alist", translate("Alist"), translate("A file list program that supports multiple storage.") .. "
" .. [[]] .. translate("User Manual") .. [[]]) end m:section(SimpleSection).template = "alist_status" @@ -21,6 +21,11 @@ o = s:option(Value, "port", translate("Port")) o.datatype = "and(port,min(1))" o.rmempty = false +o = s:option(Value, "temp_dir", translate("Cache directory")) +o.datatype = "string" +o.default = "/tmp/alist" +o.rmempty = false + o = s:option(Flag, "ssl", translate("Enable SSL")) o.rmempty=false @@ -34,20 +39,4 @@ o:depends("ssl", "1") o.datatype = "string" o.rmempty = true -s = m:section(TypedSection, "alist", translate("Cache settings")) -s.addremove = false -s.anonymous = true - -o = s:option(Value, "expiration", translate("Cache invalidation time (unit: minutes)")) -o.datatype = "and(uinteger,min(1))" -o.rmempty = false - -o = s:option(Value, "cleanup_interval", translate("Clear the invalidation cache interval (unit: minutes)")) -o.datatype = "and(uinteger,min(1))" -o.rmempty = false - -o = s:option(Value, "temp_dir", translate("Cache directory")) -o.datatype = "string" -o.rmempty = false - return m diff --git a/luci-app-alist/po/zh-cn/alist.po b/luci-app-alist/po/zh-cn/alist.po index 4016647d..f8d5e46c 100644 --- a/luci-app-alist/po/zh-cn/alist.po +++ b/luci-app-alist/po/zh-cn/alist.po @@ -34,15 +34,6 @@ msgstr "SSL 密钥" msgid "SSL key file path" msgstr "SSL 密钥文件路径" -msgid "Cache settings" -msgstr "缓存设置" - -msgid "Cache invalidation time (unit: minutes)" -msgstr "缓存失效时间(分钟)" - -msgid "Clear the invalidation cache interval (unit: minutes)" -msgstr "清理失效缓存间隔(分钟)" - msgid "Cache directory" msgstr "缓存目录" diff --git a/luci-app-alist/root/etc/alist/data.db b/luci-app-alist/root/etc/alist/data.db index 63756e27ce21b0bf278af4d3ae8d1387034eec05..920b05455ad2d5ec869ea2e8708775ccde293c45 100644 GIT binary patch literal 36864 zcmeI5-ESLN6~JfgG#Mwg-O^@F$d+}ov|Dd)>^P2-G!Ug}lUCif+Yg#umA10SGuPuu zX66nv*N#IIL6=4FutMTtA9>($#RK9GKtfu?1LB3{afO6d@ zUV?|*KKP7RB4zLH#ZO+7hQ`*V_`Ss0vGtQf?dNCcVHXlW0!RP}AOR$R1dsp{_`fCa zd}U-Lb?K7)UY@HJi#AI><=k|P61=mv{l2Dh?ZL*{!;SRAwX3%`(&fJ1a{6Lp= zoHjWrH&m-m+l?Bv-1afwbvttAa+5iJyUXxc9mbgsrv~*%xoW9Kw|Vcu%{yxk9;I(> zJZhaP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ist: fix build & apply upstream patches --- alist/Makefile | 3 +- .../001-fix-error-if-use-abs-temp-path.patch | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 alist/patches/001-fix-error-if-use-abs-temp-path.patch diff --git a/alist/Makefile b/alist/Makefile index e376ebf9..d5a5be42 100644 --- a/alist/Makefile +++ b/alist/Makefile @@ -37,8 +37,7 @@ GO_PKG:=github.com/alist-org/alist GO_PKG_LDFLAGS:=-w -s GO_PKG_LDFLAGS_X:= \ $(PKG_ALIST).Version=v$(PKG_VERSION)-$(ARCH) \ - $(PKG_ALIST).WebVersion=$(PKG_WEB_VERSION) \ - $(PKG_ALIST).BuiltAt=$(shell date "+%F %T %z") + $(PKG_ALIST).WebVersion=$(PKG_WEB_VERSION) include $(INCLUDE_DIR)/package.mk include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk diff --git a/alist/patches/001-fix-error-if-use-abs-temp-path.patch b/alist/patches/001-fix-error-if-use-abs-temp-path.patch new file mode 100644 index 00000000..70358d3a --- /dev/null +++ b/alist/patches/001-fix-error-if-use-abs-temp-path.patch @@ -0,0 +1,33 @@ +From 4af91241627909fcf34cc6e4f7abd32a2781f321 Mon Sep 17 00:00:00 2001 +From: Noah Hsu +Date: Fri, 9 Sep 2022 18:50:54 +0800 +Subject: [PATCH] fix: error if use abs temp path (close #1624) + +--- + internal/bootstrap/config.go | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) + +diff --git a/internal/bootstrap/config.go b/internal/bootstrap/config.go +index ad9f64926..3e72a98fd 100644 +--- a/internal/bootstrap/config.go ++++ b/internal/bootstrap/config.go +@@ -48,16 +48,14 @@ func InitConfig() { + confFromEnv() + } + // convert abs path +- var absPath string +- var err error + if !filepath.IsAbs(conf.Conf.TempDir) { +- absPath, err = filepath.Abs(conf.Conf.TempDir) ++ absPath, err := filepath.Abs(conf.Conf.TempDir) + if err != nil { + log.Fatalf("get abs path error: %+v", err) + } ++ conf.Conf.TempDir = absPath + } +- conf.Conf.TempDir = absPath +- err = os.RemoveAll(filepath.Join(conf.Conf.TempDir)) ++ err := os.RemoveAll(filepath.Join(conf.Conf.TempDir)) + if err != nil { + log.Errorln("failed delete temp file:", err) + } From b94090d773e96600fc380dd6789f272501cb70d3 Mon Sep 17 00:00:00 2001 From: sbwml <984419930@qq.com> Date: Fri, 9 Sep 2022 20:44:47 +0800 Subject: [PATCH 04/16] luci-app-alist: datatype must depend on 'luci-compat' --- luci-app-alist/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-alist/Makefile b/luci-app-alist/Makefile index 27d4822d..b7ab3f5d 100644 --- a/luci-app-alist/Makefile +++ b/luci-app-alist/Makefile @@ -10,7 +10,7 @@ PKG_VERSION:=1.0.5 PKG_RELEASE:=1 LUCI_TITLE:=LuCI support for alist -LUCI_DEPENDS:=+alist +LUCI_DEPENDS:=+alist +luci-compat define Package/$(PKG_NAME)/conffiles /etc/alist From 3eb834c9b0af3b0ac314297f595a735447c6c9b2 Mon Sep 17 00:00:00 2001 From: sbwml Date: Sat, 10 Sep 2022 10:01:20 +0800 Subject: [PATCH 05/16] luci-app-alist: fix password printing * daemon.info uwsgi-luci: syntax error: unexpected "&" --- luci-app-alist/luasrc/model/cbi/alist.lua | 2 +- luci-app-alist/root/etc/alist/data.db | Bin 36864 -> 36864 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/luci-app-alist/luasrc/model/cbi/alist.lua b/luci-app-alist/luasrc/model/cbi/alist.lua index 9a15cbde..f94fda61 100644 --- a/luci-app-alist/luasrc/model/cbi/alist.lua +++ b/luci-app-alist/luasrc/model/cbi/alist.lua @@ -2,7 +2,7 @@ local m, s local sys = require "luci.sys" if sys.call("pidof alist >/dev/null") == 0 then - local password = sys.exec("/usr/bin/alist --conf /etc/alist/config.json -password |& tail -1 | awk -F': ' '{print $2}'") + local password = sys.exec("/usr/bin/alist --conf /etc/alist/config.json password 2>&1 | tail -1 | awk -F': ' '{print $2}'") m = Map("alist", translate("Alist"), translate("A file list program that supports multiple storage.") .. " " .. translate("manage password:") .. "" .. password .. "" .. "
" .. [[]] .. translate("User Manual") .. [[]]) else m = Map("alist", translate("Alist"), translate("A file list program that supports multiple storage.") .. "
" .. [[]] .. translate("User Manual") .. [[]]) diff --git a/luci-app-alist/root/etc/alist/data.db b/luci-app-alist/root/etc/alist/data.db index 920b05455ad2d5ec869ea2e8708775ccde293c45..f310c33ab20fbe17f3e77deda68b47b19e535020 100644 GIT binary patch delta 147 zcmZozz|^pSX@WGP!9*EnMuUwBOY-?xdA~C7oASx4ROn*J65cXKf; delta 143 zcmZozz|^pSX@WGP&O{k!MxBibOY(VGc)v36oASxc#qQv~z4`6n{)=O$+6#V6vH$=8 From 743a3a3bc1a5d05854ddd8a6f18d2350272c3da8 Mon Sep 17 00:00:00 2001 From: sbwml <984419930@qq.com> Date: Sat, 10 Sep 2022 11:12:30 +0800 Subject: [PATCH 06/16] luci-app-alist: Add inbound access control --- luci-app-alist/luasrc/model/cbi/alist.lua | 17 ++++++----- luci-app-alist/po/zh-cn/alist.po | 4 +++ luci-app-alist/root/etc/init.d/alist | 37 ++++++++++++++++++++++- 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/luci-app-alist/luasrc/model/cbi/alist.lua b/luci-app-alist/luasrc/model/cbi/alist.lua index f94fda61..8bdb60c7 100644 --- a/luci-app-alist/luasrc/model/cbi/alist.lua +++ b/luci-app-alist/luasrc/model/cbi/alist.lua @@ -21,22 +21,23 @@ o = s:option(Value, "port", translate("Port")) o.datatype = "and(port,min(1))" o.rmempty = false -o = s:option(Value, "temp_dir", translate("Cache directory")) -o.datatype = "string" -o.default = "/tmp/alist" -o.rmempty = false - o = s:option(Flag, "ssl", translate("Enable SSL")) o.rmempty=false o = s:option(Value,"ssl_cert", translate("SSL cert"), translate("SSL certificate file path")) +o.datatype = "file" o:depends("ssl", "1") -o.datatype = "string" -o.rmempty = true o = s:option(Value,"ssl_key", translate("SSL key"), translate("SSL key file path")) +o.datatype = "file" o:depends("ssl", "1") + +o = s:option(Flag, "allow_wan", translate("Allow Access From Internet")) +o.rmempty = false + +o = s:option(Value, "temp_dir", translate("Cache directory")) o.datatype = "string" -o.rmempty = true +o.default = "/tmp/alist" +o.rmempty = false return m diff --git a/luci-app-alist/po/zh-cn/alist.po b/luci-app-alist/po/zh-cn/alist.po index f8d5e46c..3f59f8c6 100644 --- a/luci-app-alist/po/zh-cn/alist.po +++ b/luci-app-alist/po/zh-cn/alist.po @@ -51,3 +51,7 @@ msgstr "网络存储" msgid "User Manual" msgstr "用户手册" + +#: luci-app-alist/luasrc/model/cbi/alist.lua:35 +msgid "Allow Access From Internet" +msgstr "允许从外网访问" diff --git a/luci-app-alist/root/etc/init.d/alist b/luci-app-alist/root/etc/init.d/alist index fe448e12..3c40c036 100755 --- a/luci-app-alist/root/etc/init.d/alist +++ b/luci-app-alist/root/etc/init.d/alist @@ -12,6 +12,28 @@ get_config() { config_get ssl $1 ssl 0 config_get ssl_cert $1 ssl_cert "" config_get ssl_key $1 ssl_key "" + config_get allow_wan $1 allow_wan 0 + config_load network + config_get lan_addr lan ipaddr "0.0.0.0" +} + +set_firewall() { + if [ "$external_access" = "allow" ]; then + uci -q delete firewall.alist + uci set firewall.alist=rule + uci set firewall.alist.name="alist" + uci set firewall.alist.target="ACCEPT" + uci set firewall.alist.src="wan" + uci set firewall.alist.proto="tcp" + uci set firewall.alist.dest_port="$port" + uci set firewall.alist.enabled="1" + uci commit firewall + /etc/init.d/firewall reload >/dev/null 2>&1 + elif [ "$external_access" = "deny" ]; then + uci -q delete firewall.alist + uci commit firewall + /etc/init.d/firewall reload >/dev/null 2>&1 + fi } start_service() { @@ -24,8 +46,16 @@ start_service() { else SSL=false fi + if [ "$allow_wan" -eq "1" ]; then + listen_addr="0.0.0.0" + external_access="allow" + else + listen_addr=$lan_addr + external_access="deny" + fi + set_firewall cat > $CONFIG < Date: Sat, 10 Sep 2022 11:32:08 +0800 Subject: [PATCH 07/16] luci-app-alist: disable password printing for now --- luci-app-alist/luasrc/model/cbi/alist.lua | 16 ++++++++-------- luci-app-alist/po/zh-cn/alist.po | 3 +++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/luci-app-alist/luasrc/model/cbi/alist.lua b/luci-app-alist/luasrc/model/cbi/alist.lua index 8bdb60c7..59bb8154 100644 --- a/luci-app-alist/luasrc/model/cbi/alist.lua +++ b/luci-app-alist/luasrc/model/cbi/alist.lua @@ -1,12 +1,12 @@ local m, s -local sys = require "luci.sys" - -if sys.call("pidof alist >/dev/null") == 0 then - local password = sys.exec("/usr/bin/alist --conf /etc/alist/config.json password 2>&1 | tail -1 | awk -F': ' '{print $2}'") - m = Map("alist", translate("Alist"), translate("A file list program that supports multiple storage.") .. " " .. translate("manage password:") .. "" .. password .. "" .. "
" .. [[]] .. translate("User Manual") .. [[]]) -else - m = Map("alist", translate("Alist"), translate("A file list program that supports multiple storage.") .. "
" .. [[]] .. translate("User Manual") .. [[]]) -end +--local sys = require "luci.sys" + +--if sys.call("pidof alist >/dev/null") == 0 then +-- local password = sys.exec("/usr/bin/alist --conf /etc/alist/config.json password 2>&1 | tail -1 | awk -F': ' '{print $2}'") +-- m = Map("alist", translate("Alist"), translate("A file list program that supports multiple storage.") .. " " .. translate("manage password:") .. "" .. password .. "" .. "
" .. [[]] .. translate("User Manual") .. [[]]) +--else + m = Map("alist", translate("Alist"), translate("A file list program that supports multiple storage.") .. translate("Default username and password:") .. "admin / admin" .. "
" .. [[]] .. translate("User Manual") .. [[]]) +--end m:section(SimpleSection).template = "alist_status" diff --git a/luci-app-alist/po/zh-cn/alist.po b/luci-app-alist/po/zh-cn/alist.po index 3f59f8c6..db8ec745 100644 --- a/luci-app-alist/po/zh-cn/alist.po +++ b/luci-app-alist/po/zh-cn/alist.po @@ -55,3 +55,6 @@ msgstr "用户手册" #: luci-app-alist/luasrc/model/cbi/alist.lua:35 msgid "Allow Access From Internet" msgstr "允许从外网访问" + +msgid "Default username and password:" +msgstr "默认用户名和密码:" From d927bedd7662b1bc2e4923f57317dda334fc0d75 Mon Sep 17 00:00:00 2001 From: sbwml <984419930@qq.com> Date: Sat, 10 Sep 2022 11:37:25 +0800 Subject: [PATCH 08/16] alist: add patches from upstream * fix: if use down proxy url --- .../002-fix-if-use-down-proxy-url.patch | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 alist/patches/002-fix-if-use-down-proxy-url.patch diff --git a/alist/patches/002-fix-if-use-down-proxy-url.patch b/alist/patches/002-fix-if-use-down-proxy-url.patch new file mode 100644 index 00000000..30c44450 --- /dev/null +++ b/alist/patches/002-fix-if-use-down-proxy-url.patch @@ -0,0 +1,31 @@ +From 5ad3849bb635b6f339c4d1d5f648882e840c9189 Mon Sep 17 00:00:00 2001 +From: Noah Hsu +Date: Fri, 9 Sep 2022 20:54:11 +0800 +Subject: [PATCH] fix: if use down proxy url + +--- + server/handles/down.go | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/server/handles/down.go b/server/handles/down.go +index eb9d04a47..bbe0a30b3 100644 +--- a/server/handles/down.go ++++ b/server/handles/down.go +@@ -52,7 +52,7 @@ func Proxy(c *gin.Context) { + downProxyUrl := storage.GetStorage().DownProxyUrl + if downProxyUrl != "" { + _, ok := c.GetQuery("d") +- if ok { ++ if !ok { + URL := fmt.Sprintf("%s%s?sign=%s", + strings.Split(downProxyUrl, "\n")[0], + utils.EncodePath(rawPath, true), +@@ -103,7 +103,7 @@ func shouldProxy(storage driver.Driver, filename string) bool { + // 4. proxy_types + // solution: text_file + shouldProxy() + func canProxy(storage driver.Driver, filename string) bool { +- if storage.Config().MustProxy() || storage.GetStorage().WebProxy { ++ if storage.Config().MustProxy() || storage.GetStorage().WebProxy || storage.GetStorage().WebdavProxy() { + return true + } + if utils.SliceContains(conf.TypesMap[conf.ProxyTypes], utils.Ext(filename)) { From 6cfba794ab02d8b85cf62f79bf4fd5cd71bbee2d Mon Sep 17 00:00:00 2001 From: sbwml <984419930@qq.com> Date: Sat, 10 Sep 2022 17:43:20 +0800 Subject: [PATCH 09/16] alist: bump to v3.0.0-beta.1 --- alist/Makefile | 4 +-- .../001-fix-error-if-use-abs-temp-path.patch | 33 ------------------- .../002-fix-if-use-down-proxy-url.patch | 31 ----------------- 3 files changed, 2 insertions(+), 66 deletions(-) delete mode 100644 alist/patches/001-fix-error-if-use-abs-temp-path.patch delete mode 100644 alist/patches/002-fix-if-use-down-proxy-url.patch diff --git a/alist/Makefile b/alist/Makefile index d5a5be42..4bd2d7fd 100644 --- a/alist/Makefile +++ b/alist/Makefile @@ -7,13 +7,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=alist -PKG_VERSION:=3.0.0-beta.0 +PKG_VERSION:=3.0.0-beta.1 PKG_WEB_VERSION:=3.0.0-beta.0 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://codeload.github.com/alist-org/alist/tar.gz/v$(PKG_VERSION)? -PKG_HASH:=971f69bbc4fe550d4dc7f10a40290d48f8a019878ea4719da473b68297571804 +PKG_HASH:=ee23dae35de550c4c829d869d76b777a5138bcf8de003853dd3f5344bcf6f381 PKG_LICENSE:=GPL-3.0 PKG_LICENSE_FILE:=LICENSE diff --git a/alist/patches/001-fix-error-if-use-abs-temp-path.patch b/alist/patches/001-fix-error-if-use-abs-temp-path.patch deleted file mode 100644 index 70358d3a..00000000 --- a/alist/patches/001-fix-error-if-use-abs-temp-path.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 4af91241627909fcf34cc6e4f7abd32a2781f321 Mon Sep 17 00:00:00 2001 -From: Noah Hsu -Date: Fri, 9 Sep 2022 18:50:54 +0800 -Subject: [PATCH] fix: error if use abs temp path (close #1624) - ---- - internal/bootstrap/config.go | 8 +++----- - 1 file changed, 3 insertions(+), 5 deletions(-) - -diff --git a/internal/bootstrap/config.go b/internal/bootstrap/config.go -index ad9f64926..3e72a98fd 100644 ---- a/internal/bootstrap/config.go -+++ b/internal/bootstrap/config.go -@@ -48,16 +48,14 @@ func InitConfig() { - confFromEnv() - } - // convert abs path -- var absPath string -- var err error - if !filepath.IsAbs(conf.Conf.TempDir) { -- absPath, err = filepath.Abs(conf.Conf.TempDir) -+ absPath, err := filepath.Abs(conf.Conf.TempDir) - if err != nil { - log.Fatalf("get abs path error: %+v", err) - } -+ conf.Conf.TempDir = absPath - } -- conf.Conf.TempDir = absPath -- err = os.RemoveAll(filepath.Join(conf.Conf.TempDir)) -+ err := os.RemoveAll(filepath.Join(conf.Conf.TempDir)) - if err != nil { - log.Errorln("failed delete temp file:", err) - } diff --git a/alist/patches/002-fix-if-use-down-proxy-url.patch b/alist/patches/002-fix-if-use-down-proxy-url.patch deleted file mode 100644 index 30c44450..00000000 --- a/alist/patches/002-fix-if-use-down-proxy-url.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 5ad3849bb635b6f339c4d1d5f648882e840c9189 Mon Sep 17 00:00:00 2001 -From: Noah Hsu -Date: Fri, 9 Sep 2022 20:54:11 +0800 -Subject: [PATCH] fix: if use down proxy url - ---- - server/handles/down.go | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/server/handles/down.go b/server/handles/down.go -index eb9d04a47..bbe0a30b3 100644 ---- a/server/handles/down.go -+++ b/server/handles/down.go -@@ -52,7 +52,7 @@ func Proxy(c *gin.Context) { - downProxyUrl := storage.GetStorage().DownProxyUrl - if downProxyUrl != "" { - _, ok := c.GetQuery("d") -- if ok { -+ if !ok { - URL := fmt.Sprintf("%s%s?sign=%s", - strings.Split(downProxyUrl, "\n")[0], - utils.EncodePath(rawPath, true), -@@ -103,7 +103,7 @@ func shouldProxy(storage driver.Driver, filename string) bool { - // 4. proxy_types - // solution: text_file + shouldProxy() - func canProxy(storage driver.Driver, filename string) bool { -- if storage.Config().MustProxy() || storage.GetStorage().WebProxy { -+ if storage.Config().MustProxy() || storage.GetStorage().WebProxy || storage.GetStorage().WebdavProxy() { - return true - } - if utils.SliceContains(conf.TypesMap[conf.ProxyTypes], utils.Ext(filename)) { From 9656557fdfd1a8a4bb71af3d0ac3195d786f3fa3 Mon Sep 17 00:00:00 2001 From: sbwml <984419930@qq.com> Date: Mon, 12 Sep 2022 09:09:08 +0800 Subject: [PATCH 10/16] alist: bump to v3.0.0-beta.2 --- alist/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/alist/Makefile b/alist/Makefile index 4bd2d7fd..ff61c6d2 100644 --- a/alist/Makefile +++ b/alist/Makefile @@ -7,13 +7,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=alist -PKG_VERSION:=3.0.0-beta.1 -PKG_WEB_VERSION:=3.0.0-beta.0 +PKG_VERSION:=3.0.0-beta.2 +PKG_WEB_VERSION:=3.0.0-beta.2 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://codeload.github.com/alist-org/alist/tar.gz/v$(PKG_VERSION)? -PKG_HASH:=ee23dae35de550c4c829d869d76b777a5138bcf8de003853dd3f5344bcf6f381 +PKG_HASH:=4d8ad4c02db09b117823de7dfbf3ac3dea5bd56613e91899688053fa220acf21 PKG_LICENSE:=GPL-3.0 PKG_LICENSE_FILE:=LICENSE @@ -23,7 +23,7 @@ define Download/$(PKG_NAME)-web FILE:=$(PKG_NAME)-web-$(PKG_WEB_VERSION).tar.gz URL_FILE:=dist.tar.gz URL:=https://github.com/alist-org/alist-web/releases/download/$(PKG_WEB_VERSION)/ - HASH:=050abbc1568bd4098027a29f8956916a6f96fd69f8989e253d021deca579d32c + HASH:=98d84ae80f27da0aa0216f14b0ee3063fe735fe3d2fe894494e07fb3e70b7d46 endef PKG_CONFIG_DEPENDS:=CONFIG_ALIST_COMPRESS_UPX From 641a8a91dc986af20be8bc637ac5a49db426a8d3 Mon Sep 17 00:00:00 2001 From: sbwml <984419930@qq.com> Date: Mon, 12 Sep 2022 11:01:02 +0800 Subject: [PATCH 11/16] luci-app-alist: Add log preview support --- luci-app-alist/luasrc/controller/alist.lua | 19 ++++++++++-- .../luasrc/model/cbi/{alist.lua => basic.lua} | 8 +++-- luci-app-alist/luasrc/model/cbi/log.lua | 5 ++++ luci-app-alist/luasrc/view/alist_log.htm | 29 +++++++++++++++++++ luci-app-alist/luasrc/view/alist_status.htm | 6 ++-- luci-app-alist/po/zh-cn/alist.po | 23 +++++++++------ luci-app-alist/root/etc/init.d/alist | 8 ++++- 7 files changed, 81 insertions(+), 17 deletions(-) rename luci-app-alist/luasrc/model/cbi/{alist.lua => basic.lua} (90%) create mode 100644 luci-app-alist/luasrc/model/cbi/log.lua create mode 100644 luci-app-alist/luasrc/view/alist_log.htm diff --git a/luci-app-alist/luasrc/controller/alist.lua b/luci-app-alist/luasrc/controller/alist.lua index 1bb66401..bce25f97 100644 --- a/luci-app-alist/luasrc/controller/alist.lua +++ b/luci-app-alist/luasrc/controller/alist.lua @@ -5,9 +5,16 @@ function index() return end + local page = entry({"admin", "nas", "alist"}, alias("admin", "nas", "alist", "basic"), _("Alist"), 20) + page.dependent = true + page.acl_depends = { "luci-app-alist" } + entry({"admin", "nas"}, firstchild(), "NAS", 44).dependent = false - entry({"admin", "nas", "alist"}, cbi("alist"), _("Alist"), 20).dependent = true - entry({"admin", "nas", "alist_status"}, call("alist_status")) + entry({"admin", "nas", "alist", "basic"}, cbi("alist/basic"), _("Basic Setting"), 1).leaf = true + entry({"admin", "nas", "alist", "log"}, cbi("alist/log"), _("Logs"), 2).leaf = true + entry({"admin", "nas", "alist", "alist_status"}, call("alist_status")).leaf = true + entry({"admin", "nas", "alist", "get_log"}, call("get_log")).leaf = true + entry({"admin", "nas", "alist", "clear_log"}, call("clear_log")).leaf = true end function alist_status() @@ -23,3 +30,11 @@ function alist_status() luci.http.prepare_content("application/json") luci.http.write_json(status) end + +function get_log() + luci.http.write(luci.sys.exec("cat $(uci -q get alist.@alist[0].temp_dir)/alist.log")) +end + +function clear_log() + luci.sys.call("cat /dev/null > $(uci -q get alist.@alist[0].temp_dir)/alist.log") +end diff --git a/luci-app-alist/luasrc/model/cbi/alist.lua b/luci-app-alist/luasrc/model/cbi/basic.lua similarity index 90% rename from luci-app-alist/luasrc/model/cbi/alist.lua rename to luci-app-alist/luasrc/model/cbi/basic.lua index 59bb8154..500d8b7b 100644 --- a/luci-app-alist/luasrc/model/cbi/alist.lua +++ b/luci-app-alist/luasrc/model/cbi/basic.lua @@ -8,9 +8,9 @@ local m, s m = Map("alist", translate("Alist"), translate("A file list program that supports multiple storage.") .. translate("Default username and password:") .. "admin / admin" .. "
" .. [[]] .. translate("User Manual") .. [[]]) --end -m:section(SimpleSection).template = "alist_status" +m:section(SimpleSection).template = "alist/alist_status" -s = m:section(TypedSection, "alist", translate("Global settings")) +s = m:section(TypedSection, "alist") s.addremove = false s.anonymous = true @@ -21,6 +21,10 @@ o = s:option(Value, "port", translate("Port")) o.datatype = "and(port,min(1))" o.rmempty = false +o = s:option(Flag, "log", translate("Enable Logs")) +o.default = 1 +o.rmempty = false + o = s:option(Flag, "ssl", translate("Enable SSL")) o.rmempty=false diff --git a/luci-app-alist/luasrc/model/cbi/log.lua b/luci-app-alist/luasrc/model/cbi/log.lua new file mode 100644 index 00000000..4b6c36f8 --- /dev/null +++ b/luci-app-alist/luasrc/model/cbi/log.lua @@ -0,0 +1,5 @@ +m = Map("alist") + +m:append(Template("alist/alist_log")) + +return m diff --git a/luci-app-alist/luasrc/view/alist_log.htm b/luci-app-alist/luasrc/view/alist_log.htm new file mode 100644 index 00000000..b77932e4 --- /dev/null +++ b/luci-app-alist/luasrc/view/alist_log.htm @@ -0,0 +1,29 @@ + +
+ + +
diff --git a/luci-app-alist/luasrc/view/alist_status.htm b/luci-app-alist/luasrc/view/alist_status.htm index 42b1d1a3..fc11c224 100644 --- a/luci-app-alist/luasrc/view/alist_status.htm +++ b/luci-app-alist/luasrc/view/alist_status.htm @@ -9,7 +9,7 @@ %> + +<%=self.value%> +<%+cbi/valuefooter%> \ No newline at end of file diff --git a/luci-app-alist/po/zh-cn/alist.po b/luci-app-alist/po/zh-cn/alist.po index 319329e7..2008c207 100644 --- a/luci-app-alist/po/zh-cn/alist.po +++ b/luci-app-alist/po/zh-cn/alist.po @@ -10,9 +10,6 @@ msgstr "打开 Web 界面" msgid "A file list program that supports multiple storage." msgstr "一款支持多种存储的目录文件列表程序。" -msgid "manage password:" -msgstr "管理密码:" - msgid "Basic Setting" msgstr "基本设置" @@ -55,11 +52,23 @@ msgstr "用户手册" msgid "Allow Access From Internet" msgstr "允许从外网访问" -msgid "Default username and password:" -msgstr "默认用户名和密码:" - msgid "Enable Logs" msgstr "启用日志" msgid "Clear logs" msgstr "清空日志" + +msgid "View Password" +msgstr "查看密码" + +msgid "Username:" +msgstr "用户名:" + +msgid "Password:" +msgstr "密码:" + +msgid "Reading..." +msgstr "读取中..." + +msgid "Read" +msgstr "读取" From fb48d47f2ab56f5cc02212b78b909f657644ed69 Mon Sep 17 00:00:00 2001 From: sbwml <984419930@qq.com> Date: Thu, 15 Sep 2022 20:37:07 +0800 Subject: [PATCH 16/16] alist: bump to v3.0.0-rc.0 --- alist/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/alist/Makefile b/alist/Makefile index ff61c6d2..47e28d15 100644 --- a/alist/Makefile +++ b/alist/Makefile @@ -7,13 +7,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=alist -PKG_VERSION:=3.0.0-beta.2 -PKG_WEB_VERSION:=3.0.0-beta.2 +PKG_VERSION:=3.0.0-rc.0 +PKG_WEB_VERSION:=3.0.0-rc.0 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://codeload.github.com/alist-org/alist/tar.gz/v$(PKG_VERSION)? -PKG_HASH:=4d8ad4c02db09b117823de7dfbf3ac3dea5bd56613e91899688053fa220acf21 +PKG_HASH:=659ddabc87ceca834a09320c6dd87ab24b16247b992d297b12d9ea4771bed9bf PKG_LICENSE:=GPL-3.0 PKG_LICENSE_FILE:=LICENSE @@ -23,7 +23,7 @@ define Download/$(PKG_NAME)-web FILE:=$(PKG_NAME)-web-$(PKG_WEB_VERSION).tar.gz URL_FILE:=dist.tar.gz URL:=https://github.com/alist-org/alist-web/releases/download/$(PKG_WEB_VERSION)/ - HASH:=98d84ae80f27da0aa0216f14b0ee3063fe735fe3d2fe894494e07fb3e70b7d46 + HASH:=55ad8bf4e39e48ff1a0a503783c4e6922e102810cae6dcdf99cec91263c79414 endef PKG_CONFIG_DEPENDS:=CONFIG_ALIST_COMPRESS_UPX