✨ direct but proxy types
This commit is contained in:
parent
f9f92e2198
commit
94d5b5e47e
@ -65,13 +65,14 @@ func InitSettings() {
|
|||||||
Description: "text type extensions",
|
Description: "text type extensions",
|
||||||
Group: model.FRONT,
|
Group: model.FRONT,
|
||||||
},
|
},
|
||||||
//{
|
{
|
||||||
// Key: "hide readme file",
|
Key: "d_proxy types",
|
||||||
// Value: "true",
|
Value: strings.Join(conf.DProxyTypes, ","),
|
||||||
// Type: "bool",
|
Type: "string",
|
||||||
// Description: "hide readme file? ",
|
Description: "/d but proxy",
|
||||||
// Group: model.FRONT,
|
Access: model.PRIVATE,
|
||||||
//},
|
Group: model.BACK,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Key: "hide files",
|
Key: "hide files",
|
||||||
Value: "/\\/README.md/i",
|
Value: "/\\/README.md/i",
|
||||||
|
@ -34,6 +34,7 @@ var (
|
|||||||
TextTypes = []string{"txt", "htm", "html", "xml", "java", "properties", "sql",
|
TextTypes = []string{"txt", "htm", "html", "xml", "java", "properties", "sql",
|
||||||
"js", "md", "json", "conf", "ini", "vue", "php", "py", "bat", "gitignore", "yml",
|
"js", "md", "json", "conf", "ini", "vue", "php", "py", "bat", "gitignore", "yml",
|
||||||
"go", "sh", "c", "cpp", "h", "hpp", "tsx", "vtt", "srt", "ass"}
|
"go", "sh", "c", "cpp", "h", "hpp", "tsx", "vtt", "srt", "ass"}
|
||||||
|
DProxyTypes = []string{"m3u8"}
|
||||||
OfficeTypes = []string{"doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf"}
|
OfficeTypes = []string{"doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf"}
|
||||||
VideoTypes = []string{"mp4", "mkv", "avi", "mov", "rmvb", "webm", "flv"}
|
VideoTypes = []string{"mp4", "mkv", "avi", "mov", "rmvb", "webm", "flv"}
|
||||||
AudioTypes = []string{"mp3", "flac", "ogg", "m4a", "wav"}
|
AudioTypes = []string{"mp3", "flac", "ogg", "m4a", "wav"}
|
||||||
|
@ -93,6 +93,10 @@ func LoadSettings() {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
conf.TextTypes = strings.Split(textTypes.Value, ",")
|
conf.TextTypes = strings.Split(textTypes.Value, ",")
|
||||||
}
|
}
|
||||||
|
dProxyTypes, err := GetSettingByKey("d_proxy types")
|
||||||
|
if err == nil {
|
||||||
|
conf.DProxyTypes = strings.Split(dProxyTypes.Value, ",")
|
||||||
|
}
|
||||||
// html
|
// html
|
||||||
favicon, err := GetSettingByKey("favicon")
|
favicon, err := GetSettingByKey("favicon")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
@ -1,27 +1,29 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/Xhofe/alist/conf"
|
||||||
"github.com/Xhofe/alist/drivers/base"
|
"github.com/Xhofe/alist/drivers/base"
|
||||||
"github.com/Xhofe/alist/server/common"
|
"github.com/Xhofe/alist/server/common"
|
||||||
"github.com/Xhofe/alist/utils"
|
"github.com/Xhofe/alist/utils"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"path"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Down(c *gin.Context) {
|
func Down(c *gin.Context) {
|
||||||
rawPath := c.Param("path")
|
rawPath := c.Param("path")
|
||||||
rawPath = utils.ParsePath(rawPath)
|
rawPath = utils.ParsePath(rawPath)
|
||||||
log.Debugf("down: %s", rawPath)
|
log.Debugf("down: %s", rawPath)
|
||||||
account, path, driver, err := common.ParsePath(rawPath)
|
account, path_, driver, err := common.ParsePath(rawPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.ErrorResp(c, err, 500)
|
common.ErrorResp(c, err, 500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if driver.Config().OnlyProxy || account.Proxy {
|
if driver.Config().OnlyProxy || account.Proxy || utils.IsContain(conf.DProxyTypes, path.Ext(rawPath)) {
|
||||||
Proxy(c)
|
Proxy(c)
|
||||||
return
|
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 {
|
if err != nil {
|
||||||
common.ErrorResp(c, err, 500)
|
common.ErrorResp(c, err, 500)
|
||||||
return
|
return
|
||||||
|
@ -27,7 +27,9 @@ func Proxy(c *gin.Context) {
|
|||||||
// 2. driver只能中转
|
// 2. driver只能中转
|
||||||
// 3. 是文本类型文件
|
// 3. 是文本类型文件
|
||||||
// 4. 开启webdav中转(需要验证sign)
|
// 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
|
// 只开启了webdav中转,验证sign
|
||||||
ok := false
|
ok := false
|
||||||
if account.WebdavProxy {
|
if account.WebdavProxy {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user