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/>.
26 #include "command_parse.h"
28 /* All other ircds when doing this check usually just look for a string of *@* or *. We're smarter than that, though. */
30 bool InspIRCd::HostMatchesEveryone(const std::string &mask, User* user)
34 ConfigTag* insane = Config->ConfValue("insane");
36 if (insane->getBool("hostmasks"))
39 float itrigger = insane->getFloat("trigger", 95.5);
41 for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++)
43 if ((InspIRCd::Match(u->second->MakeHost(), mask, ascii_case_insensitive_map)) ||
44 (InspIRCd::Match(u->second->MakeHostIP(), mask, ascii_case_insensitive_map)))
53 float percent = ((float)matches / (float)this->Users->clientlist->size()) * 100;
54 if (percent > itrigger)
56 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);
62 bool InspIRCd::IPMatchesEveryone(const std::string &ip, User* user)
66 ConfigTag* insane = Config->ConfValue("insane");
68 if (insane->getBool("ipmasks"))
71 float itrigger = insane->getFloat("trigger", 95.5);
73 for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++)
75 if (InspIRCd::Match(u->second->GetIPString(), ip, ascii_case_insensitive_map))
82 float percent = ((float)matches / (float)this->Users->clientlist->size()) * 100;
83 if (percent > itrigger)
85 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);
91 bool InspIRCd::NickMatchesEveryone(const std::string &nick, User* user)
95 ConfigTag* insane = Config->ConfValue("insane");
97 if (insane->getBool("nickmasks"))
100 float itrigger = insane->getFloat("trigger", 95.5);
102 for (user_hash::iterator u = this->Users->clientlist->begin(); u != this->Users->clientlist->end(); u++)
104 if (InspIRCd::Match(u->second->nick, nick))
111 float percent = ((float)matches / (float)this->Users->clientlist->size()) * 100;
112 if (percent > itrigger)
114 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);
120 CmdResult SplitCommand::Handle(const std::vector<std::string>& parms, User* u)
123 return HandleLocal(parms, IS_LOCAL(u));
125 return HandleRemote(parms, IS_REMOTE(u));
127 return HandleServer(parms, IS_SERVER(u));
128 ServerInstance->Logs->Log("COMMAND", LOG_DEFAULT, "Unknown user type in command (uuid=%s)!", u->uuid.c_str());
132 CmdResult SplitCommand::HandleLocal(const std::vector<std::string>&, LocalUser*)
137 CmdResult SplitCommand::HandleRemote(const std::vector<std::string>&, RemoteUser*)
142 CmdResult SplitCommand::HandleServer(const std::vector<std::string>&, FakeUser*)