direct but proxy types

pull/661/head
Xhofe 2022-02-24 16:25:17 +08:00
parent f9f92e2198
commit 94d5b5e47e
5 changed files with 21 additions and 11 deletions

View File

@ -65,13 +65,14 @@ func InitSettings() {
Description: "text type extensions",
Group: model.FRONT,
},
//{
// Key: "hide readme file",
// Value: "true",
// Type: "bool",
// Description: "hide readme file? ",
// Group: model.FRONT,
//},
{
Key: "d_proxy types",
Value: strings.Join(conf.DProxyTypes, ","),
Type: "string",
Description: "/d but proxy",
Access: model.PRIVATE,
Group: model.BACK,
},
{
Key: "hide files",
Value: "/\\/README.md/i",

View File

@ -34,6 +34,7 @@ var (
TextTypes = []string{"txt", "htm", "html", "xml", "java", "properties", "sql",
"js", "md", "json", "conf", "ini", "vue", "php", "py", "bat", "gitignore", "yml",
"go", "sh", "c", "cpp", "h", "hpp", "tsx", "vtt", "srt", "ass"}
DProxyTypes = []string{"m3u8"}
OfficeTypes = []string{"doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf"}
VideoTypes = []string{"mp4", "mkv", "avi", "mov", "rmvb", "webm", "flv"}
AudioTypes = []string{"mp3", "flac", "ogg", "m4a", "wav"}

View File

@ -93,6 +93,10 @@ func LoadSettings() {
if err == nil {
conf.TextTypes = strings.Split(textTypes.Value, ",")
}
dProxyTypes, err := GetSettingByKey("d_proxy types")
if err == nil {
conf.DProxyTypes = strings.Split(dProxyTypes.Value, ",")
}
// html
favicon, err := GetSettingByKey("favicon")
if err == nil {

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 {