mirror of
https://github.com/AlistGo/alist.git
synced 2025-04-29 08:44:03 +08:00

* Determine whether the URL requires Sign * Add File and Mem based KV NOT TESTED: TokenKV Function * Change Token KV func to common func. Add File based KV func * Remove KV, Remove Token I found that the original Sign function is enough to complete the link signature, and only need to add simple configuration items to meet the requirements. * Add IsStorageSigned func to judge if Signing is enabled in the storage settings. It should be working now. * Add a SIGN button to the management panel. * Add enable_sign to the basic storage struct. Can enable sign for every driver now. Bug: When sign enabled, in download page, Copy link doesn't contain a sign. (Not done yet) * Fix a bug from commit 8f6c25f. Response of fsread function does not contain sign. * Optimize code and follow advices. - Add back public/dist/README.md - Enable sign when DownProxyUrl is enabled - Merge needSign() to isEncrypt() in fsread.go * simplify code --------- Co-authored-by: Andy Hsu <i@nn.ci>
56 lines
1.6 KiB
Go
56 lines
1.6 KiB
Go
package model
|
|
|
|
import "time"
|
|
|
|
type Storage struct {
|
|
ID uint `json:"id" gorm:"primaryKey"` // unique key
|
|
MountPath string `json:"mount_path" gorm:"unique" binding:"required"` // must be standardized
|
|
Order int `json:"order"` // use to sort
|
|
Driver string `json:"driver"` // driver used
|
|
CacheExpiration int `json:"cache_expiration"` // cache expire time
|
|
Status string `json:"status"`
|
|
Addition string `json:"addition" gorm:"type:text"` // Additional information, defined in the corresponding driver
|
|
Remark string `json:"remark"`
|
|
Modified time.Time `json:"modified"`
|
|
Disabled bool `json:"disabled"` // if disabled
|
|
EnableSign bool `json:"enable_sign"`
|
|
Sort
|
|
Proxy
|
|
}
|
|
|
|
type Sort struct {
|
|
OrderBy string `json:"order_by"`
|
|
OrderDirection string `json:"order_direction"`
|
|
ExtractFolder string `json:"extract_folder"`
|
|
}
|
|
|
|
type Proxy struct {
|
|
WebProxy bool `json:"web_proxy"`
|
|
WebdavPolicy string `json:"webdav_policy"`
|
|
DownProxyUrl string `json:"down_proxy_url"`
|
|
}
|
|
|
|
func (s *Storage) GetStorage() *Storage {
|
|
return s
|
|
}
|
|
|
|
func (s *Storage) SetStorage(storage Storage) {
|
|
*s = storage
|
|
}
|
|
|
|
func (s *Storage) SetStatus(status string) {
|
|
s.Status = status
|
|
}
|
|
|
|
func (p Proxy) Webdav302() bool {
|
|
return p.WebdavPolicy == "302_redirect"
|
|
}
|
|
|
|
func (p Proxy) WebdavProxy() bool {
|
|
return p.WebdavPolicy == "use_proxy_url"
|
|
}
|
|
|
|
func (p Proxy) WebdavNative() bool {
|
|
return !p.Webdav302() && !p.WebdavProxy()
|
|
}
|