]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/stats.cpp
...because every now and again, i have to do a massive commit.
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / stats.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
6  * See: http://wiki.inspircd.org/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "socket.h"
16 #include "xline.h"
17 #include "socketengine.h"
18
19 #include "main.h"
20 #include "utils.h"
21 #include "treeserver.h"
22 #include "link.h"
23 #include "treesocket.h"
24
25 /* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h */
26
27 bool TreeSocket::Stats(const std::string &prefix, parameterlist &params)
28 {
29         /* Get the reply to a STATS query if it matches this servername,
30          * and send it back as a load of PUSH queries
31          */
32         if (params.size() > 1)
33         {
34                 if (InspIRCd::Match(ServerInstance->Config->ServerName, params[1]))
35                 {
36                         /* It's for our server */
37                         string_list results;
38                         User* source = ServerInstance->FindNick(prefix);
39                         if (source)
40                         {
41                                 parameterlist par;
42                                 par.push_back(prefix);
43                                 par.push_back("");
44                                 ServerInstance->DoStats(params[0][0], source, results);
45                                 for (size_t i = 0; i < results.size(); i++)
46                                 {
47                                         par[1] = "::" + results[i];
48                                         Utils->DoOneToOne(ServerInstance->Config->GetSID(), "PUSH",par, source->server);
49                                 }
50                         }
51                 }
52                 else
53                 {
54                         /* Pass it on */
55                         User* source = ServerInstance->FindNick(prefix);
56                         if (source)
57                                 Utils->DoOneToOne(source->uuid, "STATS", params, params[1]);
58                 }
59         }
60         return true;
61 }
62