direct but proxy types

This commit is contained in:
Xhofe
2022-02-24 16:25:17 +08:00
parent f9f92e2198
commit 94d5b5e47e
5 changed files with 21 additions and 11 deletions

View File

@ -1,27 +1,29 @@
package controllers
import (
"github.com/Xhofe/alist/conf"
"github.com/Xhofe/alist/drivers/base"
"github.com/Xhofe/alist/server/common"
"github.com/Xhofe/alist/utils"
"github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
"path"
)
func Down(c *gin.Context) {
rawPath := c.Param("path")
rawPath = utils.ParsePath(rawPath)
log.Debugf("down: %s", rawPath)
account, path, driver, err := common.ParsePath(rawPath)
account, path_, driver, err := common.ParsePath(rawPath)
if err != nil {
common.ErrorResp(c, err, 500)
return
}
if driver.Config().OnlyProxy || account.Proxy {
if driver.Config().OnlyProxy || account.Proxy || utils.IsContain(conf.DProxyTypes, path.Ext(rawPath)) {
Proxy(c)
return
}
link, err := driver.Link(base.Args{Path: path, IP: c.ClientIP()}, account)
link, err := driver.Link(base.Args{Path: path_, IP: c.ClientIP()}, account)
if err != nil {
common.ErrorResp(c, err, 500)
return

View File

@ -27,7 +27,9 @@ func Proxy(c *gin.Context) {
// 2. driver只能中转
// 3. 是文本类型文件
// 4. 开启webdav中转需要验证sign
if !account.Proxy && !driver.Config().OnlyProxy && utils.GetFileType(filepath.Ext(rawPath)) != conf.TEXT {
if !account.Proxy && !driver.Config().OnlyProxy &&
utils.GetFileType(filepath.Ext(rawPath)) != conf.TEXT &&
!utils.IsContain(conf.DProxyTypes, filepath.Ext(rawPath)) {
// 只开启了webdav中转验证sign
ok := false
if account.WebdavProxy {