X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_connectban.cpp;h=d13dc1e0a1f64922a5fce73c3e1a5ce9216771df;hb=6d03943426dcce76ba66567a9b18425a5ebb4c0c;hp=fc8b9aeaa1e1d2efc38553315252a8f114b2989d;hpb=7ae8ab4a17f8ffaee1916faa93ccd0fd9e250e56;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp index fc8b9aeaa..d13dc1e0a 100644 --- a/src/modules/m_connectban.cpp +++ b/src/modules/m_connectban.cpp @@ -2,8 +2,8 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2008 InspIRCd Development Team - * See: http://www.inspircd.org/wiki/index.php/Credits + * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see * the file COPYING for details. @@ -16,7 +16,7 @@ /* $ModDesc: Throttles the connections of any users who try connect flood */ -class ModuleQuitBan : public Module +class ModuleConnectBan : public Module { private: clonemap connects; @@ -25,25 +25,24 @@ class ModuleQuitBan : public Module unsigned int ipv4_cidr; unsigned int ipv6_cidr; public: - ModuleQuitBan(InspIRCd* Me) : Module(Me) - { + ModuleConnectBan() { Implementation eventlist[] = { I_OnUserConnect, I_OnGarbageCollect, I_OnRehash }; ServerInstance->Modules->Attach(eventlist, this, 3); - OnRehash(NULL, ""); + OnRehash(NULL); } - virtual ~ModuleQuitBan() + virtual ~ModuleConnectBan() { } virtual Version GetVersion() { - return Version(1,2,0,0,VF_VENDOR,API_VERSION); + return Version("Throttles the connections of any users who try connect flood", VF_VENDOR,API_VERSION); } - virtual void OnRehash(User* user, const std::string ¶meter) + virtual void OnRehash(User* user) { - ConfigReader Conf(ServerInstance); + ConfigReader Conf; std::string duration; ipv4_cidr = Conf.ReadInteger("connectban", "ipv4cidr", 0, true); @@ -72,19 +71,13 @@ class ModuleQuitBan : public Module int range = 32; clonemap::iterator i; - switch (u->GetProtocolFamily()) + switch (u->client_sa.sa.sa_family) { - #ifdef SUPPORT_IP6LINKS case AF_INET6: - { range = ipv6_cidr; - } break; - #endif case AF_INET: - { range = ipv4_cidr; - } break; } @@ -97,13 +90,15 @@ class ModuleQuitBan : public Module if (i->second >= threshold) { // Create zline for set duration. - ZLine* zl = new ZLine(ServerInstance, ServerInstance->Time(), banduration, ServerInstance->Config->ServerName, "Connect flooding", u->GetCIDRMask(range)); + ZLine* zl = new ZLine(ServerInstance->Time(), banduration, ServerInstance->Config->ServerName, "Connect flooding", u->GetCIDRMask(range)); if (ServerInstance->XLines->AddLine(zl,NULL)) ServerInstance->XLines->ApplyLines(); else delete zl; - ServerInstance->SNO->WriteToSnoMask('x', "Connect flooding from IP range %s (%d)", u->GetCIDRMask(range), threshold); + ServerInstance->SNO->WriteGlobalSno('x',"Module m_connectban added Z:line on *@%s to expire on %s: Connect flooding", + u->GetCIDRMask(range), ServerInstance->TimeString(zl->expiry).c_str()); + ServerInstance->SNO->WriteGlobalSno('a', "Connect flooding from IP range %s (%d)", u->GetCIDRMask(range), threshold); connects.erase(i); } } @@ -115,9 +110,9 @@ class ModuleQuitBan : public Module virtual void OnGarbageCollect() { - ServerInstance->Logs->Log("m_quitban",DEBUG, "Clearing map."); + ServerInstance->Logs->Log("m_connectban",DEBUG, "Clearing map."); connects.clear(); } }; -MODULE_INIT(ModuleQuitBan) +MODULE_INIT(ModuleConnectBan)