From 87f6079b5ca4038201319ad0a6241dc2f2cb310e Mon Sep 17 00:00:00 2001 From: w00t Date: Mon, 27 Aug 2007 21:31:24 +0000 Subject: Well, this probably works. But it might not. :D. - If a server is introduced with an already-existing SID, kill it off the network. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7921 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_spanningtree/treesocket2.cpp | 40 +++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index 3418dd837..fefd25b2a 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -800,7 +800,20 @@ bool TreeSocket::RemoteServer(const std::string &prefix, std::deque return false; } Link* lnk = Utils->FindLink(servername); - TreeServer* Node = new TreeServer(this->Utils, this->Instance, servername, description, sid, ParentOfThis,NULL, lnk ? lnk->Hidden : false); + + TreeServer *Node; + + try + { + Node = new TreeServer(this->Utils, this->Instance, servername, description, sid, ParentOfThis,NULL, lnk ? lnk->Hidden : false); + } + catch (CoreException &e) + { + this->SendError("Server ID "+sid+" already exists on the network!"); + this->Instance->SNO->WriteToSnoMask('l',"Server \2"+servername+"\2 being introduced from \2" + prefix + "\2 denied, server ID already exists on the network. Closing link with " + prefix); + return false; + } + ParentOfThis->AddChild(Node); params[4] = ":" + params[4]; Utils->SetRemoteBursting(Node, true); @@ -872,7 +885,19 @@ bool TreeSocket::Outbound_Reply_Server(std::deque ¶ms) // we should add the details of this server now // to the servers tree, as a child of the root // node. - TreeServer* Node = new TreeServer(this->Utils, this->Instance, sname, description, sid, Utils->TreeRoot, this, x->Hidden); + + TreeServer *Node; + + try + { + Node = new TreeServer(this->Utils, this->Instance, sname, description, sid, Utils->TreeRoot, this, x->Hidden); + } + catch (CoreException &e) + { + this->SendError("Server ID "+sid+" already exists on the network!"); + this->Instance->SNO->WriteToSnoMask('l',"Server \2"+assign(servername)+"\2 being introduced denied, server ID already exists on the network. Closing link."); + return false; + } Utils->TreeRoot->AddChild(Node); params[4] = ":" + params[4]; Utils->DoOneToAllButSender(Utils->TreeRoot->GetName(),"SERVER",params,sname); @@ -1074,7 +1099,16 @@ bool TreeSocket::ProcessLine(std::string &line) } this->LinkState = CONNECTED; Link* lnk = Utils->FindLink(InboundServerName); - Node = new TreeServer(this->Utils,this->Instance, InboundServerName, InboundDescription, InboundSID, Utils->TreeRoot, this, lnk ? lnk->Hidden : false); + try + { + Node = new TreeServer(this->Utils,this->Instance, InboundServerName, InboundDescription, InboundSID, Utils->TreeRoot, this, lnk ? lnk->Hidden : false); + } + catch (CoreException &e) + { + this->SendError("Server ID "+InboundSID+" already exists on the network!"); + this->Instance->SNO->WriteToSnoMask('l',"Server \2"+InboundServerName+"\2 being introduced from \2" + prefix + "\2 denied, server ID already exists on the network. Closing link."); + return false; + } Utils->DelBurstingServer(this); Utils->TreeRoot->AddChild(Node); params.clear(); -- cgit v1.2.3