* clean referer when use proxy * feat: customize proxy ignore headers Co-authored-by: Noah Hsu <i@nn.ci>
This commit is contained in:
@ -10,7 +10,9 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/alist-org/alist/v3/internal/conf"
|
||||
"github.com/alist-org/alist/v3/internal/model"
|
||||
"github.com/alist-org/alist/v3/pkg/utils"
|
||||
"github.com/pkg/errors"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -67,7 +69,7 @@ func Proxy(w http.ResponseWriter, r *http.Request, link *model.Link, file model.
|
||||
return err
|
||||
}
|
||||
for h, val := range r.Header {
|
||||
if strings.ToLower(h) == "authorization" {
|
||||
if utils.SliceContains(conf.SlicesMap[conf.ProxyIgnoreHeaders], strings.ToLower(h)) {
|
||||
continue
|
||||
}
|
||||
req.Header[h] = val
|
||||
|
@ -91,7 +91,7 @@ func shouldProxy(storage driver.Driver, filename string) bool {
|
||||
if storage.Config().MustProxy() || storage.GetStorage().WebProxy {
|
||||
return true
|
||||
}
|
||||
if utils.SliceContains(conf.TypesMap[conf.ProxyTypes], utils.Ext(filename)) {
|
||||
if utils.SliceContains(conf.SlicesMap[conf.ProxyTypes], utils.Ext(filename)) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@ -108,10 +108,10 @@ func canProxy(storage driver.Driver, filename string) bool {
|
||||
if storage.Config().MustProxy() || storage.GetStorage().WebProxy || storage.GetStorage().WebdavProxy() {
|
||||
return true
|
||||
}
|
||||
if utils.SliceContains(conf.TypesMap[conf.ProxyTypes], utils.Ext(filename)) {
|
||||
if utils.SliceContains(conf.SlicesMap[conf.ProxyTypes], utils.Ext(filename)) {
|
||||
return true
|
||||
}
|
||||
if utils.SliceContains(conf.TypesMap[conf.TextTypes], utils.Ext(filename)) {
|
||||
if utils.SliceContains(conf.SlicesMap[conf.TextTypes], utils.Ext(filename)) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
Reference in New Issue
Block a user