summaryrefslogtreecommitdiff
path: root/src/server.cpp
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2013-04-07 22:23:25 +0100
committerPeter Powell <petpow@saberuk.com>2013-04-11 23:08:03 +0100
commit5c29c53f651fb0c513a50c9396e08ba340a6d2bf (patch)
treec00ab92b6ff6d002e6c40909587b146ba5e45612 /src/server.cpp
parent295b3e7ba15a228948358bd6f23591a9cb5bf5a8 (diff)
Convert ISUPPORT to use a map instead of a string.
Diffstat (limited to 'src/server.cpp')
-rw-r--r--src/server.cpp74
1 files changed, 62 insertions, 12 deletions
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());
+}