TsgcWSRateLimiterMethods › IsConnectionAllowed

IsConnectionAllowed Method

Server hook: returns True if a new connection from IP passes rate limiting.

Syntax

function IsConnectionAllowed(const aIP: string): Boolean;

Parameters

NameTypeDescription
aIPconst stringIP address of the incoming connection. Typically the client's peer IP as seen by the server (or the X-Forwarded-For value when a proxy is in front).

Return Value

Returns True if the connection should be accepted, False if it should be rejected with HTTP 429. (Boolean)

Remarks

Server-integration helper invoked automatically on every new incoming connection when the rate limiter is assigned to a server's RateLimiter property. Internally evaluates PerIP, burst protection and the global strategy and increments connection-level counters. Returns True immediately when Enabled is False. You rarely call this directly — use it only from custom transport code that is not covered by the built-in server integration.

Example

// Manual gate in a custom OnConnect handler
procedure TForm1.ServerConnect(Connection: TsgcWSConnection);
begin
  if not sgcWSRateLimiter1.IsConnectionAllowed(Connection.PeerIP) then
    Connection.Disconnect;
end;

Back to Methods