]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/pong.cpp
Remove spanningtree override of /LUSERS
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / pong.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 "socketengine.h"
18
19 #include "main.h"
20 #include "utils.h"
21 #include "treeserver.h"
22 #include "treesocket.h"
23
24 /* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/treesocket.h */
25
26 bool TreeSocket::LocalPong(const std::string &prefix, parameterlist &params)
27 {
28         if (params.size() < 1)
29                 return true;
30
31         if (params.size() == 1)
32         {
33                 TreeServer* ServerSource = Utils->FindServer(prefix);
34                 if (ServerSource)
35                 {
36                         ServerSource->SetPingFlag();
37                         timeval t;
38                         gettimeofday(&t, NULL);
39                         long ts = (t.tv_sec * 1000) + (t.tv_usec / 1000);
40                         ServerSource->rtt = ts - ServerSource->LastPingMsec;
41                 }
42         }
43         else
44         {
45                 std::string forwardto = params[1];
46                 if (forwardto == ServerInstance->Config->GetSID() || forwardto == ServerInstance->Config->ServerName)
47                 {
48                         /*
49                          * this is a PONG for us
50                          * if the prefix is a user, check theyre local, and if they are,
51                          * dump the PONG reply back to their fd. If its a server, do nowt.
52                          * Services might want to send these s->s, but we dont need to yet.
53                          */
54                         User* u = ServerInstance->FindNick(prefix);
55                         if (u)
56                         {
57                                 u->WriteServ("PONG %s %s",params[0].c_str(),params[1].c_str());
58                         }
59
60                         TreeServer *ServerSource = Utils->FindServer(params[0]);
61
62                         if (ServerSource)
63                         {
64                                 timeval t;
65                                 gettimeofday(&t, NULL);
66                                 long ts = (t.tv_sec * 1000) + (t.tv_usec / 1000);
67                                 ServerSource->rtt = ts - ServerSource->LastPingMsec;
68                                 ServerSource->SetPingFlag();
69                         }
70                 }
71                 else
72                 {
73                         // not for us, pass it on :)
74                         Utils->DoOneToOne(prefix,"PONG",params,forwardto);
75                 }
76         }
77
78         return true;
79 }
80