#include "../core/config.h"
#include "../core/hooks.h"
#include "../control/control.h"
+#include "../lib/version.h"
+#include <strings.h>
+
+#include "libGeoIP.h"
#include "geoip.h"
+#warning This module is GPLed. Load/link at your peril.
+
+MODULE_VERSION("");
+
int geoip_totals[COUNTRY_MAX + 1];
int geoip_nickext = -1;
GeoIP *gi = NULL;
}
void geoip_setupuser(nick *np) {
- int country = GeoIP_id_by_ipnum(gi, np->ipaddress);
+ if (!irc_in_addr_is_ipv4(&np->p_ipaddr))
+ return; /* geoip only supports ipv4 */
+
+ unsigned int ip = irc_in_addr_v4_to_int(&np->p_ipaddr);
+ int country = GeoIP_id_by_ipnum(gi, ip);
if((country < COUNTRY_MIN) || (country > COUNTRY_MAX))
return;
}
}
+int geoip_lookupcode(char *code) {
+ int i;
+ for(i=COUNTRY_MIN;i<COUNTRY_MAX;i++)
+ if(!strcasecmp(code, GeoIP_country_code[i]))
+ return i;
+
+ return -1;
+}