2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
5 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
6 * Copyright (C) 2004-2007 Craig Edwards <craigedwards@brainbox.cc>
7 * Copyright (C) 2006 Oliver Lupton <oliverlupton@gmail.com>
8 * Copyright (C) 2005 Craig McLure <craig@chatspike.net>
10 * This file is part of InspIRCd. InspIRCd is free software: you can
11 * redistribute it and/or modify it under the terms of the GNU General Public
12 * License as published by the Free Software Foundation, version 2.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #include "command_parse.h"
30 /* All other ircds when doing this check usually just look for a string of *@* or *. We're smarter than that, though. */
32 bool InspIRCd::HostMatchesEveryone(const std::string &mask, User* user)
36 ConfigTag* insane = Config->ConfValue("insane");
38 if (insane->getBool("hostmasks"))
41 float itrigger = insane->getFloat("trigger", 95.5);
43 for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++)
45 if ((InspIRCd::MatchCIDR(u->second->MakeHost(), mask, ascii_case_insensitive_map)) ||
46 (InspIRCd::MatchCIDR(u->second->MakeHostIP(), mask, ascii_case_insensitive_map)))
55 float percent = ((float)matches / (float)this->Users->clientlist->size()) * 100;
56 if (percent > itrigger)
58 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.c_str(),mask.c_str(),percent);
64 bool InspIRCd::IPMatchesEveryone(const std::string &ip, User* user)
68 ConfigTag* insane = Config->ConfValue("insane");
70 if (insane->getBool("ipmasks"))
73 float itrigger = insane->getFloat("trigger", 95.5);
75 for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++)
77 if (InspIRCd::MatchCIDR(u->second->GetIPString(), ip, ascii_case_insensitive_map))
84 float percent = ((float)matches / (float)this->Users->clientlist->size()) * 100;
85 if (percent > itrigger)
87 SNO->WriteToSnoMask('a', "\2WARNING\2: %s tried to set a Z line mask of %s, which covers %.2f%% of the network!",user->nick.c_str(),ip.c_str(),percent);
93 bool InspIRCd::NickMatchesEveryone(const std::string &nick, User* user)
97 ConfigTag* insane = Config->ConfValue("insane");
99 if (insane->getBool("nickmasks"))
102 float itrigger = insane->getFloat("trigger", 95.5);
104 for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++)
106 if (InspIRCd::Match(u->second->nick, nick))
113 float percent = ((float)matches / (float)this->Users->clientlist->size()) * 100;
114 if (percent > itrigger)
116 SNO->WriteToSnoMask('a', "\2WARNING\2: %s tried to set a Q line mask of %s, which covers %.2f%% of the network!",user->nick.c_str(),nick.c_str(),percent);
122 CmdResult SplitCommand::Handle(const std::vector<std::string>& parms, User* u)
125 return HandleLocal(parms, IS_LOCAL(u));
127 return HandleRemote(parms, IS_REMOTE(u));
129 return HandleServer(parms, IS_SERVER(u));
130 ServerInstance->Logs->Log("COMMAND", DEFAULT, "Unknown user type in command (uuid=%s)!", u->uuid.c_str());
134 CmdResult SplitCommand::HandleLocal(const std::vector<std::string>&, LocalUser*)
139 CmdResult SplitCommand::HandleRemote(const std::vector<std::string>&, RemoteUser*)
144 CmdResult SplitCommand::HandleServer(const std::vector<std::string>&, FakeUser*)