summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-03-16 20:06:49 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-03-16 20:06:49 +0000
commit48f844488a68654ab0ac96c8b850314bdb866a00 (patch)
tree034ce65fd3b8c831ffef73a3a19b1b21292ff626 /src
parent56a5ace638d503099accf4e3461c53b154edaa1d (diff)
Make this work, its all good! :)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9103 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/modules/extra/m_geoip.cpp36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/modules/extra/m_geoip.cpp b/src/modules/extra/m_geoip.cpp
index 57a08ed84..0e5723bc5 100644
--- a/src/modules/extra/m_geoip.cpp
+++ b/src/modules/extra/m_geoip.cpp
@@ -23,10 +23,15 @@ class ModuleGeoIP : public Module
{
GeoIP * gi;
+ bool banunknown;
+
+ std::map<std::string, std::string> GeoBans;
+
+
public:
ModuleGeoIP(InspIRCd *Me) : Module(Me)
{
- ReadConf();
+ OnRehash(NULL, "");
Implementation eventlist[] = { I_OnRehash, I_OnUserRegister };
ServerInstance->Modules->Attach(eventlist, this, 2);
@@ -42,15 +47,20 @@ class ModuleGeoIP : public Module
return Version(1, 2, 0, 0, VF_VENDOR, API_VERSION);
}
- virtual void ReadConf()
- {
- ConfigReader *MyConf = new ConfigReader(ServerInstance);
- delete MyConf;
- }
-
virtual void OnRehash(User* user, const std::string &parameter)
{
- ReadConf();
+ GeoBans.clear();
+
+ ConfigReader conf(ServerInstance);
+
+ banunknown = conf.ReadFlag("geoip", "banunknown", 0);
+
+ for (int i = 0; i < conf.Enumerate("geoban"); ++i)
+ {
+ std::string countrycode = conf.ReadValue("geoban", "country", i);
+ std::string reason = conf.ReadValue("geoban", "reason", i);
+ GeoBans[countrycode] = reason;
+ }
}
virtual int OnUserRegister(User* user)
@@ -61,16 +71,16 @@ class ModuleGeoIP : public Module
const char* c = GeoIP_country_code_by_addr(gi, user->GetIPString());
if (c)
{
- std::string country(c);
- ServerInstance->Logs->Log("m_geoip", DEBUG, "*** Country: %s", country.c_str());
+ std::map<std::string, std::string>::iterator x = GeoBans.find(c);
+ if (x != GeoBans.end())
+ User::QuitUser(ServerInstance, user, x->second);
}
else
{
- ServerInstance->Logs->Log("m_geoip", DEBUG, "*** No country for %s!", user->GetIPString());
+ if (banunknown)
+ User::QuitUser(ServerInstance, user, "Could not identify your country of origin. Access denied.");
}
}
-
- /* don't do anything with this hot potato */
return 0;
}
};