webdav direct proxy

This commit is contained in:
Xhofe
2022-02-13 15:57:42 +08:00
parent 7bb237d0ef
commit 4371c470b3
8 changed files with 124 additions and 103 deletions

View File

@ -95,7 +95,7 @@ func ClientIP(r *http.Request) string {
return ""
}
func (fs *FileSystem) Link(r *http.Request, rawPath string) (string, error) {
func (fs *FileSystem) Link(w http.ResponseWriter, r *http.Request, rawPath string) (string, error) {
rawPath = utils.ParsePath(rawPath)
log.Debugf("get link path: %s", rawPath)
if model.AccountsCount() > 1 && rawPath == "/" {
@ -110,6 +110,19 @@ func (fs *FileSystem) Link(r *http.Request, rawPath string) (string, error) {
if r.TLS != nil {
protocol = "https"
}
// 直接返回
if account.WebdavDirect {
file, err := fs.File(rawPath)
if err != nil {
return "", err
}
link_, err := driver.Link(base.Args{Path: path_}, account)
if err != nil {
return "", err
}
err = common.Proxy(w, r, link_, file)
return "", err
}
if driver.Config().OnlyProxy || account.WebdavProxy {
link = fmt.Sprintf("%s://%s/p%s", protocol, r.Host, rawPath)
if conf.GetBool("check down link") {