X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/blobdiff_plain/21f6caee9936b429da5fcd482b4907315fcb109a..7a27854095fb80ce76e2ef5a59e87f42fbbe45fe:/src/hash.c diff --git a/src/hash.c b/src/hash.c index c5e99fc..defbf84 100644 --- a/src/hash.c +++ b/src/hash.c @@ -23,11 +23,12 @@ #include "hash.h" #include "log.h" -#ifdef HAVE_GEOIP_H +#if defined(HAVE_LIBGEOIP)&&defined(HAVE_GEOIP_H)&&defined(HAVE_GEOIPCITY_H) #include -#endif -#ifdef HAVE_GEOIPCITY_H #include + +GeoIP * gi = NULL; +GeoIP * cgi = NULL; #endif struct server *self; @@ -256,10 +257,10 @@ assign_fakehost(struct userNode *user, const char *host, int announce) void set_geoip_info(struct userNode *user) { + if(IsLocal(user)) + return; /* Need the libs and the headers if this is going to compile properly */ #if defined(HAVE_LIBGEOIP)&&defined(HAVE_GEOIP_H)&&defined(HAVE_GEOIPCITY_H) - GeoIP * gi = NULL; - GeoIP * cgi = NULL; GeoIPRecord * gir; const char *geoip_data_file = NULL; const char *geoip_city_file = NULL; @@ -267,14 +268,14 @@ set_geoip_info(struct userNode *user) geoip_data_file = conf_get_data("services/opserv/geoip_data_file", RECDB_QSTRING); geoip_city_file = conf_get_data("services/opserv/geoip_city_data_file", RECDB_QSTRING); - if ((!geoip_data_file && !geoip_city_file) || IsLocal(user)) + if ((!geoip_data_file && !geoip_city_file)) return; /* Admin doesnt want to use geoip functions */ - if (geoip_data_file) - gi = GeoIP_open(geoip_data_file, GEOIP_STANDARD | GEOIP_CHECK_CACHE); + if (geoip_data_file && !gi) + gi = GeoIP_open(geoip_data_file, GEOIP_MEMORY_CACHE | GEOIP_CHECK_CACHE); - if (geoip_city_file) - cgi = GeoIP_open(geoip_city_file, GEOIP_INDEX_CACHE); + if (geoip_city_file && !cgi) + cgi = GeoIP_open(geoip_city_file, GEOIP_MEMORY_CACHE | GEOIP_CHECK_CACHE); if (cgi) { gir = GeoIP_record_by_name(cgi, user->hostname); @@ -293,12 +294,10 @@ set_geoip_info(struct userNode *user) GeoIPRecord_delete(gir); } - GeoIP_delete(cgi); return; } else if (gi) { const char *country = GeoIP_country_name_by_name(gi, user->hostname); user->country_name = strdup(country ? country : ""); - GeoIP_delete(gi); return; }