]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Store id in TreeServer, use TreeServer::GetID() to get the id (NOTE: it is std::string)
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 27 Aug 2007 20:50:07 +0000 (20:50 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 27 Aug 2007 20:50:07 +0000 (20:50 +0000)
Server id sent on all outbound and inbound SERVER now. last parameter before desc.
Min params for SERVER is now 5, not 4.

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7918 e03df62e-2008-0410-955e-edbf42e46eb7

src/modules/m_spanningtree/treeserver.cpp
src/modules/m_spanningtree/treeserver.h
src/modules/m_spanningtree/treesocket.h
src/modules/m_spanningtree/treesocket1.cpp
src/modules/m_spanningtree/treesocket2.cpp

index d13075f0f8d7aa11fc7d4e03198f4aefd4be3f23..d252f23868b1be837376e1990fdf04d0633d5c8d 100644 (file)
@@ -124,6 +124,16 @@ TreeServer::TreeServer(SpanningTreeUtilities* Util, InspIRCd* Instance, std::str
        this->AddHashEntry();
 }
 
+std::string& TreeServer::GetID()
+{
+       return sid;
+}
+
+void TreeServer::SetID(const std::string &id)
+{
+       sid = id;
+}
+
 int TreeServer::QuitUsers(const std::string &reason)
 {
        const char* reason_s = reason.c_str();
index d8d3b70e8d8ba1c3681919d106d1b736246e4406..125fdbd67924e228aa8af58de9b05ed767e7f703 100644 (file)
@@ -43,6 +43,7 @@ class TreeServer : public classbase
        time_t NextPing;                        /* After this time, the server should be PINGed*/
        bool LastPingWasGood;                   /* True if the server responded to the last PING with a PONG */
        SpanningTreeUtilities* Utils;           /* Utility class */
+       std::string sid;                        /* Server ID */
 
  public:
 
@@ -181,6 +182,14 @@ class TreeServer : public classbase
         */
        bool Tidy();
 
+       /** Get server ID
+        */
+       std::string& GetID();
+
+       /** Set server ID
+        */
+       void SetID(const std::string &id);
+
        /** Destructor
         */
        ~TreeServer();
index 55a83f3efa950b2a047303fa7792c9614773f2d6..e7cacf0c62691fe73b296d9a893ed2b1517ea4d3 100644 (file)
@@ -83,6 +83,7 @@ class TreeSocket : public InspSocket
        ServerState LinkState;                  /* Link state */
        std::string InboundServerName;          /* Server name sent to us by other side */
        std::string InboundDescription;         /* Server description (GECOS) sent to us by the other side */
+       std::string InboundSID;                 /* Server ID sent to us by the other side */
        int num_lost_users;                     /* Users lost in split */
        int num_lost_servers;                   /* Servers lost in split */
        time_t NextPing;                        /* Time when we are due to ping this server */
index f419f9becda343f85aea29cf935d7a44e3c6e51b..9c53a16cdb8ec2de9e0824773d12151de4f277b6 100644 (file)
@@ -268,7 +268,9 @@ void TreeSocket::SendServers(TreeServer* Current, TreeServer* s, int hops)
                TreeServer* recursive_server = Current->GetChild(q);
                if (recursive_server != s)
                {
-                       snprintf(command,1024,":%s SERVER %s * %d :%s",Current->GetName().c_str(),recursive_server->GetName().c_str(),hops,recursive_server->GetDesc().c_str());
+                       snprintf(command,1024,":%s SERVER %s * %d %s :%s",Current->GetName().c_str(),recursive_server->GetName().c_str(),hops,
+                                       recursive_server->GetID().c_str(),
+                                       recursive_server->GetDesc().c_str());
                        this->WriteLine(command);
                        this->WriteLine(":"+recursive_server->GetName()+" VERSION :"+recursive_server->GetVersion());
                        /* down to next level */
@@ -432,6 +434,12 @@ bool TreeSocket::Capab(const std::deque<std::string> &params)
        }
        else if (params[0] == "END")
        {
+               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);
+
                std::string reason;
                int ip6support = 0;
 #ifdef SUPPORT_IP6LINKS
@@ -503,14 +511,15 @@ bool TreeSocket::Capab(const std::deque<std::string> &params)
                        this->SetTheirChallenge(n->second);
                        if (!this->GetTheirChallenge().empty() && (this->LinkState == CONNECTING))
                        {
-                               this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+this->MakePass(OutboundPass, this->GetTheirChallenge())+" 0 :"+this->Instance->Config->ServerDesc);
+                               this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+this->MakePass(OutboundPass, this->GetTheirChallenge())+" 0 "+
+                                               OurSID+" :"+this->Instance->Config->ServerDesc);
                        }
                }
                else
                {
                        /* They didnt specify a challenge or we don't have m_sha256.so, we use plaintext */
                        if (this->LinkState == CONNECTING)
-                               this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+OutboundPass+" 0 :"+this->Instance->Config->ServerDesc);
+                               this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+OutboundPass+" 0 "+OurSID+" :"+this->Instance->Config->ServerDesc);
                }
 
                if (reason.length())
