]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Improve the way 005 ISUPPORT is sent to users when they connect, cache it in a much...
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 13 Dec 2006 20:00:33 +0000 (20:00 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Wed, 13 Dec 2006 20:00:33 +0000 (20:00 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5978 e03df62e-2008-0410-955e-edbf42e46eb7

include/configreader.h
src/cmd_version.cpp
src/configreader.cpp
src/inspircd.cpp
src/modules/m_spanningtree.cpp
src/users.cpp

index 6c000eb60c35ed0b7b42ecf9ff921a0a933811d2..622c44d0d9ae61b8138c418c1afb437ec533a5ab 100644 (file)
@@ -453,6 +453,7 @@ class ServerConfig : public Extensible
         * modules.
         */
        std::string data005;
+       std::vector<std::string> isupport;
 
        /** STATS characters in this list are available
         * only to operators.
@@ -504,6 +505,14 @@ class ServerConfig : public Extensible
         */
        void ClearStack();
 
+       /** Update the 005 vector
+        */
+       void Update005();
+
+       /** Send the 005 numerics (ISUPPORT) to a user
+        */
+       void Send005(userrec* user);
+
        /** Read the entire configuration into memory
         * and initialize this class. All other methods
         * should be used only by the core.
index 311659e5901a7e1436d5b2de369b34f32ba96a94..5a0e2c19edb71e2e057bb0813b09c10cf860da78 100644 (file)
@@ -28,26 +28,7 @@ extern "C" command_t* init_command(InspIRCd* Instance)
 
 CmdResult cmd_version::Handle (const char** parameters, int pcnt, userrec *user)
 {
-       std::stringstream out(ServerInstance->Config->data005);
-       std::string token = "";
-       std::string line5 = "";
-       int token_counter = 0;
-
        user->WriteServ("351 %s :%s",user->nick,ServerInstance->GetVersionString().c_str());
-
-       while (!out.eof())
-       {
-               out >> token;
-               line5 = line5 + token + " ";
-               token_counter++;
-
-               if ((token_counter >= 13) || (out.eof() == true))
-               {
-                       user->WriteServ("005 %s %s:are supported by this server",user->nick,line5.c_str());
-                       line5 = "";
-                       token_counter = 0;
-               }
-       }
-
+       ServerInstance->Config->Send005(user);
        return CMD_SUCCESS;
 }
index b0106eb5edf465147a8efe13b16a49cbdb4b7f7c..bcf47eb037ff7a3f35e89ef02e78407b6eb0ee88 100644 (file)
@@ -115,6 +115,37 @@ bool ServerConfig::DelIOHook(InspSocket* is)
        return false;
 }
 
+void ServerConfig::Update005()
+{
+       std::stringstream out(data005);
+       std::string token;
+       std::string line5;
+       int token_counter = 0;
+       isupport.clear();
+       while (out >> token)
+       {
+               line5 = line5 + token + " ";
+               token_counter++;
+               if (token_counter >= 13)
+               {
+                       char buf[MAXBUF];
+                       snprintf(buf, MAXBUF, "%s:are supported by this server", line5.c_str());
+                       isupport.push_back(buf);
+                       line5 = "";
+                       token_counter = 0;
+               }
+       }
+       char buf[MAXBUF];
+       snprintf(buf, MAXBUF, "%s:are supported by this server", line5.c_str());
+       isupport.push_back(buf);
+}
+
+void ServerConfig::Send005(userrec* user)
+{
+       for (std::vector<std::string>::iterator line = ServerInstance->Config->isupport.begin(); line != ServerInstance->Config->isupport.end(); line++)
+               user->WriteServ("005 %s %s", user->nick, line->c_str());
+}
+
 bool ServerConfig::CheckOnce(char* tag, bool bail, userrec* user)
 {
        int count = ConfValueEnum(this->config_data, tag);
index 8c297af07b45b2e65093b9bd3eddfd933e89ce41..aef7b09e6a730ed3de21436447bd91754fd301ba 100644 (file)
@@ -490,6 +490,7 @@ void InspIRCd::BuildISupport()
        v << MAXAWAY << " CHANMODES=" << this->Modes->ChanModes() << " FNC NETWORK=" << Config->Network << " MAXPARA=32";
        Config->data005 = v.str();
        FOREACH_MOD_I(this,I_On005Numeric,On005Numeric(Config->data005));
+       Config->Update005();
 }
 
 bool InspIRCd::UnloadModule(const char* filename)
index a50aac2563e0e500c084c3eca3bab804eaf4b3fe..c1680cf7d80131dfa559dca65372d1ec1f977cee 100644 (file)
@@ -4677,24 +4677,7 @@ class ModuleSpanningTree : public Module
                        user->WriteServ("351 %s :%s",user->nick,Version.c_str());
                        if (found == Utils->TreeRoot)
                        {
-                               std::stringstream out(ServerInstance->Config->data005);
-                               std::string token = "";
-                               std::string line5 = "";
-                               int token_counter = 0;
-
-                               while (!out.eof())
-                               {
-                                       out >> token;
-                                       line5 = line5 + token + " ";   
-                                       token_counter++;
-
-                                       if ((token_counter >= 13) || (out.eof() == true))
-                                       {
-                                               user->WriteServ("005 %s %s:are supported by this server",user->nick,line5.c_str());
-                                               line5 = "";
-                                               token_counter = 0;
-                                       }
-                               }
+                               ServerInstance->Config->Send005(user);
                        }
                }
                else
index ed979e337a29db2f5fa2183f6c26572604451b5d..6dab2549505fb5aab0bbd92e561a1c4e9f9578bc 100644 (file)
@@ -1212,27 +1212,8 @@ void userrec::FullConnect(CullList* Goners)
        this->WriteServ("003 %s :This server was created %s %s", this->nick, __TIME__, __DATE__);
        this->WriteServ("004 %s %s %s %s %s %s", this->nick, ServerInstance->Config->ServerName, VERSION, ServerInstance->Modes->UserModeList().c_str(), ServerInstance->Modes->ChannelModeList().c_str(), ServerInstance->Modes->ParaModeList().c_str());
 
-       // anfl @ #ratbox, efnet reminded me that according to the RFC this cant contain more than 13 tokens per line...
-       // so i'd better split it :)
-       std::stringstream out(ServerInstance->Config->data005);
-       std::string token = "";
-       std::string line5 = "";
-       int token_counter = 0;
-       
-       while (!out.eof())
-       {
-               out >> token;
-               line5 = line5 + token + " ";
-               token_counter++;
-               
-               if ((token_counter >= 13) || (out.eof() == true))
-               {
-                       this->WriteServ("005 %s %s:are supported by this server", this->nick, line5.c_str());
-                       line5 = "";
-                       token_counter = 0;
-               }
-       }
-       
+       ServerInstance->Config->Send005(this);
+
        this->ShowMOTD();
 
        /*