diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_spanningtree/treeserver.cpp | 11 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treeserver.h | 16 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket2.cpp | 9 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.cpp | 8 |
4 files changed, 27 insertions, 17 deletions
diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index 5f91e43b5..1d29bd3c2 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -28,7 +28,7 @@ /* $ModDep: m_spanningtree/utils.h m_spanningtree/treeserver.h */ -TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance) : ServerInstance(Instance), Utils(Util) +TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, const std::string &id) : ServerInstance(Instance), Utils(Util) { Parent = NULL; ServerName.clear(); @@ -38,13 +38,15 @@ TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance) : Server rtt = LastPing = 0; Hidden = false; VersionString = ServerInstance->GetVersionString(); + SetID(id); } /** We use this constructor only to create the 'root' item, Utils->TreeRoot, which * represents our own server. Therefore, it has no route, no parent, and * no socket associated with it. Its version string is our own local version. */ -TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::string Name, std::string Desc) : ServerInstance(Instance), ServerName(Name.c_str()), ServerDesc(Desc), Utils(Util) +TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::string Name, std::string Desc, const std::string &id) + : ServerInstance(Instance), ServerName(Name.c_str()), ServerDesc(Desc), Utils(Util) { Parent = NULL; VersionString.clear(); @@ -56,13 +58,14 @@ TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::str rtt = LastPing = 0; Hidden = false; AddHashEntry(); + SetID(id); } /** When we create a new server, we call this constructor to initialize it. * This constructor initializes the server's Route and Parent, and sets up * its ping counters so that it will be pinged one minute from now. */ -TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::string Name, std::string Desc, TreeServer* Above, TreeSocket* Sock, bool Hide) +TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::string Name, std::string Desc, const std::string &id, TreeServer* Above, TreeSocket* Sock, bool Hide) : ServerInstance(Instance), Parent(Above), ServerName(Name.c_str()), ServerDesc(Desc), Socket(Sock), Utils(Util), Hidden(Hide) { VersionString.clear(); @@ -122,6 +125,8 @@ TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::str */ this->AddHashEntry(); + + SetID(id); } std::string& TreeServer::GetID() diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h index 125fdbd67..2a96012e3 100644 --- a/src/modules/m_spanningtree/treeserver.h +++ b/src/modules/m_spanningtree/treeserver.h @@ -45,6 +45,12 @@ class TreeServer : public classbase SpanningTreeUtilities* Utils; /* Utility class */ std::string sid; /* Server ID */ + /** Set server ID + * @param id Server ID + * @throws CoreException on duplicate ID + */ + void SetID(const std::string &id); + public: bool Warned; /* True if we've warned opers about high latency on this server */ @@ -52,19 +58,19 @@ class TreeServer : public classbase /** We don't use this constructor. Its a dummy, and won't cause any insertion * of the TreeServer into the hash_map. See below for the two we DO use. */ - TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance); + TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, const std::string &id); /** We use this constructor only to create the 'root' item, Utils->TreeRoot, which * represents our own server. Therefore, it has no route, no parent, and * no socket associated with it. Its version string is our own local version. */ - TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::string Name, std::string Desc); + TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::string Name, std::string Desc, const std::string &id); /** When we create a new server, we call this constructor to initialize it. * This constructor initializes the server's Route and Parent, and sets up * its ping counters so that it will be pinged one minute from now. */ - TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::string Name, std::string Desc, TreeServer* Above, TreeSocket* Sock, bool Hide); + TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::string Name, std::string Desc, const std::string &id, TreeServer* Above, TreeSocket* Sock, bool Hide); int QuitUsers(const std::string &reason); @@ -186,10 +192,6 @@ class TreeServer : public classbase */ std::string& GetID(); - /** Set server ID - */ - void SetID(const std::string &id); - /** Destructor */ ~TreeServer(); diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index 067a972ae..3418dd837 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -800,9 +800,8 @@ bool TreeSocket::RemoteServer(const std::string &prefix, std::deque<std::string> return false; } Link* lnk = Utils->FindLink(servername); - TreeServer* Node = new TreeServer(this->Utils,this->Instance,servername,description,ParentOfThis,NULL, lnk ? lnk->Hidden : false); + TreeServer* Node = new TreeServer(this->Utils, this->Instance, servername, description, sid, ParentOfThis,NULL, lnk ? lnk->Hidden : false); ParentOfThis->AddChild(Node); - Node->SetID(sid); params[4] = ":" + params[4]; Utils->SetRemoteBursting(Node, true); Utils->DoOneToAllButSender(prefix,"SERVER",params,prefix); @@ -873,10 +872,9 @@ bool TreeSocket::Outbound_Reply_Server(std::deque<std::string> ¶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,Utils->TreeRoot,this,x->Hidden); + TreeServer* Node = new TreeServer(this->Utils, this->Instance, sname, description, sid, Utils->TreeRoot, this, x->Hidden); Utils->TreeRoot->AddChild(Node); params[4] = ":" + params[4]; - Node->SetID(params[3]); Utils->DoOneToAllButSender(Utils->TreeRoot->GetName(),"SERVER",params,sname); this->bursting = true; this->DoBurst(Node); @@ -1076,7 +1074,7 @@ bool TreeSocket::ProcessLine(std::string &line) } this->LinkState = CONNECTED; Link* lnk = Utils->FindLink(InboundServerName); - Node = new TreeServer(this->Utils,this->Instance, InboundServerName, InboundDescription, Utils->TreeRoot, this, lnk ? lnk->Hidden : false); + Node = new TreeServer(this->Utils,this->Instance, InboundServerName, InboundDescription, InboundSID, Utils->TreeRoot, this, lnk ? lnk->Hidden : false); Utils->DelBurstingServer(this); Utils->TreeRoot->AddChild(Node); params.clear(); @@ -1085,7 +1083,6 @@ bool TreeSocket::ProcessLine(std::string &line) params.push_back("1"); params.push_back(InboundSID); params.push_back(":"+InboundDescription); - Node->SetID(InboundSID); Utils->DoOneToAllButSender(Utils->TreeRoot->GetName(),"SERVER",params,InboundServerName); this->bursting = true; this->DoBurst(Node); diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 3f5a910c9..8610a1666 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -168,9 +168,15 @@ SpanningTreeUtilities::SpanningTreeUtilities(InspIRCd* Instance, ModuleSpanningT { Bindings.clear(); + std::string OurSID; + + OurSID += (char)((Instance->Config->sid / 100) + 48); + OurSID += (char)((Instance->Config->sid / 10) % 10 + 48); + OurSID += (char)(Instance->Config->sid % 10 + 48); + lines_to_apply = 0; - this->TreeRoot = new TreeServer(this, ServerInstance, ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc); + this->TreeRoot = new TreeServer(this, ServerInstance, ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc, OurSID); modulelist* ml = ServerInstance->FindInterface("InspSocketHook"); |