]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree.cpp
Added <oper:swhois> to m_swhois, which will override <type:swhois> if specified
[user/henk/code/inspircd.git] / src / modules / m_spanningtree.cpp
index 80b5cc5042c795c0f5020c73a9c3053df72b86dc..ae68115c5074a61c6c9c0b97663707fb696f3bc7 100644 (file)
 
 /** If you make a change which breaks the protocol, increment this.
  * If you  completely change the protocol, completely change the number.
+ *
+ * IMPORTANT: If you make changes, document your changes here, without fail:
+ * http://www.inspircd.org/wiki/List_of_protocol_changes_between_versions
+ *
+ * Failure to document your protocol changes will result in a painfully
+ * painful death by pain. You have been warned.
  */
-const long ProtocolVersion = 1101;
+const long ProtocolVersion = 1102;
 
 /*
  * The server list in InspIRCd is maintained as two structures
@@ -1921,6 +1927,25 @@ class TreeSocket : public InspSocket
                if (numusers)
                        buffer.append(list).append("\r\n");
 
+               /* Sorry for the hax. Because newly created channels assume +nt,
+                * if this channel doesnt have +nt, explicitly send -n and -t for the missing modes.
+                */
+               bool inverted = false;
+               if (!c->IsModeSet('n'))
+               {
+                       modes.append("-n");
+                       inverted = true;
+               }
+               if (!c->IsModeSet('t'))
+               {
+                       modes.append("-t");
+                       inverted = true;
+               }
+               if (inverted)
+               {
+                       modes.append("+");
+               }
+
                for (BanList::iterator b = c->bans.begin(); b != c->bans.end(); b++)
                {
                        modes.append("b");
@@ -3402,6 +3427,42 @@ class TreeSocket : public InspSocket
                                        }
                                        return true;
                                }
+                               else if (command == "OPERNOTICE")
+                               {
+                                       std::string sourceserv = this->myhost;
+
+                                       if (this->InboundServerName != "")
+                                               sourceserv = this->InboundServerName;
+
+                                       if (params.size() >= 1)
+                                               Instance->WriteOpers("*** From " + sourceserv + ": " + params[0]);
+
+                                       return Utils->DoOneToAllButSenderRaw(line, sourceserv, prefix, command, params);
+                               }
+                               else if (command == "MODENOTICE")
+                               {
+                                       std::string sourceserv = this->myhost;
+                                       if (this->InboundServerName != "")
+                                               sourceserv = this->InboundServerName;
+                                       if (params.size() >= 2)
+                                       {
+                                               Instance->WriteMode(params[0].c_str(), WM_AND, "*** From %s: %s", sourceserv.c_str(), params[1].c_str());
+                                       }
+
+                                       return Utils->DoOneToAllButSenderRaw(line, sourceserv, prefix, command, params);
+                               }
+                               else if (command == "SNONOTICE")
+                               {
+                                       std::string sourceserv = this->myhost;
+                                       if (this->InboundServerName != "")
+                                               sourceserv = this->InboundServerName;
+                                       if (params.size() >= 2)
+                                       {
+                                               Instance->SNO->WriteToSnoMask(*(params[0].c_str()), "From " + sourceserv + ": "+ params[1]);
+                                       }
+
+                                       return Utils->DoOneToAllButSenderRaw(line, sourceserv, prefix, command, params);
+                               }
                                else if (command == "ENDBURST")
                                {
                                        this->bursting = false;
@@ -3443,6 +3504,9 @@ class TreeSocket : public InspSocket
                                                        this->Instance->SendMode(modelist, params.size(), fake);
        
                                                        delete fake;
+
+                                                       /* Hot potato! pass it on! */
+                                                       return Utils->DoOneToAllButSenderRaw(line,sourceserv,prefix,command,params);
                                                }
                                        }
                                        if (who)
@@ -4093,14 +4157,33 @@ class ModuleSpanningTree : public Module
                if (n_users > max_global)
                        max_global = n_users;
 
