X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fserver.cpp;h=0536d36a8abb8ca3a177aeae319836d30dabb7d7;hb=551d687ec6d7ce44be35fae0dd7345fe73c4f63a;hp=691ab3842f7d1c455d06577fcb90d9b40cbfcff2;hpb=bb3aa2fb37071f48a5312df8688c0a6990644fbb;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/server.cpp b/src/server.cpp index 691ab3842..0536d36a8 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -23,7 +23,6 @@ #include #include "exitcodes.h" #include "inspircd.h" -#include "inspircd_version.h" void InspIRCd::SignalHandler(int signal) { @@ -84,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) { /* @@ -185,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 tokens; + std::vector 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::iterator extban = tokens.find("EXTBAN"); + if (extban != tokens.end()) + { + sort(extban->second.begin(), extban->second.end()); + extban->second.insert(0, ","); + } + + for (std::map::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::iterator line = this->Lines.begin(); line != this->Lines.end(); line++) + user->WriteNumeric(RPL_ISUPPORT, "%s %s", user->nick.c_str(), line->c_str()); +}