]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/stats.cpp
7c9efecde3d34621c9196940c400c3884a0c1507
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / stats.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 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 "commands/cmd_whois.h"
16 #include "commands/cmd_stats.h"
17 #include "socket.h"
18 #include "xline.h"
19 #include "../transport.h"
20 #include "socketengine.h"
21
22 #include "main.h"
23 #include "utils.h"
24 #include "treeserver.h"
25 #include "link.h"
26 #include "treesocket.h"
27
28 /* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h */
29
30 bool TreeSocket::Stats(const std::string &prefix, std::deque<std::string> &params)
31 {
32         /* Get the reply to a STATS query if it matches this servername,
33          * and send it back as a load of PUSH queries
34          */
35         if (params.size() > 1)
36         {
37                 if (InspIRCd::Match(this->ServerInstance->Config->ServerName, params[1]))
38                 {
39                         /* It's for our server */
40                         string_list results;
41                         User* source = this->ServerInstance->FindNick(prefix);
42                         if (source)
43                         {
44                                 std::deque<std::string> par;
45                                 par.push_back(prefix);
46                                 par.push_back("");
47                                 DoStats(this->ServerInstance, *(params[0].c_str()), source, results);
48                                 for (size_t i = 0; i < results.size(); i++)
49                                 {
50                                         par[1] = "::" + results[i];
51                                         Utils->DoOneToOne(this->ServerInstance->Config->GetSID(), "PUSH",par, source->server);
52                                 }
53                         }
54                 }
55                 else
56                 {
57                         /* Pass it on */
58                         User* source = this->ServerInstance->FindNick(prefix);
59                         if (source)
60                                 Utils->DoOneToOne(source->uuid, "STATS", params, params[1]);
61                 }
62         }
63         return true;
64 }
65