mirror of https://github.com/Xhofe/alist
feat(uss): add `AntiTheftChainToken` field (#5115)
* feat(uss): add AntiTheftChainToken; fix link func * feat(uss): optimize _upt generationpull/5120/head
parent
6308f1c35d
commit
092ed06833
|
@ -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)
|
downExp := time.Hour * time.Duration(d.SignURLExpire)
|
||||||
expireAt := time.Now().Add(downExp).Unix()
|
expireAt := time.Now().Add(downExp).Unix()
|
||||||
upd := url.QueryEscape(path.Base(file.GetPath()))
|
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)
|
upt := utils.GetMD5EncodeStr(signStr)[12:20] + fmt.Sprint(expireAt)
|
||||||
link := fmt.Sprintf("%s?_upd=%s&_upt=%s", u, upd, upt)
|
link := fmt.Sprintf("%s?_upd=%s&_upt=%s", u, upd, upt)
|
||||||
return &model.Link{URL: link}, nil
|
return &model.Link{URL: link}, nil
|
||||||
|
|
|
@ -11,6 +11,7 @@ type Addition struct {
|
||||||
Endpoint string `json:"endpoint" required:"true"`
|
Endpoint string `json:"endpoint" required:"true"`
|
||||||
OperatorName string `json:"operator_name" required:"true"`
|
OperatorName string `json:"operator_name" required:"true"`
|
||||||
OperatorPassword string `json:"operator_password" 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作用相同,去除
|
//CustomHost string `json:"custom_host"` //Endpoint与CustomHost作用相同,去除
|
||||||
SignURLExpire int `json:"sign_url_expire" type:"number" default:"4"`
|
SignURLExpire int `json:"sign_url_expire" type:"number" default:"4"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue