diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-12-09 22:06:15 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-12-09 22:06:15 +0000 |
commit | 3af9d9b0605a503ed16a8b8314587451979103d7 (patch) | |
tree | 5c2ea0f4733404b36899dfcc0954d57929938a35 /src/modules/m_spanningtree.cpp | |
parent | 6d2bf07374515c88734a19ffaac179b7357059ea (diff) |
Make it all work properly. Have it wait for handshake to complete before sending anything down the line
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5898 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_spanningtree.cpp')
-rw-r--r-- | src/modules/m_spanningtree.cpp | 62 |
1 files changed, 59 insertions, 3 deletions
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index e96656910..b770631f5 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -81,6 +81,7 @@ class TreeServer; class TreeSocket; class Link; class ModuleSpanningTree; +class SpanningTreeUtilities; /* This hash_map holds the hash equivalent of the server * tree, used for rapid linear lookups. @@ -117,6 +118,20 @@ class Link : public classbase int Timeout; }; +class HandshakeTimer : public InspTimer +{ + private: + InspIRCd* Instance; + TreeSocket* sock; + Link* lnk; + SpanningTreeUtilities* Utils; + int thefd; + public: + HandshakeTimer(InspIRCd* Inst, TreeSocket* s, Link* l, SpanningTreeUtilities* u); + virtual void Tick(time_t TIME); +}; + + /** Contains helper functions and variables for this module, * and keeps them out of the global namespace */ @@ -709,9 +724,20 @@ class TreeSocket : public InspSocket Instance->Log(DEBUG, "HOOK = %08x", Hook); if (Hook) + { InspSocketHookRequest(this, (Module*)Utils->Creator, Hook).Send(); + Instance->Timers->AddTimer(new HandshakeTimer(Instance, this, &(Utils->LinkBlocks[0]), this->Utils)); + } + } + + ServerState GetLinkState() + { + return this->LinkState; + } - //this->SendCapabilities(); + Module* GetHook() + { + return this->Hook; } ~TreeSocket() @@ -772,8 +798,9 @@ class TreeSocket : public InspSocket if (Hook) InspSocketHookRequest(this, (Module*)Utils->Creator, Hook).Send(); + else + this->SendCapabilities(); - //this->SendCapabilities(); if (x->EncryptionKey != "") { if (!(x->EncryptionKey.length() == 16 || x->EncryptionKey.length() == 24 || x->EncryptionKey.length() == 32)) @@ -787,7 +814,11 @@ class TreeSocket : public InspSocket } } /* found who we're supposed to be connecting to, send the neccessary gubbins. */ - this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+x->SendPass+" 0 :"+this->Instance->Config->ServerDesc); + if (Hook) + Instance->Timers->AddTimer(new HandshakeTimer(Instance, this, &(*x), this->Utils)); + else + this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+x->SendPass+" 0 :"+this->Instance->Config->ServerDesc); + return true; } } @@ -4225,6 +4256,31 @@ class TimeSyncTimer : public InspTimer virtual void Tick(time_t TIME); }; +HandshakeTimer::HandshakeTimer(InspIRCd* Inst, TreeSocket* s, Link* l, SpanningTreeUtilities* u) : InspTimer(1, time(NULL)), Instance(Inst), sock(s), lnk(l), Utils(u) +{ + thefd = sock->GetFd(); +} + +void HandshakeTimer::Tick(time_t TIME) +{ + if (Instance->SE->GetRef(thefd) == sock) + { + if (sock->GetHook() && InspSocketHSCompleteRequest(sock, (Module*)Utils->Creator, sock->GetHook()).Send()) + { + InspSocketAttachCertRequest(sock, (Module*)Utils->Creator, sock->GetHook()).Send(); + sock->SendCapabilities(); + if (sock->GetLinkState() == CONNECTING) + { + sock->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+lnk->SendPass+" 0 :"+this->Instance->Config->ServerDesc); + } + } + else + { + Instance->Timers->AddTimer(new HandshakeTimer(Instance, sock, lnk, Utils)); + } + } +} + class ModuleSpanningTree : public Module { int line; |