]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree.cpp
Moved some stuff to debug
[user/henk/code/inspircd.git] / src / modules / m_spanningtree.cpp
index a6db47bf5e9663e351b0680e96bd145b9d6cc2b4..edfef803981dfb5a625611fe20bd2acd2aa248da 100644 (file)
@@ -68,7 +68,6 @@ class TreeServer
        int UserCount;
        int OperCount;
        TreeSocket* Socket;     // for directly connected servers this points at the socket object
-       bool Deleted;
        
  public:
 
@@ -79,7 +78,6 @@ class TreeServer
                ServerDesc = "";
                VersionString = "";
                UserCount = OperCount = 0;
-               Deleted = false;
        }
 
        TreeServer(std::string Name, std::string Desc) : ServerName(Name), ServerDesc(Desc)
@@ -87,14 +85,12 @@ class TreeServer
                Parent = NULL;
                VersionString = "";
                UserCount = OperCount = 0;
-               Deleted = false;
        }
 
        TreeServer(std::string Name, std::string Desc, TreeServer* Above, TreeSocket* Sock) : Parent(Above), ServerName(Name), ServerDesc(Desc), Socket(Sock)
        {
                VersionString = "";
                UserCount = OperCount = 0;
-               Deleted = false;
        }
 
        std::string GetName()
@@ -149,11 +145,6 @@ class TreeServer
                }
        }
 
-       void MarkDeleted()
-       {
-               this->Deleted = true;
-       }
-
        void AddChild(TreeServer* Child)
        {
                Children.push_back(Child);
@@ -181,14 +172,15 @@ class TreeServer
                        stillchildren = false;
                        for (std::vector<TreeServer*>::iterator a = Children.begin(); a < Children.end(); a++)
                        {
-                               TreeServer*a = (TreeServer*)*a;
-                               a->Tidy();
+                               TreeServer* s = (TreeServer*)*a;
+                               s->Tidy();
                                Children.erase(a);
-                               delete a;
+                               delete s;
                                stillchildren = true;
                                break;
                        }
                }
+               return true;
        }
 };
 
@@ -388,8 +380,7 @@ class TreeSocket : public InspSocket
                        this->SquitServer(recursive_server);
                }
                // Now we've whacked the kids, whack self
-               this->MarkDeleted();
-               log(DEBUG,"Deleted %s",Current->GetName());
+               log(DEBUG,"Deleted %s",Current->GetName().c_str());
                bool quittingpeople = true;
                while (quittingpeople)
                {
@@ -398,7 +389,8 @@ class TreeSocket : public InspSocket
                        {
                                if (!strcasecmp(u->second->server,Current->GetName().c_str()))
                                {
-                                       Srv->QuitUser(u,Current->GetName()+" "+std::string(Srv->GetServerName()));
+                                       log(DEBUG,"Quitting user %s of server %s",u->second->nick,u->second->server);
+                                       Srv->QuitUser(u->second,Current->GetName()+" "+std::string(Srv->GetServerName()));
                                        quittingpeople = true;
                                        break;
                                }
@@ -406,11 +398,31 @@ class TreeSocket : public InspSocket
                }
        }
 
-       void Squit(TreeServer* Current)
+       void Squit(TreeServer* Current,std::string reason)
        {
-               SquitServer(Current);
-               Current->Tidy();
-               Current->GetParent()->DelChild(Current);
+               if (Current)
+               {
+                       std::deque<std::string> params;
+                       params.push_back(Current->GetName());
+                       params.push_back(":"+reason);
+                       DoOneToAllButSender(Current->GetParent()->GetName(),"SQUIT",params,Current->GetName());
+                       if (Current->GetParent() == TreeRoot)
+                       {
+                               Srv->SendOpers("Server \002"+Current->GetName()+"\002 SQUIT: "+reason);
+                       }
+                       else
+                       {
+                               Srv->SendOpers("Server \002"+Current->GetName()+"\002 split from server \002"+Current->GetParent()->GetName()+"\002 with reason: "+reason);
+                       }
+                       SquitServer(Current);
+                       Current->Tidy();
+                       Current->GetParent()->DelChild(Current);
+                       delete Current;
+               }
+               else
+               {
+                       log(DEBUG,"Squit from unknown server");
+               }
        }
 
        bool ForceJoin(std::string source, std::deque<std::string> params)
@@ -610,7 +622,7 @@ class TreeSocket : public InspSocket
                TreeServer* Node = new TreeServer(servername,description,ParentOfThis,NULL);
                ParentOfThis->AddChild(Node);
                DoOneToAllButSender(prefix,"SERVER",params,prefix);
-               Srv->SendOpers("*** Server "+prefix+" introduced server "+servername+" ("+description+")");
+               Srv->SendOpers("*** Server \002"+prefix+"\002 introduced server \002"+servername+"\002 ("+description+")");
                return true;
        }
 
@@ -667,7 +679,7 @@ class TreeSocket : public InspSocket
                {
                        if ((x->Name == servername) && (x->RecvPass == password))
                        {
-                               Srv->SendOpers("*** Verified incoming server connection from "+servername+"["+this->GetIP()+"] ("+description+")");
+                               Srv->SendOpers("*** Verified incoming server connection from \002"+servername+"\002["+this->GetIP()+"] ("+description+")");
                                this->InboundServerName = servername;
                                this->InboundDescription = description;
                                // this is good. Send our details: Our server name and description and hopcount of 0,
@@ -716,7 +728,7 @@ class TreeSocket : public InspSocket
 
        bool ProcessLine(std::string line)
        {
-               Srv->SendToModeMask("o",WM_AND,"inbound-line: '"+line+"'");
+               Srv->Log(DEBUG,"inbound-line: '"+line+"'");
 
                std::deque<std::string> params = this->Split(line);
                std::string command = "";
@@ -816,6 +828,14 @@ class TreeSocket : public InspSocket
                                {
                                        return this->RemoteServer(prefix,params);
                                }
+                               else if (command == "SQUIT")
+                               {
+                                       if (params.size() == 2)
+                                       {
+                                               this->Squit(FindServer(params[0]),params[1]);
+                                       }
+                                       return true;
+                               }
                                else
                                {
                                        // not a special inter-server command.
@@ -865,7 +885,7 @@ class TreeSocket : public InspSocket
        {
                if (this->LinkState == CONNECTING)
                {
-                       Srv->SendOpers("*** CONNECT: Connection to "+myhost+" timed out.");
+                       Srv->SendOpers("*** CONNECT: Connection to \002"+myhost+"\002 timed out.");
                }
        }
 
@@ -886,11 +906,7 @@ class TreeSocket : public InspSocket
                        params.push_back(quitserver);
                        params.push_back(":Remote host closed the connection");
                        DoOneToAllButSender(Srv->GetServerName(),"SQUIT",params,quitserver);
-                       Squit(s);
-               }
-               else
-               {
-                       log(DEBUG,"SQUIT from unknown server %s",quitserver.c_str());
+                       Squit(s,"Remote host closed the connection");
                }
        }