2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
6 * This file is part of InspIRCd. InspIRCd is free software: you can
7 * redistribute it and/or modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation, version 2.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 virtual long Run(const std::string& mask) = 0;
34 class Matcher : public MatcherBase
37 long Run(const std::string& mask)
40 const T* c = static_cast<T*>(this);
41 const user_hash& users = ServerInstance->Users->GetUsers();
42 for (user_hash::const_iterator i = users.begin(); i != users.end(); ++i)
44 if (c->Check(i->second, mask))
51 class IPHostMatcher : public Matcher<IPHostMatcher>
54 bool Check(User* user, const std::string& mask) const;
57 /** Check if the given mask matches too many users according to the config, send an announcement if yes
58 * @param mask A mask to match against
59 * @param test The test that determines if a user matches the mask or not
60 * @param user A user whose nick will be included in the announcement if one is made
61 * @param bantype Type of the ban being set, will be used in the announcement if one is made
62 * @param confkey Name of the config key (inside the insane tag) which if false disables any checking
63 * @return True if the given mask matches too many users, false if not
65 static bool MatchesEveryone(const std::string& mask, MatcherBase& test, User* user, const char* bantype, const char* confkey);
70 class CommandEline : public Command
73 /** Constructor for eline.
75 CommandEline(Module* parent);
78 * @param parameters The parameters to the command
79 * @param user The user issuing the command
80 * @return A value from CmdResult to indicate command success or failure.
82 CmdResult Handle(const std::vector<std::string>& parameters, User* user);
87 class CommandGline : public Command
90 /** Constructor for gline.
92 CommandGline(Module* parent);
95 * @param parameters The parameters to the command
96 * @param user The user issuing the command
97 * @return A value from CmdResult to indicate command success or failure.
99 CmdResult Handle(const std::vector<std::string>& parameters, User* user);
104 class CommandKline : public Command
107 /** Constructor for kline.
109 CommandKline(Module* parent);
112 * @param parameters The parameters to the command
113 * @param user The user issuing the command
114 * @return A value from CmdResult to indicate command success or failure.
116 CmdResult Handle(const std::vector<std::string>& parameters, User* user);
121 class CommandQline : public Command
123 class NickMatcher : public InsaneBan::Matcher<NickMatcher>
126 bool Check(User* user, const std::string& mask) const;
130 /** Constructor for qline.
132 CommandQline(Module* parent);
135 * @param parameters The parameters to the command
136 * @param user The user issuing the command
137 * @return A value from CmdResult to indicate command success or failure.
139 CmdResult Handle(const std::vector<std::string>& parameters, User* user);
144 class CommandZline : public Command
146 class IPMatcher : public InsaneBan::Matcher<IPMatcher>
149 bool Check(User* user, const std::string& mask) const;
153 /** Constructor for zline.
155 CommandZline(Module* parent);
158 * @param parameters The parameters to the command
159 * @param user The user issuing the command
160 * @return A value from CmdResult to indicate command success or failure.
162 CmdResult Handle(const std::vector<std::string>& parameters, User* user);