]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/server.cpp
Fix typo.
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / server.cpp
index 0256756425f4b815152d34d4ff53bd6c272c90af..bba4bdaddbc4397c20170bedb87463d663f37888 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
  * See: http://wiki.inspircd.org/Credits
  *
  * This program is free but copyrighted software; see
@@ -14,7 +14,6 @@
 #include "inspircd.h"
 #include "socket.h"
 #include "xline.h"
-#include "../transport.h"
 #include "socketengine.h"
 
 #include "main.h"
@@ -46,7 +45,7 @@ bool TreeSocket::RemoteServer(const std::string &prefix, parameterlist &params)
 
        if (!ParentOfThis)
        {
-               this->SendError("Protocol error - Introduced remote server from unknown server "+ParentOfThis->GetName());
+               this->SendError("Protocol error - Introduced remote server from unknown server "+prefix);
                return false;
        }
        if (!ServerInstance->IsSID(sid))
@@ -72,7 +71,7 @@ bool TreeSocket::RemoteServer(const std::string &prefix, parameterlist &params)
 
        Link* lnk = Utils->FindLink(servername);
 
-       TreeServer *Node = new TreeServer(this->Utils, ServerInstance, servername, description, sid, ParentOfThis,NULL, lnk ? lnk->Hidden : false);
+       TreeServer *Node = new TreeServer(Utils, servername, description, sid, ParentOfThis,NULL, lnk ? lnk->Hidden : false);
 
        ParentOfThis->AddChild(Node);
        params[4] = ":" + params[4];
@@ -101,10 +100,6 @@ bool TreeSocket::Outbound_Reply_Server(parameterlist &params)
        std::string description = params[4];
        int hops = atoi(params[2].c_str());
 
-       this->InboundServerName = sname;
-       this->InboundDescription = description;
-       this->InboundSID = sid;
-
        this->SendCapabilities(2);
 
        if (hops)
@@ -120,8 +115,9 @@ bool TreeSocket::Outbound_Reply_Server(parameterlist &params)
                return false;
        }
 
-       for (std::vector<Link>::iterator x = Utils->LinkBlocks.begin(); x < Utils->LinkBlocks.end(); x++)
+       for (std::vector<reference<Link> >::iterator i = Utils->LinkBlocks.begin(); i < Utils->LinkBlocks.end(); i++)
        {
+               Link* x = *i;
                if (x->Name != servername && x->Name != "*") // open link allowance
                        continue;
 
@@ -157,18 +153,18 @@ bool TreeSocket::Outbound_Reply_Server(parameterlist &params)
                this->LinkState = CONNECTED;
 
                Utils->timeoutlist.erase(this);
+               linkID = sname;
 
-               TreeServer *Node = new TreeServer(this->Utils, ServerInstance, sname, description, sid, Utils->TreeRoot, this, x->Hidden);
+               MyRoot = new TreeServer(Utils, sname, description, sid, Utils->TreeRoot, this, x->Hidden);
 
-               Utils->TreeRoot->AddChild(Node);
+               Utils->TreeRoot->AddChild(MyRoot);
                params[4] = ":" + params[4];
 
-
                /* IMPORTANT: Take password/hmac hash OUT of here before we broadcast the introduction! */
                params[1] = "*";
                Utils->DoOneToAllButSender(ServerInstance->Config->GetSID(),"SERVER",params,sname);
 
-               this->DoBurst(Node);
+               this->DoBurst(MyRoot);
                return true;
        }
 
@@ -196,10 +192,6 @@ bool TreeSocket::Inbound_Server(parameterlist &params)
        std::string description = params[4];
        int hops = atoi(params[2].c_str());
 
-       this->InboundServerName = sname;
-       this->InboundDescription = description;
-       this->InboundSID = sid;
-
        this->SendCapabilities(2);
 
        if (hops)
@@ -215,8 +207,9 @@ bool TreeSocket::Inbound_Server(parameterlist &params)
                return false;
        }
 
-       for (std::vector<Link>::iterator x = Utils->LinkBlocks.begin(); x < Utils->LinkBlocks.end(); x++)
+       for (std::vector<reference<Link> >::iterator i = Utils->LinkBlocks.begin(); i < Utils->LinkBlocks.end(); i++)
        {
+               Link* x = *i;
                if (x->Name != servername && x->Name != "*") // open link allowance
                        continue;
 
@@ -230,8 +223,9 @@ bool TreeSocket::Inbound_Server(parameterlist &params)
                TreeServer* CheckDupe = Utils->FindServer(sname);
                if (CheckDupe)
                {
-                       this->SendError("Server "+sname+" already exists on server "+CheckDupe->GetParent()->GetName()+"!");
-                       ServerInstance->SNO->WriteToSnoMask('l',"Server connection from \2"+sname+"\2 denied, already exists on server "+CheckDupe->GetParent()->GetName());
+                       std::string pname = CheckDupe->GetParent() ? CheckDupe->GetParent()->GetName() : "<ourself>";
+                       SendError("Server "+sname+" already exists on server "+pname+"!");
+                       ServerInstance->SNO->WriteToSnoMask('l',"Server connection from \2"+sname+"\2 denied, already exists on server "+pname);
                        return false;
                }
 
@@ -247,19 +241,21 @@ bool TreeSocket::Inbound_Server(parameterlist &params)
                        return false;
                }
 
-
-               ServerInstance->SNO->WriteToSnoMask('l',"Verified incoming server connection from \002"+sname+"\002["+(x->HiddenFromStats ? "<hidden>" : this->IP)+"] ("+description+")");
-               if (this->GetIOHook())
-               {
-                       std::string name = BufferedSocketNameRequest(Utils->Creator, this->GetIOHook()).Send();
-                       ServerInstance->SNO->WriteToSnoMask('l',"Connection from \2"+sname+"\2["+(x->HiddenFromStats ? "<hidden>" : this->IP)+"] using transport \2"+name+"\2");
-               }
+               ServerInstance->SNO->WriteToSnoMask('l',"Verified incoming server connection " + linkID + " ("+description+")");
+               linkID = sname;
 
                // this is good. Send our details: Our server name and description and hopcount of 0,
                // along with the sendpass from this block.
                this->SendCapabilities(2);
                this->WriteLine(std::string("SERVER ")+ServerInstance->Config->ServerName+" "+this->MakePass(x->SendPass, this->GetTheirChallenge())+" 0 "+ServerInstance->Config->GetSID()+" :"+ServerInstance->Config->ServerDesc);
                // move to the next state, we are now waiting for THEM.
+               MyRoot = new TreeServer(Utils, sname, description, sid, Utils->TreeRoot, this, x->Hidden);
+               Utils->TreeRoot->AddChild(MyRoot);
+
+               params[1] = "*";
+               params[4] = ":" + params[4];
+               Utils->DoOneToAllButSender(ServerInstance->Config->GetSID(),"SERVER",params,sname);
+
                this->LinkState = WAIT_AUTH_2;
                return true;
        }