Skip to content

Commit 9cb51bb

Browse files
committed
🐛 CC detect logic error
1 parent e508ced commit 9cb51bb

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

inc/ngx_http_waf_module_check.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -207,26 +207,25 @@ static ngx_int_t ngx_http_waf_handler_check_cc_ipv4(ngx_http_request_t* r, ngx_i
207207
HASH_ADD_INT(srv_conf->ipv4_times, key, hash_item);
208208
}
209209
else {
210-
if (difftime(now, hash_item->start_time) >= srv_conf->waf_cc_deny_duration * 60.0) {
211-
HASH_DEL(srv_conf->ipv4_times, hash_item);
212-
}
213-
else {
214-
if (hash_item->times > (ngx_uint_t)srv_conf->waf_cc_deny_limit) {
210+
if (hash_item->times > (ngx_uint_t)srv_conf->waf_cc_deny_limit) {
211+
if (difftime(now, hash_item->start_time) > srv_conf->waf_cc_deny_duration * 60.0) {
212+
HASH_DEL(srv_conf->ipv4_times, hash_item);
213+
}
214+
else {
215215
ctx->blocked = TRUE;
216216
strcpy((char*)ctx->rule_type, "CC-DENY");
217217
strcpy((char*)ctx->rule_deatils, "");
218218
*out_http_status = NGX_HTTP_SERVICE_UNAVAILABLE;
219219
return MATCHED;
220220
}
221-
else {
222-
++(hash_item->times);
223-
}
221+
}
222+
else {
223+
++(hash_item->times);
224224
}
225225
}
226226
return NOT_MATCHED;
227227
}
228228

229-
230229
static ngx_int_t ngx_http_waf_handler_check_white_url(ngx_http_request_t* r, ngx_int_t* out_http_status) {
231230
ngx_http_waf_ctx_t* ctx = ngx_http_get_module_ctx(r, ngx_http_waf_module);
232231
ngx_http_waf_srv_conf_t* srv_conf = ngx_http_get_module_srv_conf(r, ngx_http_waf_module);

0 commit comments

Comments
 (0)