diff --git a/internal/bootstrap/data/setting.go b/internal/bootstrap/data/setting.go index da38d59d..dcf8d76c 100644 --- a/internal/bootstrap/data/setting.go +++ b/internal/bootstrap/data/setting.go @@ -117,15 +117,18 @@ func InitialSettings() []model.SettingItem { {Key: conf.CustomizeHead, Value: ``, Type: conf.TypeText, Group: model.GLOBAL, Flag: model.PRIVATE}, {Key: conf.CustomizeBody, Type: conf.TypeText, Group: model.GLOBAL, Flag: model.PRIVATE}, {Key: conf.LinkExpiration, Value: "0", Type: conf.TypeNumber, Group: model.GLOBAL, Flag: model.PRIVATE}, + {Key: conf.SignAll, Value: "true", Type: conf.TypeBool, Group: model.GLOBAL, Flag: model.PRIVATE}, {Key: conf.PrivacyRegs, Value: `(?:(?:\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]) ([[:xdigit:]]{1,4}(?::[[:xdigit:]]{1,4}){7}|::|:(?::[[:xdigit:]]{1,4}){1,6}|[[:xdigit:]]{1,4}:(?::[[:xdigit:]]{1,4}){1,5}|(?:[[:xdigit:]]{1,4}:){2}(?::[[:xdigit:]]{1,4}){1,4}|(?:[[:xdigit:]]{1,4}:){3}(?::[[:xdigit:]]{1,4}){1,3}|(?:[[:xdigit:]]{1,4}:){4}(?::[[:xdigit:]]{1,4}){1,2}|(?:[[:xdigit:]]{1,4}:){5}:[[:xdigit:]]{1,4}|(?:[[:xdigit:]]{1,4}:){1,6}:) (?U)access_token=(.*)&`, Type: conf.TypeText, Group: model.GLOBAL, Flag: model.PRIVATE}, {Key: conf.OcrApi, Value: "https://api.nn.ci/ocr/file/json", Type: conf.TypeString, Group: model.GLOBAL}, {Key: conf.FilenameCharMapping, Value: `{"/": "|"}`, Type: conf.TypeText, Group: model.GLOBAL}, + // aria2 settings {Key: conf.Aria2Uri, Value: "http://localhost:6800/jsonrpc", Type: conf.TypeString, Group: model.ARIA2, Flag: model.PRIVATE}, {Key: conf.Aria2Secret, Value: "", Type: conf.TypeString, Group: model.ARIA2, Flag: model.PRIVATE}, + // single settings {Key: conf.Token, Value: token, Type: conf.TypeString, Group: model.SINGLE, Flag: model.PRIVATE}, {Key: conf.SearchIndex, Value: "none", Type: conf.TypeSelect, Options: "database,bleve,none", Group: model.SINGLE}, diff --git a/internal/conf/const.go b/internal/conf/const.go index c4a2e546..30fa2d22 100644 --- a/internal/conf/const.go +++ b/internal/conf/const.go @@ -37,6 +37,7 @@ const ( CustomizeHead = "customize_head" CustomizeBody = "customize_body" LinkExpiration = "link_expiration" + SignAll = "sign all" PrivacyRegs = "privacy_regs" OcrApi = "ocr_api" FilenameCharMapping = "filename_char_mapping" diff --git a/server/common/sign.go b/server/common/sign.go index b9f40249..1d56ad20 100644 --- a/server/common/sign.go +++ b/server/common/sign.go @@ -1,13 +1,16 @@ package common import ( - "github.com/alist-org/alist/v3/internal/model" - "github.com/alist-org/alist/v3/internal/sign" stdpath "path" + + "github.com/alist-org/alist/v3/internal/conf" + "github.com/alist-org/alist/v3/internal/model" + "github.com/alist-org/alist/v3/internal/setting" + "github.com/alist-org/alist/v3/internal/sign" ) func Sign(obj model.Obj, parent string, encrypt bool) string { - if obj.IsDir() || !encrypt { + if obj.IsDir() || (!encrypt && !setting.GetBool(conf.SignAll)) { return "" } return sign.Sign(stdpath.Join(parent, obj.GetName())) diff --git a/server/middlewares/down.go b/server/middlewares/down.go index c6cf8ab0..576fcfa3 100644 --- a/server/middlewares/down.go +++ b/server/middlewares/down.go @@ -3,9 +3,11 @@ package middlewares import ( "strings" + "github.com/alist-org/alist/v3/internal/conf" "github.com/alist-org/alist/v3/internal/db" "github.com/alist-org/alist/v3/internal/errs" "github.com/alist-org/alist/v3/internal/model" + "github.com/alist-org/alist/v3/internal/setting" "github.com/alist-org/alist/v3/internal/sign" "github.com/alist-org/alist/v3/pkg/utils" "github.com/alist-org/alist/v3/server/common" @@ -44,6 +46,9 @@ func parsePath(path string) string { } func needSign(meta *model.Meta, path string) bool { + if setting.GetBool(conf.SignAll) { + return true + } if meta == nil || meta.Password == "" { return false }