summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-03-16 22:34:00 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-03-16 22:34:00 +0000
commit813b671227cd4c9bdfb584b2ca7ad705620cd2c5 (patch)
treed2f80e12f71d34e565d12ac255800add6772b663
parentdf2faa39f2f1f174eb3821c5108369e47ff1b531 (diff)
Remote /MODULES
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6688 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/cmd_modules.cpp38
-rw-r--r--src/modules/m_spanningtree/main.cpp27
-rw-r--r--src/modules/m_spanningtree/main.h4
-rw-r--r--src/modules/m_spanningtree/treesocket.h3
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp59
5 files changed, 84 insertions, 47 deletions
diff --git a/src/cmd_modules.cpp b/src/cmd_modules.cpp
index 7d2700933..6f7633cc9 100644
--- a/src/cmd_modules.cpp
+++ b/src/cmd_modules.cpp
@@ -62,43 +62,7 @@ CmdResult cmd_modules::Handle (const char** parameters, int pcnt, userrec *user)
strlcpy(modulename,ServerInstance->Config->module_names[i].c_str(),256);
if (*user->oper)
{
- if ((pcnt >= 2) && (!strcasecmp(parameters[0],"debug")))
- {
- if (match(ServerInstance->Config->module_names[i].c_str(),parameters[1]))
- {
- user->WriteServ("900 %s :0x%08lx %d.%d.%d.%d %s (%s)",user->nick,ServerInstance->modules[i],V.Major,V.Minor,V.Revision,V.Build,ServerConfig::CleanFilename(modulename),flagstate+2);
- for (int it = 0; itab[it];)
- {
- char data[MAXBUF];
- char dlist[MAXBUF];
- *dlist = 0;
- for (int v = 0; v < 4; v++)
- {
- if (itab[it])
- {
- if (ServerInstance->Config->implement_lists[i][it])
- {
- snprintf(data,MAXBUF,"%s=>%c ",itab[it],(ServerInstance->Config->implement_lists[i][it] ? '1' : '0'));
- strlcat(dlist,data,MAXBUF);
- }
- it++;
- }
- }
- if (*dlist)
- user->WriteServ("900 %s :%s [ %s]",user->nick,ServerConfig::CleanFilename(modulename),dlist);
- }
- user->WriteServ("900 %s :=== DEBUG: Implementation counts ===",user->nick);
- for (int it = 0; itab[it]; it++)
- {
- if (ServerInstance->Config->global_implementation[it])
- user->WriteServ("900 %s :%s: %d times",user->nick, itab[it],(int)ServerInstance->Config->global_implementation[it]);
- }
- }
- }
- else
- {
- user->WriteServ("900 %s :0x%08lx %d.%d.%d.%d %s (%s)",user->nick,ServerInstance->modules[i],V.Major,V.Minor,V.Revision,V.Build,ServerConfig::CleanFilename(modulename),flagstate+2);
- }
+ user->WriteServ("900 %s :0x%08lx %d.%d.%d.%d %s (%s)",user->nick,ServerInstance->modules[i],V.Major,V.Minor,V.Revision,V.Build,ServerConfig::CleanFilename(modulename),flagstate+2);
}
else
{
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 1fd33b946..f286ae104 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -199,13 +199,9 @@ int ModuleSpanningTree::HandleMotd(const char** parameters, int pcnt, userrec* u
/* Send it out remotely, generate no reply yet */
TreeServer* s = Utils->FindServerMask(parameters[0]);
if (s)
- {
Utils->DoOneToOne(user->nick, "MOTD", params, s->GetName());
- }
else
- {
user->WriteServ( "402 %s %s :No such server", user->nick, parameters[0]);
- }
return 1;
}
return 0;
@@ -221,18 +217,26 @@ int ModuleSpanningTree::HandleAdmin(const char** parameters, int pcnt, userrec*
/* Send it out remotely, generate no reply yet */
TreeServer* s = Utils->FindServerMask(parameters[0]);
if (s)
- {
Utils->DoOneToOne(user->nick, "ADMIN", params, s->GetName());
- }
else
- {
user->WriteServ( "402 %s %s :No such server", user->nick, parameters[0]);
- }
return 1;
}
return 0;
}
+int ModuleSpanningTree::HandleModules(const char** parameters, int pcnt, userrec* user)
+{
+ std::deque<std::string> params;
+ params.push_back(parameters[0]);
+ TreeServer* s = Utils->FindServerMask(parameters[0]);
+ if (s)
+ Utils->DoOneToOne(user->nick, "MODULES", params, s->GetName());
+ else
+ user->WriteServ( "402 %s %s :No such server", user->nick, parameters[0]);
+ return 1;
+}
+
int ModuleSpanningTree::HandleStats(const char** parameters, int pcnt, userrec* user)
{
if (pcnt > 1)
@@ -249,9 +253,7 @@ int ModuleSpanningTree::HandleStats(const char** parameters, int pcnt, userrec*
Utils->DoOneToOne(user->nick, "STATS", params, s->GetName());
}
else
- {
user->WriteServ( "402 %s %s :No such server", user->nick, parameters[0]);
- }
return 1;
}
return 0;
@@ -649,6 +651,11 @@ int ModuleSpanningTree::OnPreCommand(const std::string &command, const char** pa
this->HandleVersion(parameters,pcnt,user);
return 1;
}
+ else if ((command == "MODULES") && (pcnt > 0))
+ {
+ this->HandleModules(parameters,pcnt,user);
+ return 1;
+ }
return 0;
}
diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h
index 4bf11ddd7..2c5d08c6a 100644
--- a/src/modules/m_spanningtree/main.h
+++ b/src/modules/m_spanningtree/main.h
@@ -95,6 +95,10 @@ class ModuleSpanningTree : public Module
*/
int HandleRemoteWhois(const char** parameters, int pcnt, userrec* user);
+ /** Handle remote MODULES
+ */
+ int HandleModules(const char** parameters, int pcnt, userrec* user);
+
/** Ping all local servers
*/
void DoPingChecks(time_t curtime);
diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h
index 5a5ec52f8..54b506c57 100644
--- a/src/modules/m_spanningtree/treesocket.h
+++ b/src/modules/m_spanningtree/treesocket.h
@@ -228,6 +228,9 @@ class TreeSocket : public InspSocket
/** remote ADMIN. leet, huh? */
bool Admin(const std::string &prefix, std::deque<std::string> &params);
+ /** Remote MODULES */
+ bool Modules(const std::string &prefix, std::deque<std::string> &params);
+
bool Stats(const std::string &prefix, std::deque<std::string> &params);
/** Because the core won't let users or even SERVERS set +o,
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index db06a47c5..128f4613e 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -38,6 +38,61 @@ bool TreeSocket::Error(std::deque<std::string> &params)
return false;
}
+bool TreeSocket::Modules(const std::string &prefix, std::deque<std::string> &params)
+{
+ if (params.empty())
+ return true;
+
+ if (!this->Instance->MatchText(this->Instance->Config->ServerName, params[0]))
+ {
+ /* Pass it on, not for us */
+ Utils->DoOneToOne(prefix, "MODULES", params, params[0]);
+ return true;
+ }
+
+ char strbuf[MAXBUF];
+ std::deque<std::string> par;
+ par.push_back(prefix);
+ par.push_back("");
+
+ userrec* source = this->Instance->FindNick(prefix);
+ if (!source)
+ return true;
+
+ for (unsigned int i = 0; i < Instance->Config->module_names.size(); i++)
+ {
+ Version V = Instance->modules[i]->GetVersion();
+ char modulename[MAXBUF];
+ char flagstate[MAXBUF];
+ *flagstate = 0;
+ if (V.Flags & VF_STATIC)
+ strlcat(flagstate,", static",MAXBUF);
+ if (V.Flags & VF_VENDOR)
+ strlcat(flagstate,", vendor",MAXBUF);
+ if (V.Flags & VF_COMMON)
+ strlcat(flagstate,", common",MAXBUF);
+ if (V.Flags & VF_SERVICEPROVIDER)
+ strlcat(flagstate,", service provider",MAXBUF);
+ if (!flagstate[0])
+ strcpy(flagstate," <no flags>");
+ strlcpy(modulename,Instance->Config->module_names[i].c_str(),256);
+ if (*source->oper)
+ {
+ snprintf(strbuf, MAXBUF, "::%s 900 %s :0x%08lx %d.%d.%d.%d %s (%s)",Instance->Config->ServerName,source->nick,(long unsigned int)Instance->modules[i],V.Major,V.Minor,V.Revision,V.Build,ServerConfig::CleanFilename(modulename),flagstate+2);
+ }
+ else
+ {
+ snprintf(strbuf, MAXBUF, "::%s 900 %s :%s",Instance->Config->ServerName,source->nick,ServerConfig::CleanFilename(modulename));
+ }
+ par[1] = strbuf;
+ Utils->DoOneToOne(Instance->Config->ServerName, "PUSH", par, source->server);
+ }
+ snprintf(strbuf, MAXBUF, "::%s 901 %s :End of MODULES list", Instance->Config->ServerName, source->nick);
+ par[1] = strbuf;
+ Utils->DoOneToOne(Instance->Config->ServerName, "PUSH", par, source->server);
+ return true;
+}
+
/** remote MOTD. leet, huh? */
bool TreeSocket::Motd(const std::string &prefix, std::deque<std::string> &params)
{
@@ -1050,6 +1105,10 @@ bool TreeSocket::ProcessLine(std::string &line)
{
return this->Motd(prefix, params);
}
+ else if (command == "MODULES")
+ {
+ return this->Modules(prefix, params);
+ }
else if (command == "ADMIN")
{
return this->Admin(prefix, params);