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"
25 CommandModules::CommandModules(Module* parent)
26 : Command(parent, "MODULES", 0, 0)
29 syntax = "[<servername>]";
34 CmdResult CommandModules::Handle (const std::vector<std::string>& parameters, User *user)
36 // Don't ask remote servers about their modules unless the local user asking is an oper
37 // 2.0 asks anyway, so let's handle that the same way
38 bool for_us = (parameters.empty() || parameters[0] == ServerInstance->Config->ServerName);
39 if ((!for_us) || (!IS_LOCAL(user)))
43 user->WriteNotice("*** You cannot check what modules other servers have loaded.");
47 // From an oper and not for us, forward
52 const ModuleManager::ModuleMap& mods = ServerInstance->Modules->GetModules();
54 for (ModuleManager::ModuleMap::const_iterator i = mods.begin(); i != mods.end(); ++i)
56 Module* m = i->second;
57 Version V = m->GetVersion();
59 if (IS_LOCAL(user) && user->HasPrivPermission("servers/auspex"))
61 std::string flags("SvcC");
63 for (int mult = 1; mult <= VF_OPTCOMMON; mult *= 2, ++pos)
64 if (!(V.Flags & mult))
68 user->SendText(":%s 702 %s :%p %s %s :%s", ServerInstance->Config->ServerName.c_str(),
69 user->nick.c_str(), (void*)m, m->ModuleSourceFile.c_str(), flags.c_str(), V.description.c_str());
71 std::string srcrev = m->ModuleDLLManager->GetVersion();
72 user->SendText(":%s 702 %s :%p %s %s :%s - %s", ServerInstance->Config->ServerName.c_str(),
73 user->nick.c_str(), (void*)m, m->ModuleSourceFile.c_str(), flags.c_str(), V.description.c_str(), srcrev.c_str());
78 user->SendText(":%s 702 %s :%s %s", ServerInstance->Config->ServerName.c_str(),
79 user->nick.c_str(), m->ModuleSourceFile.c_str(), V.description.c_str());
82 user->SendText(":%s 703 %s :End of MODULES list", ServerInstance->Config->ServerName.c_str(), user->nick.c_str());
87 RouteDescriptor CommandModules::GetRouting(User* user, const std::vector<std::string>& parameters)
89 if (parameters.size() >= 1)
90 return ROUTE_UNICAST(parameters[0]);
91 return ROUTE_LOCALONLY;