X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree%2Ftreesocket1.cpp;h=c9729cc0f3a6837c96d3d290b1e44c0ad8e9887b;hb=4e24fb7c19cff866eda602349fbafce78b7e4c51;hp=673b05c556f8b25298230a3411546d7b3a18cbe1;hpb=44f42a13de52c8025942ddab42f51feb36821782;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index 673b05c55..c9729cc0f 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -49,6 +49,7 @@ TreeSocket::TreeSocket(SpanningTreeUtilities* Util, Link* link, Autoconnect* mya capab->capab_phase = 0; MyRoot = NULL; proto_version = 0; + ConnectionFailureShown = false; LinkState = CONNECTING; if (!link->Hook.empty()) { @@ -78,6 +79,7 @@ TreeSocket::TreeSocket(SpanningTreeUtilities* Util, int newfd, ListenSocket* via age = ServerInstance->Time(); LinkState = WAIT_AUTH_1; proto_version = 0; + ConnectionFailureShown = false; linkID = "inbound from " + client->addr(); FOREACH_MOD(I_OnHookIO, OnHookIO(this, via)); @@ -134,7 +136,7 @@ void TreeSocket::OnConnected() void TreeSocket::OnError(BufferedSocketError e) { - ServerInstance->SNO->WriteGlobalSno('l', "Connection to \002%s\002 failed with error: %s", + ServerInstance->SNO->WriteGlobalSno('l', "Connection to '\002%s\002' failed with error: %s", linkID.c_str(), getError().c_str()); LinkState = DYING; } @@ -155,8 +157,9 @@ void TreeSocket::SendError(const std::string &errormessage) */ void TreeSocket::SquitServer(std::string &from, TreeServer* Current, int& num_lost_servers, int& num_lost_users) { + std::string servername = Current->GetName(); ServerInstance->Logs->Log("m_spanningtree",DEBUG,"SquitServer for %s from %s", - Current->GetName().c_str(), from.c_str()); + servername.c_str(), from.c_str()); /* recursively squit the servers attached to 'Current'. * We're going backwards so we don't remove users * while we still need them ;) @@ -183,10 +186,14 @@ void TreeSocket::Squit(TreeServer* Current, const std::string &reason) { DelServerEvent(Utils->Creator, Current->GetName()); - parameterlist params; - params.push_back(Current->GetName()); - params.push_back(":"+reason); - Utils->DoOneToAllButSender(Current->GetParent()->GetName(),"SQUIT",params,Current->GetName()); + if (!Current->GetSocket() || Current->GetSocket()->Introduced()) + { + parameterlist params; + params.push_back(Current->GetID()); + params.push_back(":"+reason); + Utils->DoOneToAllButSender(Current->GetParent()->GetID(),"SQUIT",params,Current->GetID()); + } + if (Current->GetParent() == Utils->TreeRoot) { ServerInstance->SNO->WriteGlobalSno('l', "Server \002"+Current->GetName()+"\002 split: "+reason); @@ -194,7 +201,7 @@ void TreeSocket::Squit(TreeServer* Current, const std::string &reason) } else { - ServerInstance->SNO->WriteGlobalSno('L', "Server \002"+Current->GetName()+"\002 split from server \002"+Current->GetParent()->GetName()+"\002 with reason: "+reason); + ServerInstance->SNO->WriteToSnoMask('L', "Server \002"+Current->GetName()+"\002 split from server \002"+Current->GetParent()->GetName()+"\002 with reason: "+reason); } int num_lost_servers = 0; int num_lost_users = 0; @@ -205,8 +212,9 @@ void TreeSocket::Squit(TreeServer* Current, const std::string &reason) Current->Tidy(); Current->GetParent()->DelChild(Current); Current->cull(); + const bool ismyroot = (Current == MyRoot); delete Current; - if (Current == MyRoot) + if (ismyroot) { MyRoot = NULL; Close(); @@ -241,3 +249,8 @@ void TreeSocket::OnDataReady() SendError("RecvQ overrun (line too long)"); Utils->Creator->loopCall = false; } + +bool TreeSocket::Introduced() +{ + return (capab == NULL); +}