summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2013-04-11 15:11:31 -0700
committerAttila Molnar <attilamolnar@hush.com>2013-04-11 15:11:31 -0700
commit1858feabd342636df0b52780c978979b4e049fc3 (patch)
treec00ab92b6ff6d002e6c40909587b146ba5e45612 /src
parent295b3e7ba15a228948358bd6f23591a9cb5bf5a8 (diff)
parent5c29c53f651fb0c513a50c9396e08ba340a6d2bf (diff)
Merge pull request #487 from SaberUK/master+better-isupport-api
Convert ISUPPORT to use a map instead of a string.
Diffstat (limited to 'src')
-rw-r--r--src/commands/cmd_version.cpp6
-rw-r--r--src/configreader.cpp37
-rw-r--r--src/helperfuncs.cpp20
-rw-r--r--src/inspircd.cpp2
-rw-r--r--src/modmanager_dynamic.cpp2
-rw-r--r--src/modmanager_static.cpp2
-rw-r--r--src/modules.cpp4
-rw-r--r--src/modules/extra/m_ssl_gnutls.cpp6
-rw-r--r--src/modules/extra/m_ssl_openssl.cpp4
-rw-r--r--src/modules/m_allowinvite.cpp4
-rw-r--r--src/modules/m_banexception.cpp4
-rw-r--r--src/modules/m_blockcaps.cpp4
-rw-r--r--src/modules/m_blockcolor.cpp4
-rw-r--r--src/modules/m_callerid.cpp4
-rw-r--r--src/modules/m_channelban.cpp4
-rw-r--r--src/modules/m_gecosban.cpp4
-rw-r--r--src/modules/m_httpd_stats.cpp8
-rw-r--r--src/modules/m_inviteexception.cpp4
-rw-r--r--src/modules/m_muteban.cpp4
-rw-r--r--src/modules/m_namesx.cpp4
-rw-r--r--src/modules/m_nationalchars.cpp6
-rw-r--r--src/modules/m_noctcp.cpp4
-rw-r--r--src/modules/m_nokicks.cpp4
-rw-r--r--src/modules/m_nonicks.cpp4
-rw-r--r--src/modules/m_nonotice.cpp4
-rw-r--r--src/modules/m_nopartmsg.cpp4
-rw-r--r--src/modules/m_operchans.cpp4
-rw-r--r--src/modules/m_operlog.cpp4
-rw-r--r--src/modules/m_override.cpp4
-rw-r--r--src/modules/m_remove.cpp4
-rw-r--r--src/modules/m_securelist.cpp4
-rw-r--r--src/modules/m_serverban.cpp4
-rw-r--r--src/modules/m_services_account.cpp6
-rw-r--r--src/modules/m_silence.cpp6
-rw-r--r--src/modules/m_spanningtree/main.cpp7
-rw-r--r--src/modules/m_spanningtree/precommand.cpp3
-rw-r--r--src/modules/m_sslmodes.cpp4
-rw-r--r--src/modules/m_stripcolor.cpp4
-rw-r--r--src/modules/m_uhnames.cpp4
-rw-r--r--src/modules/m_userip.cpp4
-rw-r--r--src/modules/m_watch.cpp5
-rw-r--r--src/server.cpp74
-rw-r--r--src/users.cpp2
43 files changed, 151 insertions, 149 deletions
diff --git a/src/commands/cmd_version.cpp b/src/commands/cmd_version.cpp
index 24442d9e1..9fdd9c838 100644
--- a/src/commands/cmd_version.cpp
+++ b/src/commands/cmd_version.cpp
@@ -44,7 +44,11 @@ CmdResult CommandVersion::Handle (const std::vector<std::string>&, User *user)
{
std::string version = ServerInstance->GetVersionString((user->IsOper()));
user->WriteNumeric(RPL_VERSION, "%s :%s", user->nick.c_str(), version.c_str());
- ServerInstance->Config->Send005(user);
+ LocalUser *lu = IS_LOCAL(user);
+ if (lu != NULL)
+ {
+ ServerInstance->ISupport.SendTo(lu);
+ }
return CMD_SUCCESS;
}
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 804463309..2906d66b9 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -49,41 +49,6 @@ ServerConfig::ServerConfig()
c_ipv6_range = 128;
}
-void ServerConfig::Update005()
-{
- std::stringstream out(data005);
- std::vector<std::string> data;
- std::string token;
- while (out >> token)
- data.push_back(token);
- sort(data.begin(), data.end());
-
- std::string line5;
- isupport.clear();
- for(unsigned int i=0; i < data.size(); i++)
- {
- token = data[i];
- line5 = line5 + token + " ";
- if (i % 13 == 12)
- {
- line5.append(":are supported by this server");
- isupport.push_back(line5);
- line5.clear();
- }
- }
- if (!line5.empty())
- {
- line5.append(":are supported by this server");
- isupport.push_back(line5);
- }
-}
-
-void ServerConfig::Send005(User* user)
-{
- for (std::vector<std::string>::iterator line = ServerInstance->Config->isupport.begin(); line != ServerInstance->Config->isupport.end(); line++)
- user->WriteNumeric(RPL_ISUPPORT, "%s %s", user->nick.c_str(), line->c_str());
-}
-
template<typename T, typename V>
static void range(T& value, V min, V max, V def, const char* msg)
{
@@ -932,7 +897,7 @@ void ConfigReaderThread::Finish()
Config->ApplyDisabledCommands(Config->DisabledCommands);
User* user = ServerInstance->FindNick(TheUserUID);
FOREACH_MOD(I_OnRehash, OnRehash(user));
- ServerInstance->BuildISupport();
+ ServerInstance->ISupport.Build();
ServerInstance->Logs->CloseLogs();
ServerInstance->Logs->OpenFileLogs();
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index a673c1b14..ee059e756 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -485,26 +485,6 @@ std::string InspIRCd::TimeString(time_t curtime)
return std::string(ctime(&curtime),24);
}
-// You should only pass a single character to this.
-void InspIRCd::AddExtBanChar(char c)
-{
- std::string &tok = Config->data005;
- std::string::size_type ebpos = tok.find(" EXTBAN=,");
-
- if (ebpos == std::string::npos)
- {
- tok.append(" EXTBAN=,");
- tok.push_back(c);
- }
- else
- {
- ebpos += 9;
- while (isalpha(tok[ebpos]) && tok[ebpos] < c)
- ebpos++;
- tok.insert(ebpos, 1, c);
- }
-}
-
std::string InspIRCd::GenRandomStr(int length, bool printable)
{
char* buf = new char[length];
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index ea30924a8..e02c42a82 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -548,7 +548,7 @@ InspIRCd::InspIRCd(int argc, char** argv) :
this->Modules->LoadAll();
/* Just in case no modules were loaded - fix for bug #101 */
- this->BuildISupport();
+ this->ISupport.Build();
Config->ApplyDisabledCommands(Config->DisabledCommands);
if (!pl.empty())
diff --git a/src/modmanager_dynamic.cpp b/src/modmanager_dynamic.cpp
index dab1143ad..49c91a7d8 100644
--- a/src/modmanager_dynamic.cpp
+++ b/src/modmanager_dynamic.cpp
@@ -126,7 +126,7 @@ bool ModuleManager::Load(const std::string& filename, bool defer)
ServerInstance->Logs->Log("MODULE", DEFAULT, "Hook priority dependency loop detected while loading " + filename);
}
- ServerInstance->BuildISupport();
+ ServerInstance->ISupport.Build();
return true;
}
diff --git a/src/modmanager_static.cpp b/src/modmanager_static.cpp
index 3b7d72baf..a8ba83274 100644
--- a/src/modmanager_static.cpp
+++ b/src/modmanager_static.cpp
@@ -128,7 +128,7 @@ bool ModuleManager::Load(const std::string& name, bool defer)
ServerInstance->Logs->Log("MODULE", DEFAULT, "Hook priority dependency loop detected while loading " + name);
}
- ServerInstance->BuildISupport();
+ ServerInstance->ISupport.Build();
return true;
}
diff --git a/src/modules.cpp b/src/modules.cpp
index 1d91bb006..767322fc9 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -109,7 +109,7 @@ ModResult Module::OnUserPreNotice(User*, void*, int, std::string&, char, CUList&
ModResult Module::OnUserPreNick(User*, const std::string&) { return MOD_RES_PASSTHRU; }
void Module::OnUserPostNick(User*, const std::string&) { }
ModResult Module::OnPreMode(User*, User*, Channel*, const std::vector<std::string>&) { return MOD_RES_PASSTHRU; }
-void Module::On005Numeric(std::string&) { }
+void Module::On005Numeric(std::map<std::string, std::string>&) { }
ModResult Module::OnKill(User*, User*, const std::string&) { return MOD_RES_PASSTHRU; }
void Module::OnLoadModule(Module*) { }
void Module::OnUnloadModule(Module*) { }
@@ -397,7 +397,7 @@ void ModuleManager::DoSafeUnload(Module* mod)
ServerInstance->Logs->Log("MODULE", DEFAULT,"Module %s unloaded",mod->ModuleSourceFile.c_str());
this->ModCount--;
- ServerInstance->BuildISupport();
+ ServerInstance->ISupport.Build();
}
void ModuleManager::UnloadAll()
diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp
index 39602539f..67a0dd24f 100644
--- a/src/modules/extra/m_ssl_gnutls.cpp
+++ b/src/modules/extra/m_ssl_gnutls.cpp
@@ -471,12 +471,12 @@ class ModuleSSLGnuTLS : public Module
return Version("Provides SSL support for clients", VF_VENDOR);
}
- void On005Numeric(std::string &output)
+ void On005Numeric(std::map<std::string, std::string>& tokens)
{
if (!sslports.empty())
- output.append(" SSL=" + sslports);
+ tokens["SSL"] = sslports;
if (starttls.enabled)
- output.append(" STARTTLS");
+ tokens["STARTTLS"];
}
void OnHookIO(StreamSocket* user, ListenSocket* lsb)
diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp
index bf4a9b215..258a6a840 100644
--- a/src/modules/extra/m_ssl_openssl.cpp
+++ b/src/modules/extra/m_ssl_openssl.cpp
@@ -267,10 +267,10 @@ class ModuleSSLOpenSSL : public Module
fclose(dhpfile);
}
- void On005Numeric(std::string &output)
+ void On005Numeric(std::map<std::string, std::string>& tokens)
{
if (!sslports.empty())
- output.append(" SSL=" + sslports);
+ tokens["SSL"] = sslports;
}
~ModuleSSLOpenSSL()
diff --git a/src/modules/m_allowinvite.cpp b/src/modules/m_allowinvite.cpp
index fbfdf9e7c..9cc8261b8 100644
--- a/src/modules/m_allowinvite.cpp
+++ b/src/modules/m_allowinvite.cpp
@@ -43,9 +43,9 @@ class ModuleAllowInvite : public Module
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}
- virtual void On005Numeric(std::string &output)
+ virtual void On005Numeric(std::map<std::string, std::string>& tokens)
{
- ServerInstance->AddExtBanChar('A');
+ tokens["EXTBAN"].push_back('A');
}
virtual ModResult OnUserPreInvite(User* user,User* dest,Channel* channel, time_t timeout)
diff --git a/src/modules/m_banexception.cpp b/src/modules/m_banexception.cpp
index c521c5405..cf4144935 100644
--- a/src/modules/m_banexception.cpp
+++ b/src/modules/m_banexception.cpp
@@ -63,9 +63,9 @@ class ModuleBanException : public Module
ServerInstance->Modules->Attach(list, this, sizeof(list)/sizeof(Implementation));
}
- void On005Numeric(std::string &output)
+ void On005Numeric(std::map<std::string, std::string>& tokens)
{
- output.append(" EXCEPTS=e");
+ tokens["EXCEPTS"] = "e";
}
ModResult OnExtBanCheck(User *user, Channel *chan, char type)
diff --git a/src/modules/m_blockcaps.cpp b/src/modules/m_blockcaps.cpp
index eb48da243..8371dd106 100644
--- a/src/modules/m_blockcaps.cpp
+++ b/src/modules/m_blockcaps.cpp
@@ -53,9 +53,9 @@ public:
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}
- virtual void On005Numeric(std::string &output)
+ virtual void On005Numeric(std::map<std::string, std::string>& tokens)
{
- ServerInstance->AddExtBanChar('B');
+ tokens["EXTBAN"].push_back('B');
}
virtual void OnRehash(User* user)
diff --git a/src/modules/m_blockcolor.cpp b/src/modules/m_blockcolor.cpp
index 6a0d486fd..d843fc9b0 100644
--- a/src/modules/m_blockcolor.cpp
+++ b/src/modules/m_blockcolor.cpp
@@ -49,9 +49,9 @@ class ModuleBlockColor : public Module
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}
- virtual void On005Numeric(std::string &output)
+ virtual void On005Numeric(std::map<std::string, std::string>& tokens)
{
- ServerInstance->AddExtBanChar('c');
+ tokens["EXTBAN"].push_back('c');
}
virtual ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp
index ee7b5e71a..e8448bc91 100644
--- a/src/modules/m_callerid.cpp
+++ b/src/modules/m_callerid.cpp
@@ -347,9 +347,9 @@ public:
return Version("Implementation of callerid, usermode +g, /accept", VF_COMMON | VF_VENDOR);
}
- virtual void On005Numeric(std::string& output)
+ virtual void On005Numeric(std::map<std::string, std::string>& tokens)
{
- output += " CALLERID=g";
+ tokens["CALLERID"] = "g";
}
ModResult PreText(User* user, User* dest, std::string& text)
diff --git a/src/modules/m_channelban.cpp b/src/modules/m_channelban.cpp
index 034a06e29..51a8105ab 100644
--- a/src/modules/m_channelban.cpp
+++ b/src/modules/m_channelban.cpp
@@ -66,9 +66,9 @@ class ModuleBadChannelExtban : public Module
return MOD_RES_PASSTHRU;
}
- void On005Numeric(std::string &output)
+ void On005Numeric(std::map<std::string, std::string>& tokens)
{
- ServerInstance->AddExtBanChar('j');
+ tokens["EXTBAN"].push_back('j');
}
};
diff --git a/src/modules/m_gecosban.cpp b/src/modules/m_gecosban.cpp
index 4b1fb59e0..b33362a8d 100644
--- a/src/modules/m_gecosban.cpp
+++ b/src/modules/m_gecosban.cpp
@@ -45,9 +45,9 @@ class ModuleGecosBan : public Module
return MOD_RES_PASSTHRU;
}
- void On005Numeric(std::string &output)
+ void On005Numeric(std::map<std::string, std::string>& tokens)
{
- ServerInstance->AddExtBanChar('r');
+ tokens["EXTBAN"].push_back('r');
}
};
diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp
index 3af9ee754..691fa8163 100644
--- a/src/modules/m_httpd_stats.cpp
+++ b/src/modules/m_httpd_stats.cpp
@@ -119,7 +119,13 @@ class ModuleHttpStats : public Module
stime = gmtime(&server_uptime);
data << "<uptime><days>" << stime->tm_yday << "</days><hours>" << stime->tm_hour << "</hours><mins>" << stime->tm_min << "</mins><secs>" << stime->tm_sec << "</secs><boot_time_t>" << ServerInstance->startup_time << "</boot_time_t></uptime>";
- data << "<isupport>" << Sanitize(ServerInstance->Config->data005) << "</isupport></general><xlines>";
+ data << "<isupport>";
+ const std::vector<std::string>& isupport = ServerInstance->ISupport.GetLines();
+ for (std::vector<std::string>::const_iterator it = isupport.begin(); it != isupport.end(); it++)
+ {
+ data << Sanitize(*it) << std::endl;
+ }
+ data << "</isupport></general><xlines>";
std::vector<std::string> xltypes = ServerInstance->XLines->GetAllTypes();
for (std::vector<std::string>::iterator it = xltypes.begin(); it != xltypes.end(); ++it)
{
diff --git a/src/modules/m_inviteexception.cpp b/src/modules/m_inviteexception.cpp
index aa5da086b..2d8382832 100644
--- a/src/modules/m_inviteexception.cpp
+++ b/src/modules/m_inviteexception.cpp
@@ -64,9 +64,9 @@ public:
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}
- void On005Numeric(std::string &output)
+ void On005Numeric(std::map<std::string, std::string>& tokens)
{
- output.append(" INVEX=I");
+ tokens["INVEX"] = "I";
}
ModResult OnCheckInvite(User* user, Channel* chan)
diff --git a/src/modules/m_muteban.cpp b/src/modules/m_muteban.cpp
index 2b6bedc1c..2c8a123f1 100644
--- a/src/modules/m_muteban.cpp
+++ b/src/modules/m_muteban.cpp
@@ -56,9 +56,9 @@ class ModuleQuietBan : public Module
return OnUserPreMessage(user, dest, target_type, text, status, exempt_list);
}
- virtual void On005Numeric(std::string &output)
+ virtual void On005Numeric(std::map<std::string, std::string>& tokens)
{
- ServerInstance->AddExtBanChar('m');
+ tokens["EXTBAN"].push_back('m');
}
};
diff --git a/src/modules/m_namesx.cpp b/src/modules/m_namesx.cpp
index b9d05024e..4ba8613d8 100644
--- a/src/modules/m_namesx.cpp
+++ b/src/modules/m_namesx.cpp
@@ -44,9 +44,9 @@ class ModuleNamesX : public Module
return Version("Provides the NAMESX (CAP multi-prefix) capability.",VF_VENDOR);
}
- void On005Numeric(std::string &output)
+ void On005Numeric(std::map<std::string, std::string>& tokens)
{
- output.append(" NAMESX");
+ tokens["NAMESX"];
}
ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, LocalUser *user, bool validated, const std::string &original_line)
diff --git a/src/modules/m_nationalchars.cpp b/src/modules/m_nationalchars.cpp
index cf60194d1..b59d278db 100644
--- a/src/modules/m_nationalchars.cpp
+++ b/src/modules/m_nationalchars.cpp
@@ -247,11 +247,9 @@ class ModuleNationalChars : public Module
OnRehash(NULL);
}
- virtual void On005Numeric(std::string &output)
+ virtual void On005Numeric(std::map<std::string, std::string>& tokens)
{
- std::string tmp(casemapping);
- tmp.insert(0, "CASEMAPPING=");
- SearchAndReplace(output, std::string("CASEMAPPING=rfc1459"), tmp);
+ tokens["CASEMAPPING"] = casemapping;
}
virtual void OnRehash(User* user)
diff --git a/src/modules/m_noctcp.cpp b/src/modules/m_noctcp.cpp
index 2a684e3a8..fb6e61c6e 100644
--- a/src/modules/m_noctcp.cpp
+++ b/src/modules/m_noctcp.cpp
@@ -77,9 +77,9 @@ class ModuleNoCTCP : public Module
return MOD_RES_PASSTHRU;
}
- virtual void On005Numeric(std::string &output)
+ virtual void On005Numeric(std::map<std::string, std::string>& tokens)
{
- ServerInstance->AddExtBanChar('C');
+ tokens["EXTBAN"].push_back('C');
}
};
diff --git a/src/modules/m_nokicks.cpp b/src/modules/m_nokicks.cpp
index 22f5664ed..1be389bf7 100644
--- a/src/modules/m_nokicks.cpp
+++ b/src/modules/m_nokicks.cpp
@@ -47,9 +47,9 @@ class ModuleNoKicks : public Module
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}
- void On005Numeric(std::string &output)
+ void On005Numeric(std::map<std::string, std::string>& tokens)
{
- ServerInstance->AddExtBanChar('Q');
+ tokens["EXTBAN"].push_back('Q');
}
ModResult OnUserPreKick(User* source, Membership* memb, const std::string &reason)
diff --git a/src/modules/m_nonicks.cpp b/src/modules/m_nonicks.cpp
index c1eb63da9..c1c1dd136 100644
--- a/src/modules/m_nonicks.cpp
+++ b/src/modules/m_nonicks.cpp
@@ -51,9 +51,9 @@ class ModuleNoNickChange : public Module
return Version("Provides support for channel mode +N & extban +b N: which prevents nick changes on channel", VF_VENDOR);
}
- virtual void On005Numeric(std::string &output)
+ virtual void On005Numeric(std::map<std::string, std::string>& tokens)
{
- ServerInstance->AddExtBanChar('N');
+ tokens["EXTBAN"].push_back('N');
}
virtual ModResult OnUserPreNick(User* user, const std::string &newnick)
diff --git a/src/modules/m_nonotice.cpp b/src/modules/m_nonotice.cpp
index 9216531bb..89e6be3b7 100644
--- a/src/modules/m_nonotice.cpp
+++ b/src/modules/m_nonotice.cpp
@@ -46,9 +46,9 @@ class ModuleNoNotice : public Module
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}
- virtual void On005Numeric(std::string &output)
+ virtual void On005Numeric(std::map<std::string, std::string>& tokens)
{
- ServerInstance->AddExtBanChar('T');
+ tokens["EXTBAN"].push_back('T');
}
virtual ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
diff --git a/src/modules/m_nopartmsg.cpp b/src/modules/m_nopartmsg.cpp
index 0daf48c10..be01fa6c0 100644
--- a/src/modules/m_nopartmsg.cpp
+++ b/src/modules/m_nopartmsg.cpp
@@ -44,9 +44,9 @@ class ModulePartMsgBan : public Module
partmessage.clear();
}
- virtual void On005Numeric(std::string &output)
+ virtual void On005Numeric(std::map<std::string, std::string>& tokens)
{
- ServerInstance->AddExtBanChar('p');
+ tokens["EXTBAN"].push_back('p');
}
};
diff --git a/src/modules/m_operchans.cpp b/src/modules/m_operchans.cpp
index 2ac98e90c..e986b632a 100644
--- a/src/modules/m_operchans.cpp
+++ b/src/modules/m_operchans.cpp
@@ -70,9 +70,9 @@ class ModuleOperChans : public Module
return MOD_RES_PASSTHRU;
}
- void On005Numeric(std::string &output)
+ void On005Numeric(std::map<std::string, std::string>& tokens)
{
- ServerInstance->AddExtBanChar('O');
+ tokens["EXTBAN"].push_back('O');
}
Version GetVersion()
diff --git a/src/modules/m_operlog.cpp b/src/modules/m_operlog.cpp
index 4c67ea32b..03984618b 100644
--- a/src/modules/m_operlog.cpp
+++ b/src/modules/m_operlog.cpp
@@ -70,9 +70,9 @@ class ModuleOperLog : public Module
return MOD_RES_PASSTHRU;
}
- virtual void On005Numeric(std::string &output)
+ virtual void On005Numeric(std::map<std::string, std::string>& tokens)
{
- output.append(" OPERLOG");
+ tokens["OPERLOG"];
}
};
diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp
index 81f4230eb..ea9d11c94 100644
--- a/src/modules/m_override.cpp
+++ b/src/modules/m_override.cpp
@@ -52,9 +52,9 @@ class ModuleOverride : public Module
RequireKey = tag->getBool("requirekey");
}
- void On005Numeric(std::string &output)
+ void On005Numeric(std::map<std::string, std::string>& tokens)
{
- output.append(" OVERRIDE");
+ tokens["OVERRIDE"];
}
bool CanOverride(User* source, const char* token)
diff --git a/src/modules/m_remove.cpp b/src/modules/m_remove.cpp
index d95c0c6c6..6f7c1c369 100644
--- a/src/modules/m_remove.cpp
+++ b/src/modules/m_remove.cpp
@@ -211,9 +211,9 @@ class ModuleRemove : public Module
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}
- virtual void On005Numeric(std::string &output)
+ virtual void On005Numeric(std::map<std::string, std::string>& tokens)
{
- output.append(" REMOVE");
+ tokens["REMOVE"];
}
virtual void OnRehash(User* user)
diff --git a/src/modules/m_securelist.cpp b/src/modules/m_securelist.cpp
index fb841d81b..382968355 100644
--- a/src/modules/m_securelist.cpp
+++ b/src/modules/m_securelist.cpp
@@ -82,9 +82,9 @@ class ModuleSecureList : public Module
return MOD_RES_PASSTHRU;
}
- virtual void On005Numeric(std::string &output)
+ virtual void On005Numeric(std::map<std::string, std::string>& tokens)
{
- output.append(" SECURELIST");
+ tokens["SECURELIST"];
}
};
diff --git a/src/modules/m_serverban.cpp b/src/modules/m_serverban.cpp
index cd9db395a..7ed663b20 100644
--- a/src/modules/m_serverban.cpp
+++ b/src/modules/m_serverban.cpp
@@ -45,9 +45,9 @@ class ModuleServerBan : public Module
return MOD_RES_PASSTHRU;
}
- void On005Numeric(std::string &output)
+ void On005Numeric(std::map<std::string, std::string>& tokens)
{
- ServerInstance->AddExtBanChar('s');
+ tokens["EXTBAN"].push_back('s');
}
};
diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp
index 62e96ca7c..fbf099924 100644
--- a/src/modules/m_services_account.cpp
+++ b/src/modules/m_services_account.cpp
@@ -128,10 +128,10 @@ class ModuleServicesAccount : public Module
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}
- void On005Numeric(std::string &t)
+ void On005Numeric(std::map<std::string, std::string>& tokens)
{
- ServerInstance->AddExtBanChar('R');
- ServerInstance->AddExtBanChar('U');
+ tokens["EXTBAN"].push_back('R');
+ tokens["EXTBAN"].push_back('U');
}
/* <- :twisted.oscnet.org 330 w00t2 w00t2 w00t :is logged in as */
diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp
index 55403a9b0..d1885269d 100644
--- a/src/modules/m_silence.cpp
+++ b/src/modules/m_silence.cpp
@@ -320,10 +320,10 @@ class ModuleSilence : public Module
maxsilence = 32;
}
- void On005Numeric(std::string &output)
+ void On005Numeric(std::map<std::string, std::string>& tokens)
{
- // we don't really have a limit...
- output = output + " ESILENCE SILENCE=" + ConvToStr(maxsilence);
+ tokens["ESILENCE"];
+ tokens["SILENCE"] = ConvToStr(maxsilence);
}
void OnBuildExemptList(MessageType message_type, Channel* chan, User* sender, char status, CUList &exempt_list, const std::string &text)
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index 97a57cc73..efd899c44 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -360,12 +360,13 @@ ModResult ModuleSpanningTree::HandleVersion(const std::vector<std::string>& para
TreeServer* found = Utils->FindServerMask(parameters[0]);
if (found)
{
- std::string Version = found->GetVersion();
- user->WriteNumeric(351, "%s :%s",user->nick.c_str(),Version.c_str());
if (found == Utils->TreeRoot)
{
- ServerInstance->Config->Send005(user);
+ // Pass to default VERSION handler.
+ return MOD_RES_PASSTHRU;
}
+ std::string Version = found->GetVersion();
+ user->WriteNumeric(351, "%s :%s",user->nick.c_str(),Version.c_str());
}
else
{
diff --git a/src/modules/m_spanningtree/precommand.cpp b/src/modules/m_spanningtree/precommand.cpp
index b331571ca..089f64cb0 100644
--- a/src/modules/m_spanningtree/precommand.cpp
+++ b/src/modules/m_spanningtree/precommand.cpp
@@ -64,8 +64,7 @@ ModResult ModuleSpanningTree::OnPreCommand(std::string &command, std::vector<std
}
else if ((command == "VERSION") && (parameters.size() > 0))
{
- this->HandleVersion(parameters,user);
- return MOD_RES_DENY;
+ return this->HandleVersion(parameters,user);
}
return MOD_RES_PASSTHRU;
}
diff --git a/src/modules/m_sslmodes.cpp b/src/modules/m_sslmodes.cpp
index be215924b..fbd77c249 100644
--- a/src/modules/m_sslmodes.cpp
+++ b/src/modules/m_sslmodes.cpp
@@ -126,9 +126,9 @@ class ModuleSSLModes : public Module
return MOD_RES_PASSTHRU;
}
- void On005Numeric(std::string &output)
+ void On005Numeric(std::map<std::string, std::string>& tokens)
{
- ServerInstance->AddExtBanChar('z');
+ tokens["EXTBAN"].push_back('z');
}
Version GetVersion()
diff --git a/src/modules/m_stripcolor.cpp b/src/modules/m_stripcolor.cpp
index de7b754c5..d63750a57 100644
--- a/src/modules/m_stripcolor.cpp
+++ b/src/modules/m_stripcolor.cpp
@@ -58,9 +58,9 @@ class ModuleStripColor : public Module
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}
- virtual void On005Numeric(std::string &output)
+ virtual void On005Numeric(std::map<std::string, std::string>& tokens)
{
- ServerInstance->AddExtBanChar('S');
+ tokens["EXTBAN"].push_back('S');
}
virtual ModResult OnUserPreMessage(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list)
diff --git a/src/modules/m_uhnames.cpp b/src/modules/m_uhnames.cpp
index 67ed560ca..1b0c91c94 100644
--- a/src/modules/m_uhnames.cpp
+++ b/src/modules/m_uhnames.cpp
@@ -44,9 +44,9 @@ class ModuleUHNames : public Module
return Version("Provides the UHNAMES facility.",VF_VENDOR);
}
- void On005Numeric(std::string &output)
+ void On005Numeric(std::map<std::string, std::string>& tokens)
{
- output.append(" UHNAMES");
+ tokens["UHNAMES"];
}
ModResult OnPreCommand(std::string &command, std::vector<std::string> &parameters, LocalUser *user, bool validated, const std::string &original_line)
diff --git a/src/modules/m_userip.cpp b/src/modules/m_userip.cpp
index 0a91a1b6e..fdceda063 100644
--- a/src/modules/m_userip.cpp
+++ b/src/modules/m_userip.cpp
@@ -77,9 +77,9 @@ class ModuleUserIP : public Module
ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
}
- virtual void On005Numeric(std::string &output)
+ virtual void On005Numeric(std::map<std::string, std::string>& tokens)
{
- output = output + " USERIP";
+ tokens["USERIP"];
}
virtual Version GetVersion()
diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp
index 615cdf191..60ea79a83 100644
--- a/src/modules/m_watch.cpp
+++ b/src/modules/m_watch.cpp
@@ -527,10 +527,9 @@ class Modulewatch : public Module
}
}
- virtual void On005Numeric(std::string &output)
+ virtual void On005Numeric(std::map<std::string, std::string>& tokens)
{
- // we don't really have a limit...
- output = output + " WATCH=" + ConvToStr(maxwatch);
+ tokens["WATCH"] = ConvToStr(maxwatch);
}
virtual ~Modulewatch()
diff --git a/src/server.cpp b/src/server.cpp
index 6a4603440..0536d36a8 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -83,18 +83,6 @@ const char InspIRCd::LogHeader[] =
"Log started for " VERSION " (" REVISION ", " MODULE_INIT_STR ")"
" - compiled on " SYSTEM;
-void InspIRCd::BuildISupport()
-{
- // the neatest way to construct the initial 005 numeric, considering the number of configure constants to go in it...
- std::stringstream v;
- v << "WALLCHOPS WALLVOICES MODES=" << Config->Limits.MaxModes << " CHANTYPES=# PREFIX=" << this->Modes->BuildPrefixes() << " MAP MAXCHANNELS=" << Config->MaxChans << " MAXBANS=60 VBANLIST NICKLEN=" << Config->Limits.NickMax;
- v << " CASEMAPPING=rfc1459 STATUSMSG=" << Modes->BuildPrefixes(false) << " CHARSET=ascii TOPICLEN=" << Config->Limits.MaxTopic << " KICKLEN=" << Config->Limits.MaxKick << " MAXTARGETS=" << Config->MaxTargets;
- v << " AWAYLEN=" << Config->Limits.MaxAway << " CHANMODES=" << this->Modes->GiveModeList(MASK_CHANNEL) << " FNC NETWORK=" << Config->Network << " MAXPARA=32 ELIST=MU" << " CHANNELLEN=" << Config->Limits.ChanMax;
- Config->data005 = v.str();
- FOREACH_MOD(I_On005Numeric,On005Numeric(Config->data005));
- Config->Update005();
-}
-
void InspIRCd::IncrementUID(int pos)
{
/*
@@ -184,5 +172,67 @@ std::string InspIRCd::GetUID()
return "";
}
+void ISupportManager::Build()
+{
+ /**
+ * This is currently the neatest way we can build the initial ISUPPORT map. In
+ * the future we can use an initializer list here.
+ */
+ std::map<std::string, std::string> tokens;
+ std::vector<std::string> lines;
+ int token_count = 0;
+ std::string line;
+
+ tokens["AWAYLEN"] = ConvToStr(ServerInstance->Config->Limits.MaxAway);
+ tokens["CASEMAPPING"] = "rfc1459";
+ tokens["CHANMODES"] = ConvToStr(ServerInstance->Modes->GiveModeList(MASK_CHANNEL));
+ tokens["CHANNELLEN"] = ConvToStr(ServerInstance->Config->Limits.ChanMax);
+ tokens["CHANTYPES"] = "#";
+ tokens["CHARSET"] = "ascii";
+ tokens["ELIST"] = "MU";
+ tokens["KICKLEN"] = ConvToStr(ServerInstance->Config->Limits.MaxKick);
+ tokens["MAXBANS"] = "64"; // TODO: make this a config setting.
+ tokens["MAXCHANNELS"] = ConvToStr(ServerInstance->Config->MaxChans);
+ tokens["MAXPARA"] = ConvToStr(MAXPARAMETERS);
+ tokens["MAXTARGETS"] = ConvToStr(ServerInstance->Config->MaxTargets);
+ tokens["MODES"] = ConvToStr(ServerInstance->Config->Limits.MaxModes);
+ tokens["NETWORK"] = ConvToStr(ServerInstance->Config->Network);
+ tokens["NICKLEN"] = ConvToStr(ServerInstance->Config->Limits.NickMax);
+ tokens["PREFIX"] = ServerInstance->Modes->BuildPrefixes();
+ tokens["STATUSMSG"] = ServerInstance->Modes->BuildPrefixes(false);
+ tokens["TOPICLEN"] = ConvToStr(ServerInstance->Config->Limits.MaxTopic);
+
+ tokens["FNC"] = tokens["MAP"] = tokens["VBANLIST"] =
+ tokens["WALLCHOPS"] = tokens["WALLVOICES"];
+
+ FOREACH_MOD(I_On005Numeric, On005Numeric(tokens));
+
+ // EXTBAN is a special case as we need to sort it and prepend a comma.
+ std::map<std::string, std::string>::iterator extban = tokens.find("EXTBAN");
+ if (extban != tokens.end())
+ {
+ sort(extban->second.begin(), extban->second.end());
+ extban->second.insert(0, ",");
+ }
+
+ for (std::map<std::string, std::string>::iterator it = tokens.begin(); it != tokens.end(); it++)
+ {
+ line.append(it->first + (it->second.empty() ? " " : "=" + it->second + " "));
+ token_count++;
+
+ if (token_count % 13 == 12 || it == --tokens.end())
+ {
+ line.append(":are supported by this server");
+ lines.push_back(line);
+ line.clear();
+ }
+ }
+ this->Lines = lines;
+}
+void ISupportManager::SendTo(LocalUser* user)
+{
+ for (std::vector<std::string>::iterator line = this->Lines.begin(); line != this->Lines.end(); line++)
+ user->WriteNumeric(RPL_ISUPPORT, "%s %s", user->nick.c_str(), line->c_str());
+}
diff --git a/src/users.cpp b/src/users.cpp
index 9419325da..cd3dcb8a6 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -771,7 +771,7 @@ void LocalUser::FullConnect()
std::string pmlist = ServerInstance->Modes->ParaModeList();
this->WriteNumeric(RPL_SERVERVERSION, "%s %s %s %s %s %s", this->nick.c_str(), ServerInstance->Config->ServerName.c_str(), BRANCH, umlist.c_str(), cmlist.c_str(), pmlist.c_str());
- ServerInstance->Config->Send005(this);
+ ServerInstance->ISupport.SendTo(this);
this->WriteNumeric(RPL_YOURUUID, "%s %s :your unique ID", this->nick.c_str(), this->uuid.c_str());
/* Now registered */