]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_spanningtree/handshaketimer.cpp
150c9eecd1033c6d06e4518bee4b28f946caa901
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / handshaketimer.cpp
1 #include "configreader.h"
2 #include "users.h"
3 #include "channels.h"
4 #include "modules.h"
5 #include "commands/cmd_whois.h"
6 #include "commands/cmd_stats.h"
7 #include "socket.h"
8 #include "inspircd.h"
9 #include "wildcard.h"
10 #include "xline.h"
11 #include "transport.h"
12
13 #include "m_spanningtree/main.h"
14 #include "m_spanningtree/utils.h"
15 #include "m_spanningtree/treeserver.h"
16 #include "m_spanningtree/link.h"
17 #include "m_spanningtree/treesocket.h"
18 #include "m_spanningtree/handshaketimer.h"
19
20 /* $ModDep: m_spanningtree/main.h m_spanningtree/utils.h m_spanningtree/treeserver.h m_spanningtree/link.h m_spanningtree/treesocket.h */
21
22 HandshakeTimer::HandshakeTimer(InspIRCd* Inst, TreeSocket* s, Link* l, SpanningTreeUtilities* u) : InspTimer(1, time(NULL)), Instance(Inst), sock(s), lnk(l), Utils(u)
23 {
24         thefd = sock->GetFd();
25 }
26
27 void HandshakeTimer::Tick(time_t TIME)
28 {
29         Instance->Log(DEBUG,"Tick handshake timer.");
30         if (Instance->SE->GetRef(thefd) == sock)
31         {
32                 Instance->Log(DEBUG,"Socket still here");
33                 if (sock->GetHook() && InspSocketHSCompleteRequest(sock, (Module*)Utils->Creator, sock->GetHook()).Send())
34                 {
35                         Instance->Log(DEBUG,"request complete");
36                         InspSocketAttachCertRequest(sock, (Module*)Utils->Creator, sock->GetHook()).Send();
37                         sock->SendCapabilities();
38                         if (sock->GetLinkState() == CONNECTING)
39                         {
40                                 sock->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+lnk->SendPass+" 0 :"+this->Instance->Config->ServerDesc);
41                         }
42                 }
43                 else
44                 {
45                         Instance->Log(DEBUG,"Request not yet complete");
46                         Instance->Timers->AddTimer(new HandshakeTimer(Instance, sock, lnk, Utils));
47                 }
48         }
49 }
50