]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Move SID into TreeSocket constructor. w00t, search for "new TreeSocket" to see where...
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 27 Aug 2007 21:18:57 +0000 (21:18 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 27 Aug 2007 21:18:57 +0000 (21:18 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7920 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules/m_spanningtree/treeserver.cpp
src/modules/m_spanningtree/treeserver.h
src/modules/m_spanningtree/treesocket2.cpp
src/modules/m_spanningtree/utils.cpp

index 5f91e43b577cf52c4e32cb0b96cbd5bfcb7c009b..1d29bd3c2749ba0868a86c12f0bd07986d506496 100644 (file)
@@ -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()
index 125fdbd67924e228aa8af58de9b05ed767e7f703..2a96012e32bd24a1861a05d0abb8a67b1094d03f 100644 (file)
@@ -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();
index 067a972ae28346a1aada5fba69e28ac9f1ffebf7..3418dd837cf371ac6c3defd34b4e89ab61e74e9b 100644 (file)
@@ -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> &params)
                        // 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);
index 3f5a910c9802627d971c6ccc8f6528745d4f3ccf..8610a16662567212368fae75402443ab657b56f6 100644 (file)
@@ -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");