-
Notifications
You must be signed in to change notification settings - Fork 0
4.7.6 Configuration Ip2location Proxy BIN File Access Mode
PHPFirewall uses ip2location provided Proxy BIN file and libraries to perform the lookup. The ip2location proxy library for PHP is located at: https://github.com/ip2location/ip2proxy-php
The above library provides methods to extract data from the BIN file using the following 3 modes:
- FILE_IO
- SHARED_MEMORY
- MEMORY_CACHE.
Default mode is FILE_IO. The SHARED_MEMORY utilizes PHP Shmop functions to store data in the systems shared memory space and MEMORY_CACHE utilizes php allocated memory space (using php.ini). Regardless of what you choose, you need to make sure your system has that much amount of memory to load the whole database into the memory to perform the lookups. The IP2Location-PHP-Module will check the memory allocation and throw an exception if there is not enough memory. In that case, you can switch to FILE_IO.
NOTE: I have tested the above lookups and would advice to load the file into SHARED_MEMORY or MEMORY_CACHE for a faster lookup. If memory is an issue, FILE_IO also performed well. In the end, PHPFirewall saves the lookups in a separate database and indexes them. So, PHPFirewall does not touch the BIN file after the first successful lookup is made and indexed.
admin@phpterminal:firewall(config)# set ip2location proxy bin access mode
...
OPTIONS: [SHARED_MEMORY | MEMORY_CACHE | FILE_IO]
PROXY BIN ACCESS MODE (FILE_IO) : MEMORY_CACHE
SET IP2LOCATION PROXY BIN ACCESS MODE OUTPUT
...
FIREWALL DETAILS > IP2LOCATION_PROXY_BIN_ACCESS_MODE : MEMORY_CACHE
...
admin@phpterminal:firewall(config)#
$firewall->setIp2locationProxyBinAccessMode('MEMORY_CACHE');