Skip to content

Commit 77ffb93

Browse files
committed
feat: multiple down proxy urls (close OpenListTeam#793)
1 parent 9b23d0a commit 77ffb93

File tree

5 files changed

+8
-5
lines changed

5 files changed

+8
-5
lines changed

drivers/base/driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func GetDrivers() map[string][]Item {
121121
{
122122
Name: "down_proxy_url",
123123
Label: "down_proxy_url",
124-
Type: TypeString,
124+
Type: TypeText,
125125
},
126126
{
127127
Name: "extract_folder",

drivers/base/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const (
2121
TypeSelect = "select"
2222
TypeBool = "bool"
2323
TypeNumber = "number"
24+
TypeText = "text"
2425
)
2526

2627
const (

drivers/google/googledrive.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ func (driver GoogleDrive) FormatFile(file *File, account *model.Account) *model.
7373
f.Type = utils.GetFileType(filepath.Ext(file.Name))
7474
}
7575
if file.ThumbnailLink != "" {
76-
if account.DownProxyUrl != "" {
77-
f.Thumbnail = fmt.Sprintf("%s/%s", account.DownProxyUrl, file.ThumbnailLink)
76+
if account.APIProxyUrl != "" {
77+
f.Thumbnail = fmt.Sprintf("%s/%s", account.APIProxyUrl, file.ThumbnailLink)
7878
} else {
7979
f.Thumbnail = file.ThumbnailLink
8080
}

server/controllers/path.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/Xhofe/alist/utils"
1212
"github.com/gin-gonic/gin"
1313
log "github.com/sirupsen/logrus"
14+
"strings"
1415
)
1516

1617
func Pagination(files []model.File, req *common.PathReq) (int, []model.File) {
@@ -119,7 +120,7 @@ func Path(c *gin.Context) {
119120
// 对于中转文件或只能中转,将链接修改为中转链接
120121
if driver.Config().OnlyProxy || account.Proxy {
121122
if account.DownProxyUrl != "" {
122-
file.Url = fmt.Sprintf("%s%s?sign=%s", account.DownProxyUrl, req.Path, utils.SignWithToken(file.Name, conf.Token))
123+
file.Url = fmt.Sprintf("%s%s?sign=%s", strings.Split(account.DownProxyUrl, "\n")[0], req.Path, utils.SignWithToken(file.Name, conf.Token))
123124
} else {
124125
file.Url = fmt.Sprintf("//%s/p%s?sign=%s", c.Request.Host, req.Path, utils.SignWithToken(file.Name, conf.Token))
125126
}

server/controllers/proxy.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/go-resty/resty/v2"
1212
log "github.com/sirupsen/logrus"
1313
"path/filepath"
14+
"strings"
1415
)
1516

1617
func Proxy(c *gin.Context) {
@@ -43,7 +44,7 @@ func Proxy(c *gin.Context) {
4344
// 中转时有中转机器使用中转机器,若携带标志位则表明不能再走中转机器了
4445
if account.DownProxyUrl != "" && c.Query("d") != "1" {
4546
name := utils.Base(rawPath)
46-
link := fmt.Sprintf("%s%s?sign=%s", account.DownProxyUrl, rawPath, utils.SignWithToken(name, conf.Token))
47+
link := fmt.Sprintf("%s%s?sign=%s", strings.Split(account.DownProxyUrl, "\n")[0], rawPath, utils.SignWithToken(name, conf.Token))
4748
c.Redirect(302, link)
4849
return
4950
}

0 commit comments

Comments
 (0)