feat: multiple down proxy urls (close #793)
This commit is contained in:
parent
9b23d0ab29
commit
77ffb93cbe
@ -121,7 +121,7 @@ func GetDrivers() map[string][]Item {
|
|||||||
{
|
{
|
||||||
Name: "down_proxy_url",
|
Name: "down_proxy_url",
|
||||||
Label: "down_proxy_url",
|
Label: "down_proxy_url",
|
||||||
Type: TypeString,
|
Type: TypeText,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "extract_folder",
|
Name: "extract_folder",
|
||||||
|
@ -21,6 +21,7 @@ const (
|
|||||||
TypeSelect = "select"
|
TypeSelect = "select"
|
||||||
TypeBool = "bool"
|
TypeBool = "bool"
|
||||||
TypeNumber = "number"
|
TypeNumber = "number"
|
||||||
|
TypeText = "text"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -73,8 +73,8 @@ func (driver GoogleDrive) FormatFile(file *File, account *model.Account) *model.
|
|||||||
f.Type = utils.GetFileType(filepath.Ext(file.Name))
|
f.Type = utils.GetFileType(filepath.Ext(file.Name))
|
||||||
}
|
}
|
||||||
if file.ThumbnailLink != "" {
|
if file.ThumbnailLink != "" {
|
||||||
if account.DownProxyUrl != "" {
|
if account.APIProxyUrl != "" {
|
||||||
f.Thumbnail = fmt.Sprintf("%s/%s", account.DownProxyUrl, file.ThumbnailLink)
|
f.Thumbnail = fmt.Sprintf("%s/%s", account.APIProxyUrl, file.ThumbnailLink)
|
||||||
} else {
|
} else {
|
||||||
f.Thumbnail = file.ThumbnailLink
|
f.Thumbnail = file.ThumbnailLink
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"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"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Pagination(files []model.File, req *common.PathReq) (int, []model.File) {
|
func Pagination(files []model.File, req *common.PathReq) (int, []model.File) {
|
||||||
@ -119,7 +120,7 @@ func Path(c *gin.Context) {
|
|||||||
// 对于中转文件或只能中转,将链接修改为中转链接
|
// 对于中转文件或只能中转,将链接修改为中转链接
|
||||||
if driver.Config().OnlyProxy || account.Proxy {
|
if driver.Config().OnlyProxy || account.Proxy {
|
||||||
if account.DownProxyUrl != "" {
|
if account.DownProxyUrl != "" {
|
||||||
file.Url = fmt.Sprintf("%s%s?sign=%s", account.DownProxyUrl, req.Path, utils.SignWithToken(file.Name, conf.Token))
|
file.Url = fmt.Sprintf("%s%s?sign=%s", strings.Split(account.DownProxyUrl, "\n")[0], req.Path, utils.SignWithToken(file.Name, conf.Token))
|
||||||
} else {
|
} else {
|
||||||
file.Url = fmt.Sprintf("//%s/p%s?sign=%s", c.Request.Host, req.Path, utils.SignWithToken(file.Name, conf.Token))
|
file.Url = fmt.Sprintf("//%s/p%s?sign=%s", c.Request.Host, req.Path, utils.SignWithToken(file.Name, conf.Token))
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Proxy(c *gin.Context) {
|
func Proxy(c *gin.Context) {
|
||||||
@ -43,7 +44,7 @@ func Proxy(c *gin.Context) {
|
|||||||
// 中转时有中转机器使用中转机器,若携带标志位则表明不能再走中转机器了
|
// 中转时有中转机器使用中转机器,若携带标志位则表明不能再走中转机器了
|
||||||
if account.DownProxyUrl != "" && c.Query("d") != "1" {
|
if account.DownProxyUrl != "" && c.Query("d") != "1" {
|
||||||
name := utils.Base(rawPath)
|
name := utils.Base(rawPath)
|
||||||
link := fmt.Sprintf("%s%s?sign=%s", account.DownProxyUrl, rawPath, utils.SignWithToken(name, conf.Token))
|
link := fmt.Sprintf("%s%s?sign=%s", strings.Split(account.DownProxyUrl, "\n")[0], rawPath, utils.SignWithToken(name, conf.Token))
|
||||||
c.Redirect(302, link)
|
c.Redirect(302, link)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user