]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree.cpp
Decide that it wasn't quite appropriate :(
[user/henk/code/inspircd.git] / src / modules / m_spanningtree.cpp
index e9cdeab93e962cc48264d0863a2be0bc8c961129..1374c88a2e9f839573ec3bc8367d81856a82ad42 100644 (file)
@@ -896,7 +896,7 @@ class TreeSocket : public InspSocket
                        {
                                std::string oldtopic = c->topic;
                                strlcpy(c->topic,params[3].c_str(),MAXTOPIC);
-                               strlcpy(c->setby,params[2].c_str(),NICKMAX);
+                               strlcpy(c->setby,params[2].c_str(),NICKMAX-1);
                                c->topicset = ts;
                                /* if the topic text is the same as the current topic,
                                 * dont bother to send the TOPIC command out, just silently
@@ -1091,7 +1091,7 @@ class TreeSocket : public InspSocket
 
                clientlist[tempnick] = new userrec();
                clientlist[tempnick]->fd = FD_MAGIC_NUMBER;
-               strlcpy(clientlist[tempnick]->nick, tempnick,NICKMAX);
+               strlcpy(clientlist[tempnick]->nick, tempnick,NICKMAX-1);
                strlcpy(clientlist[tempnick]->host, params[2].c_str(),160);
                strlcpy(clientlist[tempnick]->dhost, params[3].c_str(),160);
                clientlist[tempnick]->server = (char*)FindServerNamePtr(source.c_str());
@@ -1404,7 +1404,7 @@ class TreeSocket : public InspSocket
                        if (this->keylength)
                        {
                                // pad it to the key length
-                               int n = line.length() % this->keylength;
+                               int n = this->keylength - (line.length() % this->keylength);
                                if (n)
                                {
                                        log(DEBUG,"Append %d chars to line to make it %d long from %d, key length %d",n,n+line.length(),line.length(),this->keylength);
@@ -1444,7 +1444,7 @@ class TreeSocket : public InspSocket
                userrec* u = Srv->FindNick(prefix);
                if (u)
                {
-                       strlcpy(u->oper,opertype.c_str(),NICKMAX);
+                       strlcpy(u->oper,opertype.c_str(),NICKMAX-1);
                        if (!strchr(u->modes,'o'))
                        {
                                strcat(u->modes,"o");
@@ -2295,6 +2295,16 @@ class TreeSocket : public InspSocket
                                }
                                else if (command == "PING")
                                {
+                                       /*
+                                        * We just got a ping from a server that's bursting.
+                                        * This can't be right, so set them to not bursting, and
+                                        * apply their lines.
+                                        */
+                                       if (this->bursting)
+                                       {
+                                               this->bursting = false;
+                                               apply_lines(APPLY_ZLINES|APPLY_GLINES|APPLY_QLINES);
+                                       }
                                        if (prefix == "")
                                        {
                                                prefix = this->GetName();
@@ -2303,6 +2313,16 @@ class TreeSocket : public InspSocket
                                }
                                else if (command == "PONG")
                                {
+                                       /*
+                                        * We just got a pong from a server that's bursting.
+                                        * This can't be right, so set them to not bursting, and
+                                        * apply their lines.
+                                        */
+                                       if (this->bursting)
+                                       {
+                                               this->bursting = false;
+                                               apply_lines(APPLY_ZLINES|APPLY_GLINES|APPLY_QLINES);
+                                       }
                                        if (prefix == "")
                                        {
                                                prefix = this->GetName();
@@ -2345,6 +2365,24 @@ class TreeSocket : public InspSocket
                                {
                                        return this->Time(prefix,params);
                                }
+                               else if ((command == "KICK") && (IsServer(prefix)))
+                               {
+                                       std::string sourceserv = this->myhost;
+                                       if (params.size() == 3)
+                                       {
+                                               userrec* user = Srv->FindNick(params[1]);
+                                               chanrec* chan = Srv->FindChannel(params[0]);
+                                               if (user && chan)
+                                               {
+                                                       server_kick_channel(user,chan,(char*)params[2].c_str(),false);
+                                               }
+                                       }
+                                       if (this->InboundServerName != "")
+                                       {
+                                               sourceserv = this->InboundServerName;
+                                       }
+                                       return DoOneToAllButSenderRaw(line,sourceserv,prefix,command,params);
+                               }
                                else if (command == "SVSJOIN")
                                {
                                        if (prefix == "")
@@ -2757,7 +2795,7 @@ class ModuleSpanningTree : public Module
                }
                for (unsigned int q = 0; q < Current->ChildCount(); q++)
                {
-                       if ((HideULines) && (Srv->IsUlined(Current->GetName())))
+                       if ((HideULines) && (Srv->IsUlined(Current->GetChild(q)->GetName())))
                        {
                                if (*user->oper)
                                {
@@ -2769,6 +2807,9 @@ class ModuleSpanningTree : public Module
                                ShowLinks(Current->GetChild(q),user,hops+1);
                        }
                }
+               /* Don't display the line if its a uline, hide ulines is on, and the user isnt an oper */
+               if ((HideULines) && (Srv->IsUlined(Current->GetName())) && (!*user->oper))
+                       return;
                WriteServ(user->fd,"364 %s %s %s :%d %s",user->nick,Current->GetName().c_str(),(FlatLinks && (!*user->oper)) ? Srv->GetServerName().c_str() : Parent.c_str(),(FlatLinks && (!*user->oper)) ? 0 : hops,Current->GetDesc().c_str());
        }
 
@@ -3463,6 +3504,14 @@ class ModuleSpanningTree : public Module
                        params.push_back(":"+reason);
                        DoOneToMany(source->nick,"KICK",params);
                }
+               else if (!source)
+               {
+                       std::deque<std::string> params;
+                       params.push_back(chan->name);
+                       params.push_back(user->nick);
+                       params.push_back(":"+reason);
+                       DoOneToMany(Srv->GetServerName(),"KICK",params);
+               }
        }
 
        virtual void OnRemoteKill(userrec* source, userrec* dest, std::string reason)