2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2017-2019 Sadie Powell <sadie@witchery.services>
5 * Copyright (C) 2013-2016 Attila Molnar <attilamolnar@hush.com>
6 * Copyright (C) 2013 Daniel Vassdal <shutter@canternet.org>
7 * Copyright (C) 2012 Robby <robby@chatbelgie.be>
8 * Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
9 * Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
10 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
11 * Copyright (C) 2005, 2007-2008 Craig Edwards <brain@inspircd.org>
13 * This file is part of InspIRCd. InspIRCd is free software: you can
14 * redistribute it and/or modify it under the terms of the GNU General Public
15 * License as published by the Free Software Foundation, version 2.
17 * This program is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
28 #include "core_info.h"
32 // From ircd-ratbox with an InspIRCd-specific format.
34 RPL_ENDOFMODLIST = 703
37 CommandModules::CommandModules(Module* parent)
38 : ServerTargetCommand(parent, "MODULES")
41 syntax = "[<servername>]";
46 CmdResult CommandModules::Handle(User* user, const Params& parameters)
48 // Don't ask remote servers about their modules unless the local user asking is an oper
49 // 2.0 asks anyway, so let's handle that the same way
50 bool for_us = (parameters.empty() || irc::equals(parameters[0], ServerInstance->Config->ServerName));
51 if ((!for_us) || (!IS_LOCAL(user)))
55 user->WriteNotice("*** You cannot check what modules other servers have loaded.");
59 // From an oper and not for us, forward
64 const ModuleManager::ModuleMap& mods = ServerInstance->Modules->GetModules();
66 for (ModuleManager::ModuleMap::const_iterator i = mods.begin(); i != mods.end(); ++i)
68 Module* m = i->second;
69 Version V = m->GetVersion();
71 if (IS_LOCAL(user) && user->HasPrivPermission("servers/auspex"))
73 std::string flags("VCO");
75 for (int mult = 2; mult <= VF_OPTCOMMON; mult *= 2, ++pos)
76 if (!(V.Flags & mult))
79 const char* srcrev = m->ModuleDLLManager->GetVersion();
80 user->WriteRemoteNumeric(RPL_MODLIST, m->ModuleSourceFile, srcrev ? "*" : srcrev, flags, V.description);
84 user->WriteRemoteNumeric(RPL_MODLIST, m->ModuleSourceFile, '*', '*', V.description);
87 user->WriteRemoteNumeric(RPL_ENDOFMODLIST, "End of MODULES list");