mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-28 21:39:06 +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")
|
||||
}
|
||||
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)
|
||||
|
||||
@ -1768,23 +1768,19 @@ func (w WebsiteService) GetAntiLeech(id uint) (*response.NginxAntiLeechRes, erro
|
||||
if lDir.GetName() == "valid_referers" {
|
||||
res.Enable = true
|
||||
params := lDir.GetParameters()
|
||||
serverIndex := 0
|
||||
serverNameExist := false
|
||||
for i, param := range params {
|
||||
for _, param := range params {
|
||||
if param == "none" {
|
||||
res.NoneRef = true
|
||||
continue
|
||||
}
|
||||
if param == "blocked" {
|
||||
res.Blocked = true
|
||||
continue
|
||||
}
|
||||
if param == "server_names" {
|
||||
serverIndex = i
|
||||
serverNameExist = true
|
||||
continue
|
||||
}
|
||||
}
|
||||
if serverNameExist {
|
||||
serverNames := params[serverIndex+1:]
|
||||
res.ServerNames = serverNames
|
||||
res.ServerNames = append(res.ServerNames, param)
|
||||
}
|
||||
}
|
||||
if lDir.GetName() == "if" && lDir.GetParameters()[0] == "($invalid_referer)" {
|
||||
|
Loading…
Reference in New Issue
Block a user