TsgcWebSocketFirewallMethods › IsConnectionAllowed

IsConnectionAllowed Method

Core handshake filter. Evaluates every enabled connection-time protection module (bans, whitelist, blacklist, rate limit, GeoIP, custom rules) and returns whether the connection should be accepted.

Syntax

function IsConnectionAllowed(const aIP: string): Boolean;

Parameters

NameTypeDescription
aIPconst stringRemote client address as reported by the underlying socket. Both IPv4 and IPv6 are supported.

Return Value

True when the connection passes every enabled check; False if any module rejects it. On rejection OnFiltered and OnViolation fire with the matching violation type. (Boolean)

Remarks

IsConnectionAllowed is the primary entry point invoked by TsgcWebSocketServer, TsgcWebSocketHTTPServer and TsgcWebSocketServer_HTTPAPI at handshake time as soon as the Firewall property is assigned, so manual calls are rarely required. It applies the modules in the documented order: if the IP is whitelisted, all further checks are skipped and True is returned; otherwise bans, blacklist, rate limit, GeoIP and CustomRules are evaluated sequentially. The method is thread-safe and updates Stats and threat-score counters as it runs.

Example

// manual pre-filter (usually not needed — wiring the Firewall property is enough)
if not sgcWebSocketFirewall1.IsConnectionAllowed(Connection.IP) then
  Connection.Disconnect;

Back to Methods