-               user->WriteServ("251 %s :There are %d users and %d invisible on %d servers",user->nick,n_users-ServerInstance->InvisibleUserCount(),ServerInstance->InvisibleUserCount(),this->CountServs());
+               unsigned int ulined_count = 0;
+               unsigned int ulined_local_count = 0;
+
+               /* If ulined are hidden and we're not an oper, count the number of ulined servers hidden,
+                * locally and globally (locally means directly connected to us)
+                */
+               if ((Utils->HideULines) && (!*user->oper))
+               {
+                       for (server_hash::iterator q = Utils->serverlist.begin(); q != Utils->serverlist.end(); q++)
+                       {
+                               if (ServerInstance->ULine(q->second->GetName().c_str()))
+                               {
+                                       ulined_count++;
+                                       if (q->second->GetParent() == Utils->TreeRoot)
+                                               ulined_local_count++;
+                               }
+                       }
+               }
+
+               user->WriteServ("251 %s :There are %d users and %d invisible on %d servers",user->nick,n_users-ServerInstance->InvisibleUserCount(),ServerInstance->InvisibleUserCount(),ulined_count ? this->CountServs() - ulined_count : this->CountServs());
                if (ServerInstance->OperCount())
                        user->WriteServ("252 %s %d :operator(s) online",user->nick,ServerInstance->OperCount());
                if (ServerInstance->UnregisteredUserCount())
                        user->WriteServ("253 %s %d :unknown connections",user->nick,ServerInstance->UnregisteredUserCount());
                if (ServerInstance->ChannelCount())
                        user->WriteServ("254 %s %d :channels formed",user->nick,ServerInstance->ChannelCount());
-               user->WriteServ("254 %s :I have %d clients and %d servers",user->nick,ServerInstance->LocalUserCount(),this->CountLocalServs());
+               user->WriteServ("254 %s :I have %d clients and %d servers",user->nick,ServerInstance->LocalUserCount(),ulined_local_count ? this->CountLocalServs() - ulined_local_count : this->CountLocalServs());
                user->WriteServ("265 %s :Current Local Users: %d  Max: %d",user->nick,ServerInstance->LocalUserCount(),max_local);
                user->WriteServ("266 %s :Current Global Users: %d  Max: %d",user->nick,n_users,max_global);
                return;
@@ -4803,6 +4886,14 @@ class ModuleSpanningTree : public Module
                        params.push_back(ConvToStr(channel->age));
                        params.push_back(std::string(channel->GetAllPrefixChars(user))+","+std::string(user->nick));
                        Utils->DoOneToMany(ServerInstance->Config->ServerName,"FJOIN",params);
+                       if (channel->GetUserCounter() == 1)
+                       {
+                               /* First user in, sync the modes for the channel */
+                               params.pop_back();
+                               /* This is safe, all inspircd servers default to +nt */
+                               params.push_back("+nt");
+                               Utils->DoOneToMany(ServerInstance->Config->ServerName,"FMODE",params);
+                       }
                }
        }
 
@@ -5158,9 +5249,29 @@ class ModuleSpanningTree : public Module
                {
                        if (params->size() < 2)
                                return;
-                       // Insert the TS value of the object, either userrec or chanrec
                        Utils->DoOneToMany(ServerInstance->Config->ServerName,"MODE",*params);
                }
+               else if (event->GetEventID() == "send_opers")
+               {
+                       if (params->size() < 1)
+                               return;
+                       (*params)[0] = ":" + (*params)[0];
+                       Utils->DoOneToMany(ServerInstance->Config->ServerName,"OPERNOTICE",*params);
+               }
+               else if (event->GetEventID() == "send_modeset")
+               {
+                       if (params->size() < 2)
+                               return;
+                       (*params)[1] = ":" + (*params)[1];
+                       Utils->DoOneToMany(ServerInstance->Config->ServerName,"MODENOTICE",*params);
+               }
+               else if (event->GetEventID() == "send_snoset")
+               {
+                       if (params->size() < 2)
+                               return;
+                       (*params)[1] = ":" + (*params)[1];
+                       Utils->DoOneToMany(ServerInstance->Config->ServerName,"SNONOTICE",*params);
+               }
                else if (event->GetEventID() == "send_push")
                {
                        if (params->size() < 2)