summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-30 13:00:51 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-30 13:00:51 +0000
commitc746f9a9644524751501e72aa35547a7110512c1 (patch)
treeca28fc6dd5337a2755c1640e5628771989f34768 /src
parent08007a721ef12623057188b0475e0738008ecd3f (diff)
REMOTE STATS! WOOO AND YAY!
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4596 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/cmd_stats.cpp140
-rw-r--r--src/modules.cpp2
-rw-r--r--src/modules/m_cban.cpp4
-rw-r--r--src/modules/m_spanningtree.cpp86
-rw-r--r--src/xline.cpp36
5 files changed, 172 insertions, 96 deletions
diff --git a/src/cmd_stats.cpp b/src/cmd_stats.cpp
index 871423a57..a44091f6c 100644
--- a/src/cmd_stats.cpp
+++ b/src/cmd_stats.cpp
@@ -54,143 +54,149 @@ extern chan_hash chanlist;
void cmd_stats::Handle (const char** parameters, int pcnt, userrec *user)
{
- if (pcnt != 1)
- {
- return;
- }
+ string_list values;
+ DoStats(*parameters[0], user, values);
+ for (size_t i = 0; i < values.size(); i++)
+ Write(user->fd, ":%s", values[i].c_str());
+}
- if ((*Config->OperOnlyStats) && (strchr(Config->OperOnlyStats,*parameters[0])) && (!*user->oper))
+void DoStats(char statschar, userrec* user, string_list &results)
+{
+ std::string sn = Config->ServerName;
+
+ if ((*Config->OperOnlyStats) && (strchr(Config->OperOnlyStats,statschar)) && (!*user->oper))
{
- WriteServ(user->fd,"481 %s :Permission denied - STATS %c is oper-only",user->nick,*parameters[0]);
+ results.push_back(sn+std::string(" 481 ")+user->nick+" :Permission denied - STATS "+statschar+" is oper-only");
return;
}
-
-
+
int MOD_RESULT = 0;
- FOREACH_RESULT(I_OnStats,OnStats(*parameters[0],user));
+ FOREACH_RESULT(I_OnStats,OnStats(statschar,user,results));
if (MOD_RESULT)
return;
- if (*parameters[0] == 'c')
+ if (statschar == 'c')
{
/* This stats symbol must be handled by a linking module */
}
- if (*parameters[0] == 'i')
+ if (statschar == 'i')
{
int idx = 0;
for (ClassVector::iterator i = Config->Classes.begin(); i != Config->Classes.end(); i++)
{
- WriteServ(user->fd,"215 %s I * * * %d %d %s *",user->nick,MAXCLIENTS,idx,Config->ServerName);
+ results.push_back(sn+" 215 "+user->nick+" I * * * "+ConvToStr(MAXCLIENTS)+" "+ConvToStr(idx)+" "+Config->ServerName+" *");
idx++;
}
}
- if (*parameters[0] == 'y')
+ if (statschar == 'y')
{
int idx = 0;
for (ClassVector::iterator i = Config->Classes.begin(); i != Config->Classes.end(); i++)
{
- WriteServ(user->fd,"218 %s Y %d %d 0 %d %d",user->nick,idx,120,i->flood,i->registration_timeout);
+ results.push_back(sn+" 218 "+user->nick+" Y "+ConvToStr(idx)+" 120 0 "+ConvToStr(i->flood)+" "+ConvToStr(i->registration_timeout));
idx++;
}
}
- if (*parameters[0] == 'U')
+ if (statschar == 'U')
{
char ulined[MAXBUF];
for (int i = 0; i < Config->ConfValueEnum(Config->config_data, "uline"); i++)
{
Config->ConfValue(Config->config_data, "uline","server", i, ulined, MAXBUF);
- WriteServ(user->fd,"248 %s U %s",user->nick,ulined);
+ results.push_back(sn+" 248 "+user->nick+" U "+std::string(ulined));
}
}
- if (*parameters[0] == 'P')
+ if (statschar == 'P')
{
int idx = 0;
for (user_hash::iterator i = clientlist.begin(); i != clientlist.end(); i++)
{
if (*i->second->oper)
{
- WriteServ(user->fd,"249 %s :%s (%s@%s) Idle: %d",user->nick,i->second->nick,i->second->ident,i->second->dhost,(TIME - i->second->idle_lastmsg));
+ results.push_back(sn+" 249 "+user->nick+" :"+i->second->nick+" ("+i->second->ident+"@"+i->second->dhost+") Idle: "+ConvToStr(TIME - i->second->idle_lastmsg));
idx++;
}
}
- WriteServ(user->fd,"249 %s :%d OPER(s)",user->nick,idx);
+ results.push_back(sn+" 249 "+user->nick+" :"+ConvToStr(idx)+" OPER(s)");
}
-
- if (*parameters[0] == 'k')
+
+ if (statschar == 'k')
{
- stats_k(user);
+ stats_k(user,results);
}
- if (*parameters[0] == 'g')
+ if (statschar == 'g')
{
- stats_g(user);
+ stats_g(user,results);
}
- if (*parameters[0] == 'q')
+ if (statschar == 'q')
{
- stats_q(user);
+ stats_q(user,results);
}
- if (*parameters[0] == 'Z')
+ if (statschar == 'Z')
{
- stats_z(user);
+ stats_z(user,results);
}
- if (*parameters[0] == 'e')
+ if (statschar == 'e')
{
- stats_e(user);
+ stats_e(user,results);
}
/* stats m (list number of times each command has been used, plus bytecount) */
- if (*parameters[0] == 'm')
+ if (statschar == 'm')
{
for (nspace::hash_map<std::string,command_t*>::iterator i = ServerInstance->Parser->cmdlist.begin(); i != ServerInstance->Parser->cmdlist.end(); i++)
{
if (i->second->use_count)
{
/* RPL_STATSCOMMANDS */
- WriteServ(user->fd,"212 %s %s %d %d",user->nick,i->second->command.c_str(),i->second->use_count,i->second->total_bytes);
+ results.push_back(sn+" 212 "+user->nick+" "+i->second->command+" "+ConvToStr(i->second->use_count)+" "+ConvToStr(i->second->total_bytes));
}
}
}
/* stats z (debug and memory info) */
- if (*parameters[0] == 'z')
+ if (statschar == 'z')
{
rusage R;
- WriteServ(user->fd,"249 %s :Users(HASH_MAP) %d (%d bytes, %d buckets)",user->nick,clientlist.size(),clientlist.size()*sizeof(userrec),clientlist.bucket_count());
- WriteServ(user->fd,"249 %s :Channels(HASH_MAP) %d (%d bytes, %d buckets)",user->nick,chanlist.size(),chanlist.size()*sizeof(chanrec),chanlist.bucket_count());
- WriteServ(user->fd,"249 %s :Commands(VECTOR) %d (%d bytes)",user->nick,ServerInstance->Parser->cmdlist.size(),ServerInstance->Parser->cmdlist.size()*sizeof(command_t));
- WriteServ(user->fd,"249 %s :MOTD(VECTOR) %d, RULES(VECTOR) %d",user->nick,Config->MOTD.size(),Config->RULES.size());
- WriteServ(user->fd,"249 %s :Modules(VECTOR) %d (%d)",user->nick,modules.size(),modules.size()*sizeof(Module));
- WriteServ(user->fd,"249 %s :ClassFactories(VECTOR) %d (%d)",user->nick,factory.size(),factory.size()*sizeof(ircd_module));
+ results.push_back(sn+" 249 "+user->nick+" :Users(HASH_MAP) "+ConvToStr(clientlist.size())+" ("+ConvToStr(clientlist.size()*sizeof(userrec))+" bytes, "+ConvToStr(clientlist.bucket_count())+" buckets)");
+ results.push_back(sn+" 249 "+user->nick+" :Channels(HASH_MAP) "+ConvToStr(chanlist.size())+" ("+ConvToStr(chanlist.size()*sizeof(chanrec))+" bytes, "+ConvToStr(chanlist.bucket_count())+" buckets)");
+ results.push_back(sn+" 249 "+user->nick+" :Commands(VECTOR) "+ConvToStr(ServerInstance->Parser->cmdlist.size())+" ("+ConvToStr(ServerInstance->Parser->cmdlist.size()*sizeof(command_t))+" bytes)");
+ results.push_back(sn+" 249 "+user->nick+" :MOTD(VECTOR) "+ConvToStr(Config->MOTD.size())+", RULES(VECTOR) "+ConvToStr(Config->RULES.size()));
+ results.push_back(sn+" 249 "+user->nick+" :Modules(VECTOR) "+ConvToStr(modules.size())+" ("+ConvToStr(modules.size()*sizeof(Module))+")");
+ results.push_back(sn+" 249 "+user->nick+" :ClassFactories(VECTOR) "+ConvToStr(factory.size())+" ("+ConvToStr(factory.size()*sizeof(ircd_module))+")");
if (!getrusage(RUSAGE_SELF,&R))
{
- WriteServ(user->fd,"249 %s :Total allocation: %luK (0x%lx)",user->nick,R.ru_maxrss,R.ru_maxrss);
- WriteServ(user->fd,"249 %s :Signals: %lu (0x%lx)",user->nick,R.ru_nsignals,R.ru_nsignals);
- WriteServ(user->fd,"249 %s :Page faults: %lu (0x%lx)",user->nick,R.ru_majflt,R.ru_majflt);
- WriteServ(user->fd,"249 %s :Swaps: %lu (0x%lx)",user->nick,R.ru_nswap,R.ru_nswap);
- WriteServ(user->fd,"249 %s :Context Switches: %lu (0x%lx)",user->nick,R.ru_nvcsw+R.ru_nivcsw,R.ru_nvcsw+R.ru_nivcsw);
+ results.push_back(sn+" 249 "+user->nick+" :Total allocation: "+ConvToStr(R.ru_maxrss)+"K");
+ results.push_back(sn+" 249 "+user->nick+" :Signals: "+ConvToStr(R.ru_nsignals));
+ results.push_back(sn+" 249 "+user->nick+" :Page faults: "+ConvToStr(R.ru_majflt));
+ results.push_back(sn+" 249 "+user->nick+" :Swaps: "+ConvToStr(R.ru_nswap));
+ results.push_back(sn+" 249 "+user->nick+" :Context Switches: "+ConvToStr(R.ru_nvcsw+R.ru_nivcsw));
}
}
- if (*parameters[0] == 'T')
+ if (statschar == 'T')
{
- WriteServ(user->fd,"249 %s :accepts %lu refused %lu",user->nick,ServerInstance->stats->statsAccept,ServerInstance->stats->statsRefused);
- WriteServ(user->fd,"249 %s :unknown commands %lu",user->nick,ServerInstance->stats->statsUnknown);
- WriteServ(user->fd,"249 %s :nick collisions %lu",user->nick,ServerInstance->stats->statsCollisions);
- WriteServ(user->fd,"249 %s :dns requests %lu succeeded %lu failed %lu",user->nick,ServerInstance->stats->statsDns,ServerInstance->stats->statsDnsGood,ServerInstance->stats->statsDnsBad);
- WriteServ(user->fd,"249 %s :connections %lu",user->nick,ServerInstance->stats->statsConnects);
- WriteServ(user->fd,"249 %s :bytes sent %5.2fK recv %5.2fK",user->nick,ServerInstance->stats->statsSent / 1024,ServerInstance->stats->statsRecv / 1024);
+ results.push_back(sn+" 249 "+user->nick+" :accepts "+ConvToStr(ServerInstance->stats->statsAccept)+" refused "+ConvToStr(ServerInstance->stats->statsRefused));
+ results.push_back(sn+" 249 "+user->nick+" :unknown commands "+ConvToStr(ServerInstance->stats->statsUnknown));
+ results.push_back(sn+" 249 "+user->nick+" :nick collisions "+ConvToStr(ServerInstance->stats->statsCollisions));
+ results.push_back(sn+" 249 "+user->nick+" :dns requests "+ConvToStr(ServerInstance->stats->statsDns)+" succeeded "+ConvToStr(ServerInstance->stats->statsDnsGood)+" failed "+ConvToStr(ServerInstance->stats->statsDnsBad));
+ results.push_back(sn+" 249 "+user->nick+" :connections "+ConvToStr(ServerInstance->stats->statsConnects));
+ char buffer[MAXBUF];
+ snprintf(buffer,MAXBUF," 249 %s :bytes sent %5.2fK recv %5.2fK",user->nick,ServerInstance->stats->statsSent / 1024,ServerInstance->stats->statsRecv / 1024);
+ results.push_back(sn+buffer);
}
-
+
/* stats o */
- if (*parameters[0] == 'o')
+ if (statschar == 'o')
{
for (int i = 0; i < Config->ConfValueEnum(Config->config_data, "oper"); i++)
{
@@ -200,30 +206,30 @@ void cmd_stats::Handle (const char** parameters, int pcnt, userrec *user)
Config->ConfValue(Config->config_data, "oper","name", i, LoginName, MAXBUF);
Config->ConfValue(Config->config_data, "oper","host", i, HostName, MAXBUF);
Config->ConfValue(Config->config_data, "oper","type", i, OperType, MAXBUF);
- WriteServ(user->fd,"243 %s O %s * %s %s 0",user->nick,HostName,LoginName,OperType);
+ results.push_back(sn+" 243 "+user->nick+" O "+HostName+" * "+LoginName+" "+OperType+" 0");
}
}
/* stats l (show user I/O stats) */
- if (*parameters[0] == 'l')
+ if (statschar == 'l')
{
- WriteServ(user->fd,"211 %s :server:port nick bytes_in cmds_in bytes_out cmds_out",user->nick);
+ results.push_back(sn+" 211 "+user->nick+" :server:port nick bytes_in cmds_in bytes_out cmds_out");
for (user_hash::iterator i = clientlist.begin(); i != clientlist.end(); i++)
{
if (isnick(i->second->nick))
{
- WriteServ(user->fd,"211 %s :%s:%d %s %d %d %d %d",user->nick,i->second->server,i->second->port,i->second->nick,i->second->bytes_in,i->second->cmds_in,i->second->bytes_out,i->second->cmds_out);
+ results.push_back(sn+" 211 "+user->nick+" :"+i->second->server+":"+ConvToStr(i->second->port)+" "+i->second->nick+" "+ConvToStr(i->second->bytes_in)+" "+ConvToStr(i->second->cmds_in)+" "+ConvToStr(i->second->bytes_out)+" "+ConvToStr(i->second->cmds_out));
}
else
{
- WriteServ(user->fd,"211 %s :%s:%d (unknown@%d) %d %d %d %d",user->nick,i->second->server,i->second->port,i->second->fd,i->second->bytes_in,i->second->cmds_in,i->second->bytes_out,i->second->cmds_out);
+ results.push_back(sn+" 211 "+user->nick+" :"+i->second->server+":"+ConvToStr(i->second->port)+" (unknown@"+ConvToStr(i->second->fd)+") "+ConvToStr(i->second->bytes_in)+" "+ConvToStr(i->second->cmds_in)+" "+ConvToStr(i->second->bytes_out)+" "+ConvToStr(i->second->cmds_out));
}
}
}
/* stats u (show server uptime) */
- if (*parameters[0] == 'u')
+ if (statschar == 'u')
{
time_t current_time = 0;
current_time = TIME;
@@ -234,15 +240,21 @@ void cmd_stats::Handle (const char** parameters, int pcnt, userrec *user)
* Craig suggested this, and it seemed a good idea so in it went */
if (stime->tm_year > 70)
{
- WriteServ(user->fd,"242 %s :Server up %d years, %d days, %.2d:%.2d:%.2d",user->nick,(stime->tm_year-70),stime->tm_yday,stime->tm_hour,stime->tm_min,stime->tm_sec);
+ char buffer[MAXBUF];
+ snprintf(buffer,MAXBUF,"242 %s :Server up %d years, %d days, %.2d:%.2d:%.2d",user->nick,(stime->tm_year-70),stime->tm_yday,stime->tm_hour,stime->tm_min,stime->tm_sec);
+ results.push_back(sn+buffer);
}
else
{
- WriteServ(user->fd,"242 %s :Server up %d days, %.2d:%.2d:%.2d",user->nick,stime->tm_yday,stime->tm_hour,stime->tm_min,stime->tm_sec);
+ char buffer[MAXBUF];
+ snprintf(buffer,MAXBUF,"242 %s :Server up %d days, %.2d:%.2d:%.2d",user->nick,stime->tm_yday,stime->tm_hour,stime->tm_min,stime->tm_sec);
+ results.push_back(sn+buffer);
}
}
- WriteServ(user->fd,"219 %s %s :End of /STATS report",user->nick,parameters[0]);
- WriteOpers("*** Notice: Stats '%s' requested by %s (%s@%s)",parameters[0],user->nick,user->ident,user->host);
-
+ results.push_back(sn+" 219 "+user->nick+" "+statschar+" :End of /STATS report");
+ WriteOpers("*** Notice: %s '%c' requested by %s (%s@%s)",(!strcmp(user->server,Config->ServerName) ? "Stats" : "Remote stats"),statschar,user->nick,user->ident,user->host);
+
+ return;
}
+
diff --git a/src/modules.cpp b/src/modules.cpp
index 8316d228a..fbdac43d2 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -185,7 +185,7 @@ int Module::OnCheckInvite(userrec* user, chanrec* chan) { return 0; };
int Module::OnCheckKey(userrec* user, chanrec* chan, const std::string &keygiven) { return 0; };
int Module::OnCheckLimit(userrec* user, chanrec* chan) { return 0; };
int Module::OnCheckBan(userrec* user, chanrec* chan) { return 0; };
-int Module::OnStats(char symbol, userrec* user) { return 0; };
+int Module::OnStats(char symbol, userrec* user, string_list &results) { return 0; };
int Module::OnChangeLocalUserHost(userrec* user, const std::string &newhost) { return 0; };
int Module::OnChangeLocalUserGECOS(userrec* user, const std::string &newhost) { return 0; };
int Module::OnLocalTopicChange(userrec* user, chanrec* chan, const std::string &topic) { return 0; };
diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp
index 8f10cc84d..7d834db66 100644
--- a/src/modules/m_cban.cpp
+++ b/src/modules/m_cban.cpp
@@ -142,7 +142,7 @@ class ModuleCBan : public Module
List[I_OnUserPreJoin] = List[I_OnSyncOtherMetaData] = List[I_OnDecodeMetaData] = List[I_OnStats] = 1;
}
- virtual int OnStats(char symbol, userrec* user)
+ virtual int OnStats(char symbol, userrec* user, string_list &results)
{
ExpireBans();
@@ -151,7 +151,7 @@ class ModuleCBan : public Module
for(cbanlist::iterator iter = cbans.begin(); iter != cbans.end(); iter++)
{
unsigned long remaining = (iter->set_on + iter->length) - TIME;
- WriteServ(user->fd, "210 %s %s %s %lu %lu %lu :%s", user->nick, iter->chname.c_str(), iter->set_by.c_str(), iter->set_on, iter->length, remaining, iter->reason.c_str());
+ results.push_back(Srv->GetServerName()+" 210 "+user->nick+" "+iter->chname.c_str()+" "+iter->set_by+" "+ConvToStr(iter->set_on)+" "+ConvToStr(iter->length)+" "+ConvToStr(remaining)+" :"+iter->reason);
}
}
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index c4d335ef2..c55662f9f 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -30,6 +30,7 @@ using namespace std;
#include "modules.h"
#include "commands.h"
#include "commands/cmd_whois.h"
+#include "commands/cmd_stats.h"
#include "socket.h"
#include "helperfuncs.h"
#include "inspircd.h"
@@ -1916,6 +1917,43 @@ class TreeSocket : public InspSocket
return false;
}
+ bool Stats(std::string prefix, std::deque<std::string> &params)
+ {
+ /* Get the reply to a STATS query if it matches this servername,
+ * and send it back as a load of PUSH queries
+ */
+ if (params.size() > 1)
+ {
+ if (Srv->MatchText(Srv->GetServerName(), params[1]))
+ {
+ /* It's for our server */
+ string_list results;
+ userrec* source = Srv->FindNick(prefix);
+ if (source)
+ {
+ std::deque<std::string> par;
+ par.push_back(prefix);
+ par.push_back("");
+ DoStats(*(params[0].c_str()), source, results);
+ for (size_t i = 0; i < results.size(); i++)
+ {
+ par[1] = "::" + results[i];
+ DoOneToOne(Srv->GetServerName(), "PUSH",par, source->server);
+ }
+ }
+ }
+ else
+ {
+ /* Pass it on */
+ userrec* source = Srv->FindNick(prefix);
+ if (source)
+ DoOneToOne(prefix, "STATS", params, params[1]);
+ }
+ }
+ return true;
+ }
+
+
/* Because the core won't let users or even SERVERS set +o,
* we use the OPERTYPE command to do this.
*/
@@ -2280,15 +2318,7 @@ class TreeSocket : public InspSocket
if (IS_LOCAL(u))
{
- // push the raw to the user
- if (Srv->IsUlined(prefix))
- {
- ::Write(u->fd,"%s",params[1].c_str());
- }
- else
- {
- log(DEBUG,"PUSH from non-ulined server dropped into the bit-bucket: :%s PUSH %s :%s",prefix.c_str(),params[0].c_str(),params[1].c_str());
- }
+ ::Write(u->fd,"%s",params[1].c_str());
}
else
{
@@ -2730,6 +2760,10 @@ class TreeSocket : public InspSocket
{
return this->ForceJoin(prefix,params);
}
+ else if (command == "STATS")
+ {
+ return this->Stats(prefix, params);
+ }
else if (command == "SERVER")
{
return this->RemoteServer(prefix,params);
@@ -3430,6 +3464,26 @@ class ModuleSpanningTree : public Module
}
}
+ int HandleStats(const char** parameters, int pcnt, userrec* user)
+ {
+ if (pcnt > 1)
+ {
+ /* Remote STATS, the server is within the 2nd parameter */
+ std::deque<std::string> params;
+ params.push_back(parameters[0]);
+ params.push_back(parameters[1]);
+ /* Send it out remotely, generate no reply yet */
+ TreeServer* s = FindServerMask(parameters[1]);
+ if (s)
+ {
+ params[1] = s->GetName();
+ DoOneToOne(user->nick, "STATS", params, s->GetName());
+ }
+ return 1;
+ }
+ return 0;
+ }
+
// Ok, prepare to be confused.
// After much mulling over how to approach this, it struck me that
// the 'usual' way of doing a /MAP isnt the best way. Instead of
@@ -3697,17 +3751,17 @@ class ModuleSpanningTree : public Module
return 1;
}
- virtual int OnStats(char statschar, userrec* user)
+ virtual int OnStats(char statschar, userrec* user, string_list &results)
{
if (statschar == 'c')
{
for (unsigned int i = 0; i < LinkBlocks.size(); i++)
{
- WriteServ(user->fd,"213 %s C *@%s * %s %d 0 %c%c%c",user->nick,(LinkBlocks[i].HiddenFromStats ? "<hidden>" : LinkBlocks[i].IPAddr).c_str(),LinkBlocks[i].Name.c_str(),LinkBlocks[i].Port,(LinkBlocks[i].EncryptionKey != "" ? 'e' : '-'),(LinkBlocks[i].AutoConnect ? 'a' : '-'),'s');
- WriteServ(user->fd,"244 %s H * * %s",user->nick,LinkBlocks[i].Name.c_str());
+ results.push_back(Srv->GetServerName()+" 213 "+user->nick+" C *@"+(LinkBlocks[i].HiddenFromStats ? "<hidden>" : LinkBlocks[i].IPAddr)+" * "+LinkBlocks[i].Name.c_str()+" "+ConvToStr(LinkBlocks[i].Port)+" "+(LinkBlocks[i].EncryptionKey != "" ? 'e' : '-')+(LinkBlocks[i].AutoConnect ? 'a' : '-')+'s');
+ results.push_back(Srv->GetServerName()+" 244 "+user->nick+" H * * "+LinkBlocks[i].Name.c_str());
}
- WriteServ(user->fd,"219 %s %c :End of /STATS report",user->nick,statschar);
- WriteOpers("*** Notice: Stats '%c' requested by %s (%s@%s)",statschar,user->nick,user->ident,user->host);
+ results.push_back(Srv->GetServerName()+" 219 "+user->nick+" "+statschar+" :End of /STATS report");
+ WriteOpers("*** Notice: %s '%c' requested by %s (%s@%s)",(!strcmp(user->server,Config->ServerName) ? "Stats" : "Remote stats"),statschar,user->nick,user->ident,user->host);
return 1;
}
return 0;
@@ -3723,6 +3777,10 @@ class ModuleSpanningTree : public Module
{
return this->HandleConnect(parameters,pcnt,user);
}
+ else if (command == "STATS")
+ {
+ return this->HandleStats(parameters,pcnt,user);
+ }
else if (command == "SQUIT")
{
return this->HandleSquit(parameters,pcnt,user);
diff --git a/src/xline.cpp b/src/xline.cpp
index a718b8094..3401ca441 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -36,6 +36,7 @@ using namespace std;
#include "helperfuncs.h"
#include "hashcomp.h"
#include "typedefs.h"
+#include "configreader.h"
#include "cull_list.h"
extern ServerConfig *Config;
@@ -714,42 +715,47 @@ void apply_lines(const int What)
DELETE(Goners);
}
-void stats_k(userrec* user)
+void stats_k(userrec* user, string_list &results)
{
+ std::string sn = Config->ServerName;
for (std::vector<KLine>::iterator i = klines.begin(); i != klines.end(); i++)
- WriteServ(user->fd,"216 %s :%s %d %d %s :%s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
+ results.push_back(sn+" 216 "+user->nick+" :"+i->hostmask+" "+ConvToStr(i->set_time)+" "+ConvToStr(i->duration)+" "+i->source+" :"+i->reason);
for (std::vector<KLine>::iterator i = pklines.begin(); i != pklines.end(); i++)
- WriteServ(user->fd,"216 %s :%s %d %d %s :%s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
+ results.push_back(sn+" 216 "+user->nick+" :"+i->hostmask+" "+ConvToStr(i->set_time)+" "+ConvToStr(i->duration)+" "+i->source+" :"+i->reason);
}
-void stats_g(userrec* user)
+void stats_g(userrec* user, string_list &results)
{
+ std::string sn = Config->ServerName;
for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++)
- WriteServ(user->fd,"223 %s :%s %d %d %s :%s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
+ results.push_back(sn+" 223 "+user->nick+" :"+i->hostmask+" "+ConvToStr(i->set_time)+" "+ConvToStr(i->duration)+" "+i->source+" :"+i->reason);
for (std::vector<GLine>::iterator i = pglines.begin(); i != pglines.end(); i++)
- WriteServ(user->fd,"223 %s :%s %d %d %s :%s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
+ results.push_back(sn+" 223 "+user->nick+" :"+i->hostmask+" "+ConvToStr(i->set_time)+" "+ConvToStr(i->duration)+" "+i->source+" :"+i->reason);
}
-void stats_q(userrec* user)
+void stats_q(userrec* user, string_list &results)
{
+ std::string sn = Config->ServerName;
for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++)
- WriteServ(user->fd,"217 %s :%s %d %d %s :%s",user->nick,i->nick,i->set_time,i->duration,i->source,i->reason);
+ results.push_back(sn+" 217 "+user->nick+" :"+i->nick+" "+ConvToStr(i->set_time)+" "+ConvToStr(i->duration)+" "+i->source+" :"+i->reason);
for (std::vector<QLine>::iterator i = pqlines.begin(); i != pqlines.end(); i++)
- WriteServ(user->fd,"217 %s :%s %d %d %s :%s",user->nick,i->nick,i->set_time,i->duration,i->source,i->reason);
+ results.push_back(sn+" 217 "+user->nick+" :"+i->nick+" "+ConvToStr(i->set_time)+" "+ConvToStr(i->duration)+" "+i->source+" :"+i->reason);
}
-void stats_z(userrec* user)
+void stats_z(userrec* user, string_list &results)
{
+ std::string sn = Config->ServerName;
for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++)
- WriteServ(user->fd,"223 %s :%s %d %d %s :%s",user->nick,i->ipaddr,i->set_time,i->duration,i->source,i->reason);
+ results.push_back(sn+" 223 "+user->nick+" :"+i->ipaddr+" "+ConvToStr(i->set_time)+" "+ConvToStr(i->duration)+" "+i->source+" :"+i->reason);
for (std::vector<ZLine>::iterator i = pzlines.begin(); i != pzlines.end(); i++)
- WriteServ(user->fd,"223 %s :%s %d %d %s :%s",user->nick,i->ipaddr,i->set_time,i->duration,i->source,i->reason);
+ results.push_back(sn+" 223 "+user->nick+" :"+i->ipaddr+" "+ConvToStr(i->set_time)+" "+ConvToStr(i->duration)+" "+i->source+" :"+i->reason);
}
-void stats_e(userrec* user)
+void stats_e(userrec* user, string_list &results)
{
+ std::string sn = Config->ServerName;
for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
- WriteServ(user->fd,"223 %s :%s %d %d %s :%s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
+ results.push_back(sn+" 223 "+user->nick+" :"+i->hostmask+" "+ConvToStr(i->set_time)+" "+ConvToStr(i->duration)+" "+i->source+" :"+i->reason);
for (std::vector<ELine>::iterator i = pelines.begin(); i != pelines.end(); i++)
- WriteServ(user->fd,"223 %s :%s %d %d %s :%s",user->nick,i->hostmask,i->set_time,i->duration,i->source,i->reason);
+ results.push_back(sn+" 223 "+user->nick+" :"+i->hostmask+" "+ConvToStr(i->set_time)+" "+ConvToStr(i->duration)+" "+i->source+" :"+i->reason);
}