From 2f8258053f5be8a17d8f19f6d78bae82fa30a8d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=AE=E5=87=89?= <927625802@qq.com> Date: Fri, 10 Dec 2021 15:55:21 +0800 Subject: [PATCH] :sparkles: support native proxy url --- drivers/base/driver.go | 17 +++++++---------- server/controllers/down.go | 4 ++-- server/controllers/path.go | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/base/driver.go b/drivers/base/driver.go index 70767e86..c3ef458a 100644 --- a/drivers/base/driver.go +++ b/drivers/base/driver.go @@ -84,16 +84,13 @@ func GetDrivers() map[string][]Item { }, }, v.Items()...) } - // 不支持给本地文件添加中转 - if v.Config().Name != "Native" { - res[k] = append(res[k], Item{ - Name: "proxy_url", - Label: "proxy_url", - Type: TypeString, - Required: false, - Description: "proxy url", - }) - } + res[k] = append(res[k], Item{ + Name: "proxy_url", + Label: "proxy_url", + Type: TypeString, + Required: false, + Description: "proxy url", + }) } return res } diff --git a/server/controllers/down.go b/server/controllers/down.go index 9f6eaf18..3bbe8f29 100644 --- a/server/controllers/down.go +++ b/server/controllers/down.go @@ -56,8 +56,8 @@ func Proxy(c *gin.Context) { common.ErrorResp(c, fmt.Errorf("[%s] not allowed proxy", account.Name), 403) return } - // 中转时有中转机器使用中转机器 - if account.ProxyUrl != "" { + // 中转时有中转机器使用中转机器,若携带标志位则表明不能再走中转机器了 + if account.ProxyUrl != "" && c.Param("d") != "1" { name := utils.Base(rawPath) link := fmt.Sprintf("%s%s?sign=%s", account.ProxyUrl, rawPath, utils.SignWithToken(name, conf.Token)) c.Redirect(302, link) diff --git a/server/controllers/path.go b/server/controllers/path.go index fe54dcc1..14ae231e 100644 --- a/server/controllers/path.go +++ b/server/controllers/path.go @@ -95,7 +95,7 @@ func Link(c *gin.Context) { } if driver.Config().NoLink { common.SuccessResp(c, base.Link{ - Url: fmt.Sprintf("//%s/d%s?sign=%s", c.Request.Host, req.Path, utils.SignWithToken(utils.Base(rawPath), conf.Token)), + Url: fmt.Sprintf("//%s/d%s?d=1&sign=%s", c.Request.Host, req.Path, utils.SignWithToken(utils.Base(rawPath), conf.Token)), }) return } else {