CheckIPRateLimit (open)

Implements rate limiting for the current request IP

Syntax

LOADLIB "mod::system/lib/services.whlib";

RECORD FUNCTION CheckIPRateLimit(RECORD criterium, INTEGER numhits, RECORD options)

Parameters

RECORD criterium

A record describing this rate limit (hashed to generate a unique key)

INTEGER numhits

Number of hits to accept in the time period

RECORD options

Options

BOOLEAN exemptdev

Exempt development servers from the ratelimit (if this is a request, add a header to indicate the rate was hit)

INTEGER timeperiod

Time period to which the limit applies in ms. Defaults to 1 minute (60000)

Return value

RECORD

Limit check result

BOOLEAN accepted

If TRUE, accept this request, rate limit not hit

INTEGER backoff

If >0, recommended backoff time before requests will be accepted again (in ms)

Description

Wraps CheckRateLimit but automatically adds the current IP to the request. For ipv6, it will rate limit based on the /64 of the IP