2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2019 Robby <robby@chatbelgie.be>
5 * Copyright (C) 2019 Matt Schatz <genius3000@g3k.solutions>
6 * Copyright (C) 2017-2018 Sadie Powell <sadie@witchery.services>
7 * Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
9 * This file is part of InspIRCd. InspIRCd is free software: you can
10 * redistribute it and/or modify it under the terms of the GNU General Public
11 * License as published by the Free Software Foundation, version 2.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
33 virtual long Run(const std::string& mask) = 0;
37 class Matcher : public MatcherBase
40 long Run(const std::string& mask) CXX11_OVERRIDE
43 const T* c = static_cast<T*>(this);
44 const user_hash& users = ServerInstance->Users->GetUsers();
45 for (user_hash::const_iterator i = users.begin(); i != users.end(); ++i)
47 if (c->Check(i->second, mask))
54 class IPHostMatcher : public Matcher<IPHostMatcher>
57 bool Check(User* user, const std::string& mask) const;
60 /** Check if the given mask matches too many users according to the config, send an announcement if yes
61 * @param mask A mask to match against
62 * @param test The test that determines if a user matches the mask or not
63 * @param user A user whose nick will be included in the announcement if one is made
64 * @param bantype Type of the ban being set, will be used in the announcement if one is made
65 * @param confkey Name of the config key (inside the insane tag) which if false disables any checking
66 * @return True if the given mask matches too many users, false if not
68 static bool MatchesEveryone(const std::string& mask, MatcherBase& test, User* user, const char* bantype, const char* confkey);
73 class CommandEline : public Command
76 /** Constructor for E-line.
78 CommandEline(Module* parent);
81 * @param parameters The parameters to the command
82 * @param user The user issuing the command
83 * @return A value from CmdResult to indicate command success or failure.
85 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
90 class CommandGline : public Command
93 /** Constructor for G-line.
95 CommandGline(Module* parent);
98 * @param parameters The parameters to the command
99 * @param user The user issuing the command
100 * @return A value from CmdResult to indicate command success or failure.
102 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
107 class CommandKline : public Command
110 /** Constructor for K-line.
112 CommandKline(Module* parent);
115 * @param parameters The parameters to the command
116 * @param user The user issuing the command
117 * @return A value from CmdResult to indicate command success or failure.
119 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
124 class CommandQline : public Command
126 class NickMatcher : public InsaneBan::Matcher<NickMatcher>
129 bool Check(User* user, const std::string& mask) const;
133 /** Constructor for Q-line.
135 CommandQline(Module* parent);
138 * @param parameters The parameters to the command
139 * @param user The user issuing the command
140 * @return A value from CmdResult to indicate command success or failure.
142 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;
147 class CommandZline : public Command
149 class IPMatcher : public InsaneBan::Matcher<IPMatcher>
152 bool Check(User* user, const std::string& mask) const;
156 /** Constructor for Z-line.
158 CommandZline(Module* parent);
161 * @param parameters The parameters to the command
162 * @param user The user issuing the command
163 * @return A value from CmdResult to indicate command success or failure.
165 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE;