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 * ---------------------------------------------------
14 /* $Core: libIRCDcommands */
19 #include "command_parse.h"
21 /* All other ircds when doing this check usually just look for a string of *@* or *. We're smarter than that, though. */
23 bool InspIRCd::HostMatchesEveryone(const std::string &mask, User* user)
25 char itrigger[MAXBUF];
28 if (!Config->ConfValue(Config->config_data, "insane","trigger", 0, itrigger, MAXBUF))
29 strlcpy(itrigger,"95.5",MAXBUF);
31 if (Config->ConfValueBool(Config->config_data, "insane","hostmasks", 0))
34 for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++)
36 if ((match(u->second->MakeHost(),mask.c_str(),true)) || (match(u->second->MakeHostIP(),mask.c_str(),true)))
45 float percent = ((float)matches / (float)this->Users->clientlist->size()) * 100;
46 if (percent > (float)atof(itrigger))
48 SNO->WriteToSnoMask('A', "\2WARNING\2: %s tried to set a G/K/E line mask of %s, which covers %.2f%% of the network!",user->nick,mask.c_str(),percent);
54 bool InspIRCd::IPMatchesEveryone(const std::string &ip, User* user)
56 char itrigger[MAXBUF];
59 if (!Config->ConfValue(Config->config_data, "insane","trigger",0,itrigger,MAXBUF))
60 strlcpy(itrigger,"95.5",MAXBUF);
62 if (Config->ConfValueBool(Config->config_data, "insane","ipmasks",0))
65 for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++)
67 if (match(u->second->GetIPString(),ip.c_str(),true))
74 float percent = ((float)matches / (float)this->Users->clientlist->size()) * 100;
75 if (percent > (float)atof(itrigger))
77 SNO->WriteToSnoMask('A', "\2WARNING\2: %s tried to set a Z line mask of %s, which covers %.2f%% of the network!",user->nick,ip.c_str(),percent);
83 bool InspIRCd::NickMatchesEveryone(const std::string &nick, User* user)
85 char itrigger[MAXBUF];
88 if (!Config->ConfValue(Config->config_data, "insane","trigger",0,itrigger,MAXBUF))
89 strlcpy(itrigger,"95.5",MAXBUF);
91 if (Config->ConfValueBool(Config->config_data, "insane","nickmasks",0))
94 for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++)
96 if (match(u->second->nick,nick.c_str()))
103 float percent = ((float)matches / (float)this->Users->clientlist->size()) * 100;
104 if (percent > (float)atof(itrigger))
106 SNO->WriteToSnoMask('A', "\2WARNING\2: %s tried to set a Q line mask of %s, which covers %.2f%% of the network!",user->nick,nick.c_str(),percent);