TsgcWebSocketFirewall › Methods

TsgcWebSocketFirewall Methods

Public methods grouped by purpose, followed by the full alphabetical list.

Connection checks

NameDescription
IsConnectionAllowedCore 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.
IsMessageAllowedCore per-message filter. Runs the enabled content-inspection modules (SQL injection, XSS, path traversal, command injection, payload limit, flood protection, custom rules) and returns whether the message should be delivered.
IsOriginAllowedChecks a WebSocket Origin header against WebSocketProtection.AllowedOrigins (with wildcard support) and returns whether it is accepted.
IsFrameSizeAllowedChecks a single WebSocket frame size against WebSocketProtection.MaxFrameSize and returns whether it is within the configured limit.
IsSubprotocolAllowedChecks the requested WebSocket subprotocol name against WebSocketProtection.AllowedSubprotocols and returns whether it is accepted.

Tracking

NameDescription
RegisterConnectionRecords a new accepted connection for the given IP, incrementing the per-IP counters used by RateLimit and feeding the ThreatScore decay window.
UnregisterConnectionDecrements the per-IP connection counter when a previously registered connection closes, freeing capacity for RateLimit.
RegisterFailedAttemptApplication-level hook that records a failed authentication attempt from the given IP, feeding the BruteForce tracker and potentially triggering an automatic ban.

Ban management

NameDescription
BanIPManually bans an IP address for the specified duration, adding it to the active ban list so all subsequent connections from that IP are rejected.
UnbanIPRemoves the active ban record for a single IP address so the client can reconnect on its next attempt.
IsBannedReturns True when the given IP address is currently banned, taking into account both manual and automatic bans and their remaining duration.
ClearBansRemoves every active ban from the firewall, immediately allowing previously blocked IPs to reconnect (subject to the other firewall checks).
ClearTrackingResets all internal tracking state: per-IP connection counts, brute-force attempt logs, flood-protection message counters and threat scores.
SaveBansToFileWrites the current ban list, including expiry timestamps and escalation levels, to the specified file so it can be restored with LoadBansFromFile.
LoadBansFromFileRestores the active ban list from a file previously written by SaveBansToFile, so bans survive process restarts.
SaveBansToStreamSerializes the active ban list into any writable TStream, useful for persistence backends that are not file-based (databases, network sync, encrypted archives).
LoadBansFromStreamReads ban records from any TStream (memory, network, resource) in the same format produced by SaveBansToStream.

Geo-location

NameDescription
LoadGeoIPDatabaseLoads a MaxMind GeoIP CSV database into memory so subsequent LookupCountry calls and GeoIP country-based filtering can resolve client IPs offline.
LookupCountryReturns the ISO 3166-1 alpha-2 country code for an IP address, using the loaded GeoIP database or the OnResolveCountry event handler.

Threat system

NameDescription
ResetThreatScoreClears the accumulated threat score for a single IP, giving it a clean slate against AutoBanThreshold without affecting other IPs.

All Methods (alphabetical)

NameDescription
BanIPManually bans an IP address for the specified duration, adding it to the active ban list so all subsequent connections from that IP are rejected.
ClearBansRemoves every active ban from the firewall, immediately allowing previously blocked IPs to reconnect (subject to the other firewall checks).
ClearTrackingResets all internal tracking state: per-IP connection counts, brute-force attempt logs, flood-protection message counters and threat scores.
IsBannedReturns True when the given IP address is currently banned, taking into account both manual and automatic bans and their remaining duration.
IsConnectionAllowedCore 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.
IsFrameSizeAllowedChecks a single WebSocket frame size against WebSocketProtection.MaxFrameSize and returns whether it is within the configured limit.
IsMessageAllowedCore per-message filter. Runs the enabled content-inspection modules (SQL injection, XSS, path traversal, command injection, payload limit, flood protection, custom rules) and returns whether the message should be delivered.
IsOriginAllowedChecks a WebSocket Origin header against WebSocketProtection.AllowedOrigins (with wildcard support) and returns whether it is accepted.
IsSubprotocolAllowedChecks the requested WebSocket subprotocol name against WebSocketProtection.AllowedSubprotocols and returns whether it is accepted.
LoadBansFromFileRestores the active ban list from a file previously written by SaveBansToFile, so bans survive process restarts.
LoadBansFromStreamReads ban records from any TStream (memory, network, resource) in the same format produced by SaveBansToStream.
LoadGeoIPDatabaseLoads a MaxMind GeoIP CSV database into memory so subsequent LookupCountry calls and GeoIP country-based filtering can resolve client IPs offline.
LookupCountryReturns the ISO 3166-1 alpha-2 country code for an IP address, using the loaded GeoIP database or the OnResolveCountry event handler.
RegisterConnectionRecords a new accepted connection for the given IP, incrementing the per-IP counters used by RateLimit and feeding the ThreatScore decay window.
RegisterFailedAttemptApplication-level hook that records a failed authentication attempt from the given IP, feeding the BruteForce tracker and potentially triggering an automatic ban.
ResetThreatScoreClears the accumulated threat score for a single IP, giving it a clean slate against AutoBanThreshold without affecting other IPs.
SaveBansToFileWrites the current ban list, including expiry timestamps and escalation levels, to the specified file so it can be restored with LoadBansFromFile.
SaveBansToStreamSerializes the active ban list into any writable TStream, useful for persistence backends that are not file-based (databases, network sync, encrypted archives).
UnbanIPRemoves the active ban record for a single IP address so the client can reconnect on its next attempt.
UnregisterConnectionDecrements the per-IP connection counter when a previously registered connection closes, freeing capacity for RateLimit.