feat(uss): add `AntiTheftChainToken` field (#5115)

* feat(uss): add AntiTheftChainToken; fix link func

* feat(uss): optimize _upt generation
pull/5120/head
Kuingsmile 2023-08-30 00:16:26 -07:00 committed by GitHub
parent 6308f1c35d
commit 092ed06833
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -80,7 +80,11 @@ func (d *USS) Link(ctx context.Context, file model.Obj, args model.LinkArgs) (*m
downExp := time.Hour * time.Duration(d.SignURLExpire)
expireAt := time.Now().Add(downExp).Unix()
upd := url.QueryEscape(path.Base(file.GetPath()))
signStr := strings.Join([]string{d.OperatorPassword, fmt.Sprint(expireAt), fmt.Sprintf("/%s", key)}, "&")
tokenOrPassword := d.AntiTheftChainToken
if tokenOrPassword == "" {
tokenOrPassword = d.OperatorPassword
}
signStr := strings.Join([]string{tokenOrPassword, fmt.Sprint(expireAt), fmt.Sprintf("/%s", key)}, "&")
upt := utils.GetMD5EncodeStr(signStr)[12:20] + fmt.Sprint(expireAt)
link := fmt.Sprintf("%s?_upd=%s&_upt=%s", u, upd, upt)
return &model.Link{URL: link}, nil

View File

@ -11,6 +11,7 @@ type Addition struct {
Endpoint string `json:"endpoint" required:"true"`
OperatorName string `json:"operator_name" required:"true"`
OperatorPassword string `json:"operator_password" required:"true"`
AntiTheftChainToken string `json:"anti_theft_chain_token" required:"false" default:""`
//CustomHost string `json:"custom_host"` //Endpoint与CustomHost作用相同去除
SignURLExpire int `json:"sign_url_expire" type:"number" default:"4"`
}