Skip to content

Commit

Permalink
feat: add disable_x_envoy_ratelimited_header option
Browse files Browse the repository at this point in the history
  • Loading branch information
yizhibian committed Jan 11, 2025
1 parent 8c55999 commit c57842f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
4 changes: 4 additions & 0 deletions plugins/plugins/limitcountredis/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ func TestConfig(t *testing.T) {
name: "pass",
input: `{"address":"127.0.0.1:6479", "rules":[{"count":1,"timeWindow":"1s"}], "prefix":"test"}`,
},
{
name: "disable x-envoy-ratelimited header",
input: `{"address":"127.0.0.1:6479", "rules":[{"count":1,"timeWindow":"1s"}], "prefix":"test", "disable_x_envoy_ratelimited_header": true}`,
},
}

for _, tt := range tests {
Expand Down
2 changes: 1 addition & 1 deletion plugins/plugins/limitcountredis/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (f *filter) DecodeHeaders(headers api.RequestHeaderMap, endStream bool) api
remain := ress[2*i].(int64)
if remain < 0 {
hdr := http.Header{}
if config.EnableLimitQuotaHeaders {
if !config.DisableXEnvoyRatelimitedHeader {
hdr.Set("x-envoy-ratelimited", "true")
}
status := 429
Expand Down
27 changes: 20 additions & 7 deletions types/plugins/limitcountredis/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions types/plugins/limitcountredis/config.pb.validate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions types/plugins/limitcountredis/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ message Config {

// There is no special reason to limit the length <=128, just to avoid too long string
string prefix = 12 [(validate.rules).string = {min_len: 1, max_len: 128}];

bool disable_x_envoy_ratelimited_header = 13;
}

0 comments on commit c57842f

Please sign in to comment.