TsgcWebSocketFirewallMethods › LoadGeoIPDatabase

LoadGeoIPDatabase Method

Loads a MaxMind GeoIP CSV database into memory so subsequent LookupCountry calls and GeoIP country-based filtering can resolve client IPs offline.

Syntax

procedure LoadGeoIPDatabase(const aFileName: string);

Parameters

NameTypeDescription
aFileNameconst stringPath to a GeoIP CSV file. Expected format per line: start_ip,end_ip,country_code. Both IPv4 and IPv6 ranges are supported.

Remarks

Call LoadGeoIPDatabase once at start-up — typically before the server goes live — so the lookup index is built up front and subsequent connection checks do not block on disk I/O. Loading is additive: calling it again merges another file into the current index. If you prefer on-the-fly resolution (for example via a third-party library or a web service), leave the database unloaded and handle OnResolveCountry instead. GeoIP filtering is only active when GeoIP.Enabled is True and the country list is populated.

Example

sgcWebSocketFirewall1.GeoIP.Enabled := True;
sgcWebSocketFirewall1.GeoIP.Mode := gmBlockList;
sgcWebSocketFirewall1.GeoIP.Countries.Add('CN');
sgcWebSocketFirewall1.LoadGeoIPDatabase('geoip.csv');

Back to Methods