chore: webdav policy of account

refactor/fs
Noah Hsu 2022-06-27 13:58:21 +08:00
parent 2aff218356
commit 087fae1b15
2 changed files with 27 additions and 9 deletions

View File

@ -22,9 +22,8 @@ type Sort struct {
}
type Proxy struct {
WebProxy string `json:"web_proxy"`
WebdavProxy bool `json:"webdav_proxy"`
WebdavDirect bool `json:"webdav_direct"`
WebProxy bool `json:"web_proxy"`
WebdavPolicy string `json:"webdav_policy"`
DownProxyUrl string `json:"down_proxy_url"`
}
@ -35,3 +34,15 @@ func (a Account) GetAccount() Account {
func (a *Account) SetStatus(status string) {
a.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()
}

View File

@ -64,20 +64,27 @@ func getMainItems(config driver.Config) []driver.Item {
}, {
Name: "down_proxy_url",
Type: driver.TypeText,
}, {
Name: "webdav_direct",
Type: driver.TypeBool,
Help: "Transfer the WebDAV of this account through the native without redirect",
}}
if !config.OnlyProxy && !config.OnlyLocal {
items = append(items, []driver.Item{{
Name: "web_proxy",
Type: driver.TypeBool,
}, {
Name: "webdav_proxy",
Type: driver.TypeBool,
Name: "webdav_policy",
Type: driver.TypeSelect,
Values: "302_redirect, use_proxy_url, native_proxy",
Default: "direct",
Required: true,
},
}...)
} else {
items = append(items, driver.Item{
Name: "webdav_policy",
Type: driver.TypeSelect,
Default: "",
Values: "use_proxy_url, native_proxy",
Required: true,
})
}
if config.LocalSort {
items = append(items, []driver.Item{{