2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
5 * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
6 * Copyright (C) 2006-2007 Craig Edwards <craigedwards@brainbox.cc>
8 * This file is part of InspIRCd. InspIRCd is free software: you can
9 * redistribute it and/or modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation, version 2.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "modules/account.h"
25 class ModuleSecureList : public Module
27 std::vector<std::string> allowlist;
28 bool exemptregistered;
29 unsigned int WaitTime;
32 Version GetVersion() CXX11_OVERRIDE
34 return Version("Disallows /LIST for recently connected clients to hinder spam bots", VF_VENDOR);
37 void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
41 ConfigTagList tags = ServerInstance->Config->ConfTags("securehost");
42 for (ConfigIter i = tags.first; i != tags.second; ++i)
43 allowlist.push_back(i->second->getString("exception"));
45 ConfigTag* tag = ServerInstance->Config->ConfValue("securelist");
46 exemptregistered = tag->getBool("exemptregistered");
47 WaitTime = tag->getDuration("waittime", 60, 1);
53 * Intercept the LIST command.
55 ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) CXX11_OVERRIDE
57 /* If the command doesnt appear to be valid, we dont want to mess with it. */
59 return MOD_RES_PASSTHRU;
61 if ((command == "LIST") && (ServerInstance->Time() < (user->signon+WaitTime)) && (!user->IsOper()))
63 /* Normally wouldnt be allowed here, are they exempt? */
64 for (std::vector<std::string>::iterator x = allowlist.begin(); x != allowlist.end(); x++)
65 if (InspIRCd::Match(user->MakeHost(), *x, ascii_case_insensitive_map))
66 return MOD_RES_PASSTHRU;
68 const AccountExtItem* ext = GetAccountExtItem();
69 if (exemptregistered && ext && ext->get(user))
70 return MOD_RES_PASSTHRU;
72 /* Not exempt, BOOK EM DANNO! */
73 user->WriteNotice("*** You cannot list within the first " + ConvToStr(WaitTime) + " seconds of connecting. Please try again later.");
74 /* Some clients (e.g. mIRC, various java chat applets) muck up if they don't
75 * receive these numerics whenever they send LIST, so give them an empty LIST to mull over.
77 user->WriteNumeric(RPL_LISTSTART, "Channel", "Users Name");
78 user->WriteNumeric(RPL_LISTEND, "End of channel list.");
81 return MOD_RES_PASSTHRU;
84 void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
90 MODULE_INIT(ModuleSecureList)