mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 16:29:17 +08:00
fix: 解决打开防盗链报错的问题 (#1230)
This commit is contained in:
parent
488eb319a1
commit
e7a9c3814b
@ -1703,7 +1703,7 @@ func (w WebsiteService) UpdateAntiLeech(req request.NginxAntiLeechUpdate) (err e
|
|||||||
validDir.Parameters = append(validDir.Parameters, "none")
|
validDir.Parameters = append(validDir.Parameters, "none")
|
||||||
}
|
}
|
||||||
if len(req.ServerNames) > 0 {
|
if len(req.ServerNames) > 0 {
|
||||||
validDir.Parameters = append(validDir.Parameters, "server_names", strings.Join(req.ServerNames, " "))
|
validDir.Parameters = append(validDir.Parameters, strings.Join(req.ServerNames, " "))
|
||||||
}
|
}
|
||||||
newBlock.Directives = append(newBlock.Directives, validDir)
|
newBlock.Directives = append(newBlock.Directives, validDir)
|
||||||
|
|
||||||
@ -1768,23 +1768,19 @@ func (w WebsiteService) GetAntiLeech(id uint) (*response.NginxAntiLeechRes, erro
|
|||||||
if lDir.GetName() == "valid_referers" {
|
if lDir.GetName() == "valid_referers" {
|
||||||
res.Enable = true
|
res.Enable = true
|
||||||
params := lDir.GetParameters()
|
params := lDir.GetParameters()
|
||||||
serverIndex := 0
|
for _, param := range params {
|
||||||
serverNameExist := false
|
|
||||||
for i, param := range params {
|
|
||||||
if param == "none" {
|
if param == "none" {
|
||||||
res.NoneRef = true
|
res.NoneRef = true
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
if param == "blocked" {
|
if param == "blocked" {
|
||||||
res.Blocked = true
|
res.Blocked = true
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
if param == "server_names" {
|
if param == "server_names" {
|
||||||
serverIndex = i
|
continue
|
||||||
serverNameExist = true
|
|
||||||
}
|
}
|
||||||
}
|
res.ServerNames = append(res.ServerNames, param)
|
||||||
if serverNameExist {
|
|
||||||
serverNames := params[serverIndex+1:]
|
|
||||||
res.ServerNames = serverNames
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if lDir.GetName() == "if" && lDir.GetParameters()[0] == "($invalid_referer)" {
|
if lDir.GetName() == "if" && lDir.GetParameters()[0] == "($invalid_referer)" {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user