1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
19 /* $ModDesc: Provides a way to restrict users by country using GeoIP lookup */
20 /* $LinkerFlags: -lGeoIP */
22 class ModuleGeoIP : public Module
27 ModuleGeoIP(InspIRCd *Me) : Module(Me)
30 Implementation eventlist[] = { I_OnRehash, I_OnUserRegister };
31 ServerInstance->Modules->Attach(eventlist, this, 2);
33 gi = GeoIP_new(GEOIP_STANDARD);
36 virtual ~ModuleGeoIP()
40 virtual Version GetVersion()
42 return Version(1, 2, 0, 0, VF_VENDOR, API_VERSION);
45 virtual void ReadConf()
47 ConfigReader *MyConf = new ConfigReader(ServerInstance);
51 virtual void OnRehash(User* user, const std::string ¶meter)
56 virtual int OnUserRegister(User* user)
58 /* only do lookups on local users */
61 const char* c = GeoIP_country_code_by_addr(gi, user->GetIPString());
64 std::string country(c);
65 ServerInstance->Logs->Log("m_geoip", DEBUG, "*** Country: %s", country.c_str());
69 ServerInstance->Logs->Log("m_geoip", DEBUG, "*** No country for %s!", user->GetIPString());
73 /* don't do anything with this hot potato */
78 MODULE_INIT(ModuleGeoIP)