Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
669524cf8e |
@@ -109,12 +109,13 @@ bytes). Rate limits are whole numbers of requests. Netblocks are in CIDR form,
|
|||||||
and a bare address stands for itself alone. `off` switches a timeout, a size
|
and a bare address stands for itself alone. `off` switches a timeout, a size
|
||||||
limit or a rate limit off.
|
limit or a rate limit off.
|
||||||
|
|
||||||
Two limits are fixed rather than settings: the request line and headers may take
|
Four limits are fixed rather than settings. The request line and headers may
|
||||||
up to 32 KiB, above which the answer is `431` and nothing reaches the app, and a
|
take up to 32 KiB, above which the answer is `431` and nothing reaches the app.
|
||||||
kept-open connection that sends nothing for 120 seconds is closed. That is
|
A kept-open connection that sends nothing for 120 seconds is closed. That is
|
||||||
longer than the 90 seconds after which traefik closes a connection it is not
|
longer than the 90 seconds after which traefik closes a connection it is not
|
||||||
using, so traefik never sends a request on a connection `smallwebwaf` is
|
using, so traefik never sends a request on a connection `smallwebwaf` is
|
||||||
closing.
|
closing. At most 20,000 clients are kept for the rate limits, and an IPv6 client
|
||||||
|
is counted by its /64.
|
||||||
|
|
||||||
## Request log
|
## Request log
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,25 @@ func TestEachWindowRefusesAtItsLimitAndLetsTheClientBack(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestClientBackAfterAWholeBucketIsWithinTheLimitAtOnce(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
limiter := ratelimit.New(ratelimit.Limits{PerHour: limit})
|
||||||
|
client := netip.MustParsePrefix("203.0.113.9/32")
|
||||||
|
start := midnight()
|
||||||
|
|
||||||
|
for range limit {
|
||||||
|
wantCount(t, limiter, client, start, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
wantCount(t, limiter, client, start, hour)
|
||||||
|
|
||||||
|
// No request in the whole next bucket, so a quarter into the one after
|
||||||
|
// it the window covers none of the four requests: 1 is within the
|
||||||
|
// limit. Were they counted as the bucket before, 3 + 1 would be over.
|
||||||
|
wantCount(t, limiter, client, start.Add(2*time.Hour+time.Hour/4), "")
|
||||||
|
}
|
||||||
|
|
||||||
func TestRefusedRequestsCount(t *testing.T) {
|
func TestRefusedRequestsCount(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user