2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
5 * Copyright (C) 2006-2007 Craig Edwards <craigedwards@brainbox.cc>
7 * This file is part of InspIRCd. InspIRCd is free software: you can
8 * redistribute it and/or modify it under the terms of the GNU General Public
9 * License as published by the Free Software Foundation, version 2.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 class CommandTline : public Command
28 CommandTline(Module* Creator) : Command(Creator,"TLINE", 1)
30 flags_needed = 'o'; this->syntax = "<mask>";
33 CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE
35 unsigned int n_matched = 0;
36 unsigned int n_match_host = 0;
37 unsigned int n_match_ip = 0;
39 const user_hash& users = ServerInstance->Users->GetUsers();
40 for (user_hash::const_iterator u = users.begin(); u != users.end(); ++u)
42 if (InspIRCd::Match(u->second->GetFullRealHost(),parameters[0]))
49 std::string host = u->second->ident + "@" + u->second->GetIPString();
50 if (InspIRCd::MatchCIDR(host, parameters[0]))
58 unsigned long n_counted = users.size();
61 float p = (n_matched / (float)n_counted) * 100;
62 user->WriteNotice(InspIRCd::Format("*** TLINE: Counted %lu user(s). Matched '%s' against %u user(s) (%0.2f%% of the userbase). %u by hostname and %u by IP address.", n_counted, parameters[0].c_str(), n_matched, p, n_match_host, n_match_ip));
65 user->WriteNotice(InspIRCd::Format("*** TLINE: Counted %lu user(s). Matched '%s' against no user(s).", n_counted, parameters[0].c_str()));
71 class ModuleTLine : public Module
80 Version GetVersion() CXX11_OVERRIDE
82 return Version("Provides /tline command used to test who a mask matches", VF_VENDOR);
86 MODULE_INIT(ModuleTLine)