index 64705cb983641192bf6a89dcafcc6220e4d13b2f..067a972ae28346a1aada5fba69e28ac9f1ffebf7 100644 (file)
@@ -779,12 +779,13 @@ bool TreeSocket::RemoveStatus(const std::string &prefix, std::deque<std::string>
 
 bool TreeSocket::RemoteServer(const std::string &prefix, std::deque<std::string> &params)
 {
-       if (params.size() < 4)
+       if (params.size() < 5)
                return false;
        std::string servername = params[0];
        std::string password = params[1];
        // hopcount is not used for a remote server, we calculate this ourselves
-       std::string description = params[3];
+       std::string sid = params[3];
+       std::string description = params[4];
        TreeServer* ParentOfThis = Utils->FindServer(prefix);
        if (!ParentOfThis)
        {
@@ -801,7 +802,8 @@ bool TreeSocket::RemoteServer(const std::string &prefix, std::deque<std::string>
        Link* lnk = Utils->FindLink(servername);
        TreeServer* Node = new TreeServer(this->Utils,this->Instance,servername,description,ParentOfThis,NULL, lnk ? lnk->Hidden : false);
        ParentOfThis->AddChild(Node);
-       params[3] = ":" + params[3];
+       Node->SetID(sid);
+       params[4] = ":" + params[4];
        Utils->SetRemoteBursting(Node, true);
        Utils->DoOneToAllButSender(prefix,"SERVER",params,prefix);
        this->Instance->SNO->WriteToSnoMask('l',"Server \002"+prefix+"\002 introduced server \002"+servername+"\002 ("+description+")");
@@ -828,17 +830,19 @@ bool TreeSocket::ComparePass(const std::string &ours, const std::string &theirs)
 
 bool TreeSocket::Outbound_Reply_Server(std::deque<std::string> &params)
 {
-       if (params.size() < 4)
+       if (params.size() < 5)
                return false;
 
        irc::string servername = params[0].c_str();
        std::string sname = params[0];
        std::string password = params[1];
-       std::string description = params[3];
+       std::string sid = params[3];
+       std::string description = params[4];
        int hops = atoi(params[2].c_str());
 
        this->InboundServerName = sname;
        this->InboundDescription = description;
+       this->InboundSID = sid;
 
        if (!sentcapab)
                this->SendCapabilities();
@@ -871,7 +875,8 @@ bool TreeSocket::Outbound_Reply_Server(std::deque<std::string> &params)
                        // node.
                        TreeServer* Node = new TreeServer(this->Utils,this->Instance,sname,description,Utils->TreeRoot,this,x->Hidden);
                        Utils->TreeRoot->AddChild(Node);
-                       params[3] = ":" + params[3];
+                       params[4] = ":" + params[4];
+                       Node->SetID(params[3]);
                        Utils->DoOneToAllButSender(Utils->TreeRoot->GetName(),"SERVER",params,sname);
                        this->bursting = true;
                        this->DoBurst(Node);
@@ -885,16 +890,23 @@ bool TreeSocket::Outbound_Reply_Server(std::deque<std::string> &params)
 
 bool TreeSocket::Inbound_Server(std::deque<std::string> &params)
 {
-       if (params.size() < 4)
+       if (params.size() < 5)
                return false;
        irc::string servername = params[0].c_str();
        std::string sname = params[0];
        std::string password = params[1];
-       std::string description = params[3];
+       std::string sid = params[3];
+       std::string description = params[4];
+       std::string OurSID;
        int hops = atoi(params[2].c_str());
 
        this->InboundServerName = sname;
        this->InboundDescription = description;
+       this->InboundSID = sid;
+
+       OurSID += (char)((Instance->Config->sid / 100) + 48);
+       OurSID += (char)((Instance->Config->sid / 10) % 10 + 48);
+       OurSID += (char)(Instance->Config->sid % 10 + 48);
 
        if (!sentcapab)
                this->SendCapabilities();
@@ -941,7 +953,7 @@ bool TreeSocket::Inbound_Server(std::deque<std::string> &params)
 
                        // this is good. Send our details: Our server name and description and hopcount of 0,
                        // along with the sendpass from this block.
-                       this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+this->MakePass(x->SendPass, this->GetTheirChallenge())+" 0 :"+this->Instance->Config->ServerDesc);
+                       this->WriteLine(std::string("SERVER ")+this->Instance->Config->ServerName+" "+this->MakePass(x->SendPass, this->GetTheirChallenge())+" 0 "+OurSID+" :"+this->Instance->Config->ServerDesc);
                        // move to the next state, we are now waiting for THEM.
                        this->LinkState = WAIT_AUTH_2;
                        return true;
@@ -1071,7 +1083,9 @@ bool TreeSocket::ProcessLine(std::string &line)
                                params.push_back(InboundServerName);
                                params.push_back("*");
                                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);