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 * ---------------------------------------------------
17 /* $ModDesc: Throttles the connections of any users who try connect flood */
19 class ModuleQuitBan : public Module
23 unsigned int threshold;
24 unsigned int banduration;
26 ModuleQuitBan(InspIRCd* Me) : Module(Me)
28 Implementation eventlist[] = { I_OnUserConnect, I_OnGarbageCollect, I_OnRehash };
29 ServerInstance->Modules->Attach(eventlist, this, 3);
33 virtual ~ModuleQuitBan()
37 virtual Version GetVersion()
39 return Version(1,2,0,0,VF_VENDOR,API_VERSION);
42 virtual void OnRehash(User* user, const std::string ¶meter)
44 ConfigReader Conf(ServerInstance);
47 threshold = Conf.ReadInteger("connectban", "threshold", 0, true);
52 duration = Conf.ReadValue("connectban", "duration", 0, true);
57 banduration = ServerInstance->Duration(duration);
60 virtual void OnUserConnect(User *u)
62 clonemap::iterator i = connects.find(u->GetIPString());
64 if (i != connects.end())
67 ServerInstance->Logs->Log("m_connectban",DEBUG, "Count for IP is now %d", i->second);
69 if (i->second >= threshold)
71 // Create zline for set duration.
72 ZLine* zl = new ZLine(ServerInstance, ServerInstance->Time(), banduration, ServerInstance->Config->ServerName, "Connect flooding", u->GetIPString());
73 if (ServerInstance->XLines->AddLine(zl,NULL))
74 ServerInstance->XLines->ApplyLines();
78 ServerInstance->SNO->WriteToSnoMask('x', "Connect flooding from IP %s (%d)", u->GetIPString(), threshold);
84 connects[u->GetIPString()] = 1;
85 ServerInstance->Logs->Log("m_quitban",DEBUG, "Added new record");
89 virtual void OnGarbageCollect()
91 ServerInstance->Logs->Log("m_quitban",DEBUG, "Clearing map.");
96 MODULE_INIT(ModuleQuitBan)