1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/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
28 ModuleGeoIP() : ext("geoip_cc", this)
30 gi = GeoIP_new(GEOIP_STANDARD);
35 ServerInstance->Modules->AddService(ext);
36 Implementation eventlist[] = { I_OnSetConnectClass };
37 ServerInstance->Modules->Attach(eventlist, this, 1);
47 return Version("Provides a way to assign users to connect classes by country using GeoIP lookup", VF_VENDOR);
50 ModResult OnSetConnectClass(LocalUser* user, ConnectClass* myclass)
52 std::string* cc = ext.get(user);
55 const char* c = GeoIP_country_code_by_addr(gi, user->GetIPString());
58 cc = new std::string(c);
61 std::string geoip = myclass->config->getString("geoip");
63 return MOD_RES_PASSTHRU;
64 irc::commasepstream list(geoip);
66 while (list.GetToken(country))
68 return MOD_RES_PASSTHRU;
73 MODULE_INIT(ModuleGeoIP)