Skip to content

Commit ecfcef0

Browse files
committed
fixed bug for flowspec limit in check_rule_limit function
1 parent 159d70b commit ecfcef0

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

flowapp/models/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def check_rule_limit(org_id: int, rule_type: RuleTypes) -> bool:
2222
:param rule_type: RuleType rule type
2323
:return: boolean
2424
"""
25-
flowspec_limit = current_app.config.get("FLOWSPEC_MAX_RULES", 9000)
25+
flowspec4_limit = current_app.config.get("FLOWSPEC4_MAX_RULES", 9000)
26+
flowspec6_limit = current_app.config.get("FLOWSPEC6_MAX_RULES", 9000)
2627
rtbh_limit = current_app.config.get("RTBH_MAX_RULES", 100000)
2728
fs4 = db.session.query(Flowspec4).filter_by(rstate_id=1).count()
2829
fs6 = db.session.query(Flowspec6).filter_by(rstate_id=1).count()
@@ -32,10 +33,10 @@ def check_rule_limit(org_id: int, rule_type: RuleTypes) -> bool:
3233
org = Organization.query.filter_by(id=org_id).first()
3334
if rule_type == RuleTypes.IPv4 and org.limit_flowspec4 > 0:
3435
count = db.session.query(Flowspec4).filter_by(org_id=org_id, rstate_id=1).count()
35-
return count >= org.limit_flowspec4 or fs4 >= flowspec_limit
36+
return count >= org.limit_flowspec4 or fs4 >= flowspec4_limit
3637
if rule_type == RuleTypes.IPv6 and org.limit_flowspec6 > 0:
3738
count = db.session.query(Flowspec6).filter_by(org_id=org_id, rstate_id=1).count()
38-
return count >= org.limit_flowspec6 or fs6 >= flowspec_limit
39+
return count >= org.limit_flowspec6 or fs6 >= flowspec6_limit
3940
if rule_type == RuleTypes.RTBH and org.limit_rtbh > 0:
4041
count = db.session.query(RTBH).filter_by(org_id=org_id, rstate_id=1).count()
4142
return count >= org.limit_rtbh or rtbh >= rtbh_limit

0 commit comments

Comments
 (0)