]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/treesocket2.cpp
Added ability to send and receive a challenge, dont do anything with it yet
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / treesocket2.cpp
index 128f4613e1f5ff4aa803e3be18d207d4c506ce19..da456603fa5c78a9a3ae6b1e8a89eb9383ca8d64 100644 (file)
@@ -1,3 +1,16 @@
+/*       +------------------------------------+
+ *       | Inspire Internet Relay Chat Daemon |
+ *       +------------------------------------+
+ *
+ *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ * See: http://www.inspircd.org/wiki/index.php/Credits
+ *
+ * This program is free but copyrighted software; see
+ *            the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
 #include "configreader.h"
 #include "users.h"
 #include "channels.h"
@@ -335,7 +348,7 @@ bool TreeSocket::ServiceJoin(const std::string &prefix, std::deque<std::string>
        {
                /* only join if it's local, otherwise just pass it on! */
                if (IS_LOCAL(u))
-                       chanrec::JoinUser(this->Instance, u, params[1].c_str(), false);
+                       chanrec::JoinUser(this->Instance, u, params[1].c_str(), false, "", Instance->Time());
                Utils->DoOneToAllButSender(prefix,"SVSJOIN",params,prefix);
        }
        return true;
@@ -400,6 +413,7 @@ bool TreeSocket::LocalPong(const std::string &prefix, std::deque<std::string> &p
                if (ServerSource)
                {
                        ServerSource->SetPingFlag();
+                       ServerSource->rtt = Instance->Time() - ServerSource->LastPing;
                }
        }
        else
@@ -542,7 +556,8 @@ bool TreeSocket::AddLine(const std::string &prefix, std::deque<std::string> &par
        {
                if (atoi(params[4].c_str()))
                {
-                       this->Instance->SNO->WriteToSnoMask('x',"%s Added %cLINE on %s to expire in %lu seconds (%s).",prefix.c_str(),*(params[0].c_str()),params[1].c_str(),atoi(params[4].c_str()),params[5].c_str());
+                       time_t c_requires_crap = ConvToInt(params[4]) + Instance->Time();
+                       this->Instance->SNO->WriteToSnoMask('x',"%s Added %cLINE on %s to expire on %s (%s).",prefix.c_str(),*(params[0].c_str()),params[1].c_str(),Instance->TimeString(c_requires_crap).c_str(),params[5].c_str());
                }
                else
                {
@@ -787,10 +802,11 @@ bool TreeSocket::RemoteServer(const std::string &prefix, std::deque<std::string>
        if (CheckDupe)
        {
                this->WriteLine("ERROR :Server "+servername+" already exists!");
-               this->Instance->SNO->WriteToSnoMask('l',"Server connection from \2"+servername+"\2 denied, already exists");
+               this->Instance->SNO->WriteToSnoMask('l',"Server \2"+servername+"\2 being introduced from \2" + prefix + "\2 denied, already exists. Closing link with " + prefix);
                return false;
        }
-       TreeServer* Node = new TreeServer(this->Utils,this->Instance,servername,description,ParentOfThis,NULL);
+       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];
        Utils->DoOneToAllButSender(prefix,"SERVER",params,prefix);
@@ -834,7 +850,7 @@ 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);
+                       TreeServer* Node = new TreeServer(this->Utils,this->Instance,sname,description,Utils->TreeRoot,this,x->Hidden);
                        Utils->TreeRoot->AddChild(Node);
                        params[3] = ":" + params[3];
                        Utils->DoOneToAllButSender(Utils->TreeRoot->GetName(),"SERVER",params,sname);
@@ -902,7 +918,7 @@ void TreeSocket::Split(const std::string &line, std::deque<std::string> &n)
        n.clear();
        irc::tokenstream tokens(line);
        std::string param;
-       while ((param = tokens.GetToken()) != "")
+       while (tokens.GetToken(param))
                n.push_back(param);
        return;
 }
@@ -994,12 +1010,16 @@ bool TreeSocket::ProcessLine(std::string &line)
                                        bool we_have_delta = (Instance->Time(false) != Instance->Time(true));
                                        time_t them = atoi(params[0].c_str());
                                        time_t delta = them - Instance->Time(false);
-                                       if ((delta < -600) || (delta > 600))
+                                       if ((delta < -300) || (delta > 300))
                                        {
-                                               this->Instance->SNO->WriteToSnoMask('l',"\2ERROR\2: Your clocks are out by %d seconds (this is more than ten minutes). Link aborted, \2PLEASE SYNC YOUR CLOCKS!\2",abs(delta));
-                                               this->WriteLine("ERROR :Your clocks are out by "+ConvToStr(abs(delta))+" seconds (this is more than ten minutes). Link aborted, PLEASE SYNC YOUR CLOCKS!");
+                                               Instance->SNO->WriteToSnoMask('l',"\2ERROR\2: Your clocks are out by %d seconds (this is more than five minutes). Link aborted, \2PLEASE SYNC YOUR CLOCKS!\2",abs(delta));
+                                               WriteLine("ERROR :Your clocks are out by "+ConvToStr(abs(delta))+" seconds (this is more than ten minutes). Link aborted, PLEASE SYNC YOUR CLOCKS!");
                                                return false;
                                        }
+                                       else if ((delta < -30) || (delta > 30))
+                                       {
+                                               Instance->SNO->WriteToSnoMask('l',"\2WARNING\2: Your clocks are out by %d seconds. Please consider synching your clocks.", abs(delta));
+                                       }
 
                                        if (!Utils->MasterTime && !we_have_delta)
                                        {
@@ -1009,7 +1029,8 @@ bool TreeSocket::ProcessLine(std::string &line)
                                        }
                                }
                                this->LinkState = CONNECTED;
-                               Node = new TreeServer(this->Utils,this->Instance,InboundServerName,InboundDescription,Utils->TreeRoot,this);
+                               Link* lnk = Utils->FindLink(InboundServerName);
+                               Node = new TreeServer(this->Utils,this->Instance, InboundServerName, InboundDescription, Utils->TreeRoot, this, lnk ? lnk->Hidden : false);
                                Utils->TreeRoot->AddChild(Node);
                                params.clear();
                                params.push_back(InboundServerName);