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