-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support IP rate limiting #59
Conversation
controllers/rule.go
Outdated
@@ -131,6 +131,8 @@ func checkExpressions(expressions []*object.Expression, ruleType string) error { | |||
return checkWafRule(values) | |||
case "IP": | |||
return checkIpRule(values) | |||
case "IpRate": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Label is "IP Rate Limiting"
@@ -157,3 +159,19 @@ func checkIpRule(ipLists []string) error { | |||
} | |||
return nil | |||
} | |||
|
|||
func checkIpRateRule(expressions []*object.Expression) error { | |||
if len(expressions) != 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this be zero?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not allowed to be zero.
controllers/rule.go
Outdated
|
||
func checkIpRateRule(expressions []*object.Expression) error { | ||
if len(expressions) != 1 { | ||
return errors.New("IpRate rule should have only one expression") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to limit this in frontend too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has been limited in frontend.
web/src/RuleEditPage.js
Outdated
@@ -86,7 +96,7 @@ class RuleEditPage extends React.Component { | |||
{value: "WAF", text: "WAF"}, | |||
{value: "IP", text: "IP"}, | |||
{value: "User-Agent", text: "User-Agent"}, | |||
// {value: "frequency", text: "Frequency"}, | |||
{value: "IpRate", text: "IP Rate"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Label is "IP Rate Limiting"
web/src/RuleEditPage.js
Outdated
{ | ||
this.state.rule.type === "IpRate" ? ( | ||
<IpRateRuleTable | ||
title={"IP Rate"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Label is "IP Rate Limiting"
renderTable(table) { | ||
const columns = [ | ||
{ | ||
title: "Name", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i18n
), | ||
}, | ||
{ | ||
title: "Rate", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i18n
), | ||
}, | ||
{ | ||
title: "Block Duration", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i18n
web/src/components/UaRuleTable.js
Outdated
@@ -147,7 +147,7 @@ class UaRuleTable extends React.Component { | |||
<div> | |||
{this.props.title} | |||
<Button style={{marginRight: "5px"}} type="primary" size="small" onClick={() => this.addRow(table)}>{"Add"}</Button> | |||
<Button style={{marginRight: "5px"}} type="primary" size="small" onClick={() => this.restore()}>{"Restore Build-in User-Agent Rules"}</Button> | |||
<Button style={{marginRight: "5px"}} type="primary" size="small" onClick={() => this.restore()}>{"Restore"}</Button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check all i18n
rule/rule.go
Outdated
@@ -36,6 +36,10 @@ func CheckRules(ruleIds []string, r *http.Request) (string, string, error) { | |||
ruleObj = &IpRule{} | |||
case "WAF": | |||
ruleObj = &WafRule{} | |||
case "IpRate": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Label is "IP Rate Limiting"
🎉 This PR is included in version 1.29.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Fix: #58
P.S. update antd to ~4.24.0