]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/server.cpp
Merge pull request #495 from SaberUK/master+fix-libcpp
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / server.cpp
index bba4bdaddbc4397c20170bedb87463d663f37888..19e2d53a6f6a64fd1f3d84ea3eca54b757f3f688 100644 (file)
@@ -1,22 +1,25 @@
-/*       +------------------------------------+
- *       | Inspire Internet Relay Chat Daemon |
- *       +------------------------------------+
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
+ *
+ *   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
+ *   Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
  *
- *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
+ * This file is part of InspIRCd.  InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
  *
- * This program is free but copyrighted software; see
- *            the file COPYING for details.
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
  *
- * ---------------------------------------------------
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+
 #include "inspircd.h"
-#include "socket.h"
-#include "xline.h"
-#include "socketengine.h"
 
-#include "main.h"
 #include "utils.h"
 #include "link.h"
 #include "treeserver.h"
@@ -48,7 +51,7 @@ bool TreeSocket::RemoteServer(const std::string &prefix, parameterlist &params)
                this->SendError("Protocol error - Introduced remote server from unknown server "+prefix);
                return false;
        }
-       if (!ServerInstance->IsSID(sid))
+       if (!InspIRCd::IsSID(sid))
        {
                this->SendError("Invalid format server ID: "+sid+"!");
                return false;
@@ -98,17 +101,9 @@ bool TreeSocket::Outbound_Reply_Server(parameterlist &params)
        std::string password = params[1];
        std::string sid = params[3];
        std::string description = params[4];
-       int hops = atoi(params[2].c_str());
 
        this->SendCapabilities(2);
 
-       if (hops)
-       {
-               this->SendError("Server too far away for authentication");
-               ServerInstance->SNO->WriteToSnoMask('l',"Server connection from \2"+sname+"\2 denied, server is too far away for authentication");
-               return false;
-       }
-
        if (!ServerInstance->IsSID(sid))
        {
                this->SendError("Invalid format server ID: "+sid+"!");
@@ -156,15 +151,15 @@ bool TreeSocket::Outbound_Reply_Server(parameterlist &params)
                linkID = sname;
 
                MyRoot = new TreeServer(Utils, sname, description, sid, Utils->TreeRoot, this, x->Hidden);
-
                Utils->TreeRoot->AddChild(MyRoot);
+               this->DoBurst(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(MyRoot);
                return true;
        }
 
@@ -190,17 +185,9 @@ bool TreeSocket::Inbound_Server(parameterlist &params)
        std::string password = params[1];
        std::string sid = params[3];
        std::string description = params[4];
-       int hops = atoi(params[2].c_str());
 
        this->SendCapabilities(2);
 
-       if (hops)
-       {
-               this->SendError("Server too far away for authentication");
-               ServerInstance->SNO->WriteToSnoMask('l',"Server connection from \2"+sname+"\2 denied, server is too far away for authentication");
-               return false;
-       }
-
        if (!ServerInstance->IsSID(sid))
        {
                this->SendError("Invalid format server ID: "+sid+"!");
@@ -230,7 +217,7 @@ bool TreeSocket::Inbound_Server(parameterlist &params)
                }
 
                /* Check for fully initialized instances of the server by id */
-               ServerInstance->Logs->Log("m_spanningtree",DEBUG,"Looking for dupe SID %s", sid.c_str());
+               ServerInstance->Logs->Log("m_spanningtree",LOG_DEBUG,"Looking for dupe SID %s", sid.c_str());
                CheckDupe = Utils->FindServerID(sid);
 
                if (CheckDupe)
@@ -247,15 +234,11 @@ bool TreeSocket::Inbound_Server(parameterlist &params)
                // 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);
+               this->WriteLine("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;
        }