From e7a9c3814bff3dc4813f9b975eac5133771fd646 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 <31820853+zhengkunwang223@users.noreply.github.com> Date: Fri, 2 Jun 2023 13:53:25 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E6=89=93=E5=BC=80?= =?UTF-8?q?=E9=98=B2=E7=9B=97=E9=93=BE=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20(#1230)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/website.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/backend/app/service/website.go b/backend/app/service/website.go index a2eaa4d61..9c6bb2738 100644 --- a/backend/app/service/website.go +++ b/backend/app/service/website.go @@ -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)" {