X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_connectban.cpp;h=f831a3b77b1ba50873c374efe77a065f29d8d1ed;hb=44f42a13de52c8025942ddab42f51feb36821782;hp=d13dc1e0a1f64922a5fce73c3e1a5ce9216771df;hpb=6d03943426dcce76ba66567a9b18425a5ebb4c0c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp index d13dc1e0a..f831a3b77 100644 --- a/src/modules/m_connectban.cpp +++ b/src/modules/m_connectban.cpp @@ -1,16 +1,22 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits + * Copyright (C) 2008 Robin Burchell * - * This program is free but copyrighted software; see - * the file COPYING for details. + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. * - * --------------------------------------------------- + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + #include "inspircd.h" #include "xline.h" @@ -37,7 +43,7 @@ class ModuleConnectBan : public Module virtual Version GetVersion() { - return Version("Throttles the connections of any users who try connect flood", VF_VENDOR,API_VERSION); + return Version("Throttles the connections of any users who try connect flood", VF_VENDOR); } virtual void OnRehash(User* user) @@ -66,7 +72,7 @@ class ModuleConnectBan : public Module banduration = ServerInstance->Duration(duration); } - virtual void OnUserConnect(User *u) + virtual void OnUserConnect(LocalUser *u) { int range = 32; clonemap::iterator i; @@ -81,7 +87,8 @@ class ModuleConnectBan : public Module break; } - i = connects.find(u->GetCIDRMask(range)); + irc::sockets::cidr_mask mask(u->client_sa, range); + i = connects.find(mask); if (i != connects.end()) { @@ -90,21 +97,21 @@ class ModuleConnectBan : public Module if (i->second >= threshold) { // Create zline for set duration. - ZLine* zl = new ZLine(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->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); + 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; } }