Skip to content

Commit

Permalink
remove redundant code from CC check and let it go directly when CC po…
Browse files Browse the repository at this point in the history
…licy is OK_PASS
  • Loading branch information
zhyale committed Mar 20, 2022
1 parent b33ab0a commit 2d83534
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 1 addition & 6 deletions firewall/cc.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,10 @@ func GetCCPolicyRespByAppID(appID int64) (*models.CCPolicy, error) {

// IsCCAttack to judge a request is CC attack, return IsCC, CCPolicy, ClientID, NeedLog
func IsCCAttack(r *http.Request, app *models.Application, srcIP string) (bool, *models.CCPolicy, string, bool) {
isCC := false
ccPolicy := GetCCPolicyByAppID(app.ID)
if !ccPolicy.IsEnabled {
if !ccPolicy.IsEnabled || ccPolicy.Action == models.Action_Pass_400 {
return false, nil, "", false
}
if isCC {
clientID := data.SHA256Hash(srcIP)
return isCC, ccPolicy, clientID, false
}
ccAppID := app.ID
if ccPolicy.AppID == 0 {
ccAppID = 0 // Important: stat within general policy
Expand Down
2 changes: 2 additions & 0 deletions gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ func ReverseHandlerFunc(w http.ResponseWriter, r *http.Request) {
captchaURL := CaptchaEntrance + "?id=" + hitInfo.ClientID
http.Redirect(w, r, captchaURL, http.StatusFound)
return
default:
// models.Action_Pass_400 do nothing
}
}
}
Expand Down

0 comments on commit 2d83534

Please sign in to comment.