2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
5 * Copyright (C) 2008 Craig Edwards <craigedwards@brainbox.cc>
6 * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
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 "core_info.h"
27 // From ircd-ratbox with an InspIRCd-specific format.
29 RPL_ENDOFMODLIST = 703
32 CommandModules::CommandModules(Module* parent)
33 : ServerTargetCommand(parent, "MODULES")
36 syntax = "[<servername>]";
41 CmdResult CommandModules::Handle (const std::vector<std::string>& parameters, User *user)
43 // Don't ask remote servers about their modules unless the local user asking is an oper
44 // 2.0 asks anyway, so let's handle that the same way
45 bool for_us = (parameters.empty() || parameters[0] == ServerInstance->Config->ServerName);
46 if ((!for_us) || (!IS_LOCAL(user)))
50 user->WriteNotice("*** You cannot check what modules other servers have loaded.");
54 // From an oper and not for us, forward
59 const ModuleManager::ModuleMap& mods = ServerInstance->Modules->GetModules();
61 for (ModuleManager::ModuleMap::const_iterator i = mods.begin(); i != mods.end(); ++i)
63 Module* m = i->second;
64 Version V = m->GetVersion();
66 if (IS_LOCAL(user) && user->HasPrivPermission("servers/auspex"))
68 std::string flags("VCO");
70 for (int mult = 2; mult <= VF_OPTCOMMON; mult *= 2, ++pos)
71 if (!(V.Flags & mult))
74 #ifdef INSPIRCD_STATIC
75 user->WriteRemoteNumeric(RPL_MODLIST, m->ModuleSourceFile, INSPIRCD_VERSION, flags, V.description);
77 std::string srcrev = m->ModuleDLLManager->GetVersion();
78 user->WriteRemoteNumeric(RPL_MODLIST, m->ModuleSourceFile, srcrev.empty() ? "*" : srcrev, flags, V.description);
83 user->WriteRemoteNumeric(RPL_MODLIST, m->ModuleSourceFile, '*', '*', V.description);
86 user->WriteRemoteNumeric(RPL_ENDOFMODLIST, "End of MODULES list");