logswan

Fast Web log analyzer using probabilistic data structures
Log | Files | Refs | README | LICENSE

commit b97345bb9c0cf0305cfa4283463d9effcebce969
parent cdf6d5cadab4266d1d61ab9dbb762e0c157e48d8
Author: Frederic Cambus <fred@statdns.com>
Date:   Sun, 30 Oct 2016 21:06:42 +0100

Do not attempt to increment countries and continents array if there is no GeoIP database

Diffstat:
Msrc/logswan.c | 18++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/logswan.c b/src/logswan.c @@ -168,14 +168,16 @@ int main (int argc, char *argv[]) { } } - /* Increment countries array */ - results.countries[countryId]++; - - /* Increment continents array */ - for (size_t loop = 0; loop<CONTINENTS; loop++) { - if (!strcmp(continentsId[loop], GeoIP_continent_by_id(countryId))) { - results.continents[loop] ++; - break; + if (geoip || geoipv6) { + /* Increment countries array */ + results.countries[countryId]++; + + /* Increment continents array */ + for (size_t loop = 0; loop<CONTINENTS; loop++) { + if (!strcmp(continentsId[loop], GeoIP_continent_by_id(countryId))) { + results.continents[loop] ++; + break; + } } }