X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_connectban.cpp;h=f9dc37b36ff9910530d8fad64e57e6d9ad4fb69c;hb=46e56dedd37abe33af4e8b970d5b83729dc1ef05;hp=8a5a1cb926f2d1ad9d6c31ff7f570ec1c07ac0ee;hpb=b6dbd6caab62bc2c0d11ce5a45d511611eb9c2ef;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp index 8a5a1cb92..f9dc37b36 100644 --- a/src/modules/m_connectban.cpp +++ b/src/modules/m_connectban.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * InspIRCd: (C) 2002-2010 InspIRCd Development Team * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see @@ -25,11 +25,10 @@ class ModuleConnectBan : public Module unsigned int ipv4_cidr; unsigned int ipv6_cidr; public: - ModuleConnectBan(InspIRCd* Me) : Module(Me) - { + ModuleConnectBan() { Implementation eventlist[] = { I_OnUserConnect, I_OnGarbageCollect, I_OnRehash }; ServerInstance->Modules->Attach(eventlist, this, 3); - OnRehash(NULL, ""); + OnRehash(NULL); } virtual ~ModuleConnectBan() @@ -38,12 +37,12 @@ class ModuleConnectBan : public Module virtual Version GetVersion() { - return Version("$Id$", VF_VENDOR,API_VERSION); + return Version("Throttles the connections of any users who try connect flood", VF_VENDOR); } - 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); @@ -67,28 +66,23 @@ class ModuleConnectBan : public Module banduration = ServerInstance->Duration(duration); } - virtual void OnUserConnect(User *u) + virtual void OnUserConnect(LocalUser *u) { 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; } - i = connects.find(u->GetCIDRMask(range)); + irc::sockets::cidr_mask mask(u->client_sa, range); + i = connects.find(mask); if (i != connects.end()) { @@ -97,19 +91,21 @@ class ModuleConnectBan : 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, "Your IP range has been attempting to connect too many times in too short a duration. Wait a while, and you will be able to connect.", mask.str()); 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", + mask.str().c_str(), ServerInstance->TimeString(zl->expiry).c_str()); + ServerInstance->SNO->WriteGlobalSno('a', "Connect flooding from IP range %s (%d)", mask.str().c_str(), threshold); connects.erase(i); } } else { - connects[u->GetCIDRMask(range)] = 1; + connects[mask] = 1; } }