Class RateLimitParameters
- Namespace
- Cloudflare.NET.Security.Rulesets.Models
- Assembly
- Cloudflare.NET.dll
Defines the configuration for a rate limiting rule.
public record RateLimitParameters : IEquatable<RateLimitParameters>
- Inheritance
-
RateLimitParameters
- Implements
- Inherited Members
Constructors
RateLimitParameters(IReadOnlyList<string>, int, int, int?, int?, bool?, string?, string?, bool?)
Defines the configuration for a rate limiting rule.
public RateLimitParameters(IReadOnlyList<string> Characteristics, int Period, int MitigationTimeout, int? RequestsPerPeriod = null, int? ScorePerPeriod = null, bool? RequestsToOrigin = null, string? CountingExpression = null, string? ScoreResponseHeaderName = null, bool? Simulate = null)
Parameters
CharacteristicsIReadOnlyList<string>The properties to track for rate limiting (e.g., "ip.src").
PeriodintThe time period in seconds. Only specific values are allowed. It is highly recommended to use the constants defined in SecurityConstants.RateLimiting.Periods to avoid errors.
MitigationTimeoutintThe duration in seconds to apply the mitigation action.
RequestsPerPeriodint?The number of requests allowed in the period for standard rate limiting.
ScorePerPeriodint?The score threshold for complexity-based rate limiting.
RequestsToOriginbool?Whether to count requests to origin (ignores cache).
CountingExpressionstringA filter expression to specify which requests to count.
ScoreResponseHeaderNamestringFor complexity-based limiting, the name of the response header to send the score.
Simulatebool?If true, the rule will be logged but not actioned.
Properties
Characteristics
The properties to track for rate limiting (e.g., "ip.src").
[JsonPropertyName("characteristics")]
public IReadOnlyList<string> Characteristics { get; init; }
Property Value
CountingExpression
A filter expression to specify which requests to count.
[JsonPropertyName("counting_expression")]
public string? CountingExpression { get; init; }
Property Value
MitigationTimeout
The duration in seconds to apply the mitigation action.
[JsonPropertyName("mitigation_timeout")]
public int MitigationTimeout { get; init; }
Property Value
Period
The time period in seconds. Only specific values are allowed. It is highly recommended to use the constants defined in SecurityConstants.RateLimiting.Periods to avoid errors.
[JsonPropertyName("period")]
public int Period { get; init; }
Property Value
RequestsPerPeriod
The number of requests allowed in the period for standard rate limiting.
[JsonPropertyName("requests_per_period")]
public int? RequestsPerPeriod { get; init; }
Property Value
- int?
RequestsToOrigin
Whether to count requests to origin (ignores cache).
[JsonPropertyName("requests_to_origin")]
public bool? RequestsToOrigin { get; init; }
Property Value
- bool?
ScorePerPeriod
The score threshold for complexity-based rate limiting.
[JsonPropertyName("score_per_period")]
public int? ScorePerPeriod { get; init; }
Property Value
- int?
ScoreResponseHeaderName
For complexity-based limiting, the name of the response header to send the score.
[JsonPropertyName("score_response_header_name")]
public string? ScoreResponseHeaderName { get; init; }
Property Value
Simulate
If true, the rule will be logged but not actioned.
[JsonPropertyName("simulate")]
public bool? Simulate { get; init; }
Property Value
- bool?