feat(proxy-route): allow -1 to disable rate limits

This commit is contained in:
ryan
2026-07-19 18:14:16 +08:00
parent 2bc2d82ad0
commit c5f8105db8
3 changed files with 35 additions and 3 deletions
@@ -326,8 +326,8 @@ func validateProxyRouteZoneDomainCertificates(ctx context.Context, domains []mod
}
func normalizeProxyRouteLimitConnValue(value int, field string) (int, error) {
if value < 0 {
return 0, fmt.Errorf("%s must be greater than or equal to 0", field)
if value < -1 {
return 0, fmt.Errorf("%s must be greater than or equal to -1", field)
}
return value, nil
}
@@ -337,6 +337,9 @@ func normalizeProxyRouteLimitRate(raw string) (string, error) {
if normalized == "" || normalized == "0" {
return "", nil
}
if normalized == "-1" {
return "-1", nil
}
if !proxyRouteLimitRatePattern.MatchString(normalized) {
return "", errors.New(errProxyRouteLimitRate)
}