diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-12-13 20:00:33 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-12-13 20:00:33 +0000 |
commit | f240285155d115ee3a0fd437944f2bec05a0c14c (patch) | |
tree | c5279b786faf023765a2b692b89bdc63b0716225 | |
parent | 15e70c8fe60f6d36120c3e278e391f4909aa3688 (diff) |
Improve the way 005 ISUPPORT is sent to users when they connect, cache it in a much more sane format which is much simpler to spool to them
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5978 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/configreader.h | 9 | ||||
-rw-r--r-- | src/cmd_version.cpp | 21 | ||||
-rw-r--r-- | src/configreader.cpp | 31 | ||||
-rw-r--r-- | src/inspircd.cpp | 1 | ||||
-rw-r--r-- | src/modules/m_spanningtree.cpp | 19 | ||||
-rw-r--r-- | src/users.cpp | 23 |
6 files changed, 45 insertions, 59 deletions
diff --git a/include/configreader.h b/include/configreader.h index 6c000eb60..622c44d0d 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -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. diff --git a/src/cmd_version.cpp b/src/cmd_version.cpp index 311659e59..5a0e2c19e 100644 --- a/src/cmd_version.cpp +++ b/src/cmd_version.cpp @@ -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; } diff --git a/src/configreader.cpp b/src/configreader.cpp index b0106eb5e..bcf47eb03 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -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); diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 8c297af07..aef7b09e6 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -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) diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index a50aac256..c1680cf7d 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -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 diff --git a/src/users.cpp b/src/users.cpp index ed979e337..6dab25495 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -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(); /* |