diff options
| author | 2020-06-21 04:25:45 +0100 | |
|---|---|---|
| committer | 2021-05-08 15:31:50 +0100 | |
| commit | 0c750c060839f9018ca129bd7456184792ea0dc0 (patch) | |
| tree | 43aa8d0a593afa292e2922d2481b2349e0dc8dfd /src | |
| parent | Merge branch 'insp3' into master. (diff) | |
| download | inspircd++-0c750c060839f9018ca129bd7456184792ea0dc0.tar.gz inspircd++-0c750c060839f9018ca129bd7456184792ea0dc0.tar.bz2 inspircd++-0c750c060839f9018ca129bd7456184792ea0dc0.zip | |
Move channel logic from InspIRCd to the new ChannelManager class.
Diffstat (limited to 'src')
59 files changed, 139 insertions, 124 deletions
diff --git a/src/channelmanager.cpp b/src/channelmanager.cpp new file mode 100644 index 000000000..f8bd9ddb4 --- /dev/null +++ b/src/channelmanager.cpp @@ -0,0 +1,52 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * Copyright (C) 2020 Sadie Powell <sadie@witchery.services> + * + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "inspircd.h" + +bool ChannelManager::DefaultIsChannel(const std::string& channel) +{ + if (channel.empty() || channel.length() > ServerInstance->Config->Limits.MaxChannel) + return false; + + if (channel[0] != '#') + return false; + + for (const auto& chr : insp::iterator_range(channel.begin() + 1, channel.end())) + { + switch (chr) + { + case 0x07: // BELL + case 0x20: // SPACE + case 0x2C: // COMMA + return false; + } + } + + return true; +} + +Channel* ChannelManager::Find(const std::string& channel) +{ + ChannelMap::iterator iter = channels.find(channel); + if (iter == channels.end()) + return nullptr; + + return iter->second; +} + diff --git a/src/channels.cpp b/src/channels.cpp index 12c9aeeff..6b885735c 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -37,7 +37,7 @@ Channel::Channel(const std::string &cname, time_t ts) : name(cname) , age(ts) { - if (!ServerInstance->chanlist.emplace(cname, this).second) + if (!ServerInstance->Channels.GetChans().emplace(cname, this).second) throw CoreException("Cannot create duplicate channel " + cname); } @@ -94,12 +94,12 @@ void Channel::CheckDestroy() return; // If the channel isn't in chanlist then it is already in the cull list, don't add it again - chan_hash::iterator iter = ServerInstance->chanlist.find(this->name); - if ((iter == ServerInstance->chanlist.end()) || (iter->second != this)) + ChannelMap::iterator iter = ServerInstance->Channels.GetChans().find(this->name); + if ((iter == ServerInstance->Channels.GetChans().end()) || (iter->second != this)) return; FOREACH_MOD(OnChannelDelete, (this)); - ServerInstance->chanlist.erase(iter); + ServerInstance->Channels.GetChans().erase(iter); ServerInstance->GlobalCulls.AddItem(this); } @@ -197,7 +197,7 @@ Channel* Channel::JoinUser(LocalUser* user, std::string cname, bool override, co if (cname.length() > ServerInstance->Config->Limits.MaxChannel) cname.resize(ServerInstance->Config->Limits.MaxChannel); - Channel* chan = ServerInstance->FindChan(cname); + Channel* chan = ServerInstance->Channels.Find(cname); bool created_by_local = (chan == NULL); // Flag that will be passed to modules in the OnUserJoin() hook later std::string privs; // Prefix mode(letter)s to give to the joining user diff --git a/src/coremods/core_channel/cmd_invite.cpp b/src/coremods/core_channel/cmd_invite.cpp index 1af7a2818..fc650ead5 100644 --- a/src/coremods/core_channel/cmd_invite.cpp +++ b/src/coremods/core_channel/cmd_invite.cpp @@ -60,7 +60,7 @@ CmdResult CommandInvite::Handle(User* user, const Params& parameters) else u = ServerInstance->Users.Find(parameters[0]); - Channel* c = ServerInstance->FindChan(parameters[1]); + Channel* c = ServerInstance->Channels.Find(parameters[1]); time_t timeout = 0; if (parameters.size() >= 3) { diff --git a/src/coremods/core_channel/cmd_join.cpp b/src/coremods/core_channel/cmd_join.cpp index b2e542a14..52dfdaf8c 100644 --- a/src/coremods/core_channel/cmd_join.cpp +++ b/src/coremods/core_channel/cmd_join.cpp @@ -42,7 +42,7 @@ CmdResult CommandJoin::HandleLocal(LocalUser* user, const Params& parameters) if (CommandParser::LoopCall(user, this, parameters, 0, 1, false)) return CmdResult::SUCCESS; - if (ServerInstance->IsChannel(parameters[0])) + if (ServerInstance->Channels.IsChannel(parameters[0])) { Channel::JoinUser(user, parameters[0], false, parameters[1]); return CmdResult::SUCCESS; @@ -53,7 +53,7 @@ CmdResult CommandJoin::HandleLocal(LocalUser* user, const Params& parameters) if (CommandParser::LoopCall(user, this, parameters, 0, -1, false)) return CmdResult::SUCCESS; - if (ServerInstance->IsChannel(parameters[0])) + if (ServerInstance->Channels.IsChannel(parameters[0])) { Channel::JoinUser(user, parameters[0]); return CmdResult::SUCCESS; diff --git a/src/coremods/core_channel/cmd_kick.cpp b/src/coremods/core_channel/cmd_kick.cpp index 4139887df..f9413b752 100644 --- a/src/coremods/core_channel/cmd_kick.cpp +++ b/src/coremods/core_channel/cmd_kick.cpp @@ -39,7 +39,7 @@ CommandKick::CommandKick(Module* parent) */ CmdResult CommandKick::Handle(User* user, const Params& parameters) { - Channel* c = ServerInstance->FindChan(parameters[0]); + Channel* c = ServerInstance->Channels.Find(parameters[0]); User* u; if (CommandParser::LoopCall(user, this, parameters, 1)) diff --git a/src/coremods/core_channel/cmd_names.cpp b/src/coremods/core_channel/cmd_names.cpp index dddc8b50e..193931fb3 100644 --- a/src/coremods/core_channel/cmd_names.cpp +++ b/src/coremods/core_channel/cmd_names.cpp @@ -55,7 +55,7 @@ CmdResult CommandNames::HandleLocal(LocalUser* user, const Params& parameters) if (CommandParser::LoopCall(user, this, parameters, 0)) return CmdResult::SUCCESS; - c = ServerInstance->FindChan(parameters[0]); + c = ServerInstance->Channels.Find(parameters[0]); if (c) { // Show the NAMES list if one of the following is true: diff --git a/src/coremods/core_channel/cmd_topic.cpp b/src/coremods/core_channel/cmd_topic.cpp index 67f951f6c..6d1017eb7 100644 --- a/src/coremods/core_channel/cmd_topic.cpp +++ b/src/coremods/core_channel/cmd_topic.cpp @@ -40,7 +40,7 @@ CommandTopic::CommandTopic(Module* parent) CmdResult CommandTopic::HandleLocal(LocalUser* user, const Params& parameters) { - Channel* c = ServerInstance->FindChan(parameters[0]); + Channel* c = ServerInstance->Channels.Find(parameters[0]); if (!c) { user->WriteNumeric(Numerics::NoSuchChannel(parameters[0])); diff --git a/src/coremods/core_channel/invite.cpp b/src/coremods/core_channel/invite.cpp index ff6c51e38..626756345 100644 --- a/src/coremods/core_channel/invite.cpp +++ b/src/coremods/core_channel/invite.cpp @@ -163,7 +163,7 @@ void Invite::APIImpl::Unserialize(LocalUser* user, const std::string& value) irc::spacesepstream ss(value); for (std::string channame, exptime; (ss.GetToken(channame) && ss.GetToken(exptime)); ) { - Channel* chan = ServerInstance->FindChan(channame); + Channel* chan = ServerInstance->Channels.Find(channame); if (chan) Create(user, chan, ConvToNum<time_t>(exptime)); } diff --git a/src/coremods/core_list.cpp b/src/coremods/core_list.cpp index 70c698122..2f6b48375 100644 --- a/src/coremods/core_list.cpp +++ b/src/coremods/core_list.cpp @@ -142,7 +142,7 @@ CmdResult CommandList::Handle(User* user, const Params& parameters) user->WriteNumeric(RPL_LISTSTART, "Channel", "Users Name"); - for (const auto& [_, chan] : ServerInstance->GetChans()) + for (const auto& [_, chan] : ServerInstance->Channels.GetChans()) { // Check the user count if a search has been specified. const size_t users = chan->GetUserCounter(); diff --git a/src/coremods/core_lusers.cpp b/src/coremods/core_lusers.cpp index 8b33fef8e..c882da9ad 100644 --- a/src/coremods/core_lusers.cpp +++ b/src/coremods/core_lusers.cpp @@ -105,11 +105,10 @@ CmdResult CommandLusers::Handle(User* user, const Params& parameters) if (ServerInstance->Users.UnregisteredUserCount()) user->WriteNumeric(RPL_LUSERUNKNOWN, ServerInstance->Users.UnregisteredUserCount(), "unknown connections"); - user->WriteNumeric(RPL_LUSERCHANNELS, ServerInstance->GetChans().size(), "channels formed"); + user->WriteNumeric(RPL_LUSERCHANNELS, ServerInstance->Channels.GetChans().size(), "channels formed"); user->WriteNumeric(RPL_LUSERME, InspIRCd::Format("I have %zu clients and %zu servers", ServerInstance->Users.LocalUserCount(), n_local_servs)); user->WriteNumeric(RPL_LOCALUSERS, InspIRCd::Format("Current local users: %zu Max: %zu", ServerInstance->Users.LocalUserCount(), counters.max_local)); user->WriteNumeric(RPL_GLOBALUSERS, InspIRCd::Format("Current global users: %zu Max: %zu", n_users, counters.max_global)); - return CmdResult::SUCCESS; } diff --git a/src/coremods/core_message.cpp b/src/coremods/core_message.cpp index 8fe438906..1b18a231b 100644 --- a/src/coremods/core_message.cpp +++ b/src/coremods/core_message.cpp @@ -139,7 +139,7 @@ class CommandMessage : public Command CmdResult HandleChannelTarget(User* source, const Params& parameters, const char* target, PrefixMode* pm) { - Channel* chan = ServerInstance->FindChan(target); + Channel* chan = ServerInstance->Channels.Find(target); if (!chan) { // The target channel does not exist. diff --git a/src/coremods/core_mode.cpp b/src/coremods/core_mode.cpp index 299657b76..dee6be6bb 100644 --- a/src/coremods/core_mode.cpp +++ b/src/coremods/core_mode.cpp @@ -85,7 +85,7 @@ CommandMode::CommandMode(Module* parent) CmdResult CommandMode::Handle(User* user, const Params& parameters) { const std::string& target = parameters[0]; - Channel* targetchannel = ServerInstance->FindChan(target); + Channel* targetchannel = ServerInstance->Channels.Find(target); User* targetuser = NULL; if (!targetchannel) { diff --git a/src/coremods/core_reloadmodule.cpp b/src/coremods/core_reloadmodule.cpp index e9bea238c..dfb55ad37 100644 --- a/src/coremods/core_reloadmodule.cpp +++ b/src/coremods/core_reloadmodule.cpp @@ -401,7 +401,7 @@ void DataKeeper::DoSaveChans() ModesExts currdata; std::vector<OwnedModesExts> currmemberdata; - for (const auto& [_, chan] : ServerInstance->GetChans()) + for (const auto& [_, chan] : ServerInstance->Channels.GetChans()) { // Serialize channel modes for (size_t j = 0; j < handledmodes[MODETYPE_CHANNEL].size(); j++) @@ -641,7 +641,7 @@ void DataKeeper::DoRestoreChans() for (const auto& chandata : chandatalist) { - Channel* const chan = ServerInstance->FindChan(chandata.owner); + Channel* const chan = ServerInstance->Channels.Find(chandata.owner); if (!chan) { ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Channel %s not found", chandata.owner.c_str()); diff --git a/src/coremods/core_stats.cpp b/src/coremods/core_stats.cpp index 32da10f9e..e624dbb35 100644 --- a/src/coremods/core_stats.cpp +++ b/src/coremods/core_stats.cpp @@ -240,7 +240,7 @@ void CommandStats::DoStats(Stats::Context& stats) case 'z': { stats.AddRow(249, "Users: "+ConvToStr(ServerInstance->Users.GetUsers().size())); - stats.AddRow(249, "Channels: "+ConvToStr(ServerInstance->GetChans().size())); + stats.AddRow(249, "Channels: "+ConvToStr(ServerInstance->Channels.GetChans().size())); stats.AddRow(249, "Commands: "+ConvToStr(ServerInstance->Parser.GetCommands().size())); float kbitpersec_in, kbitpersec_out, kbitpersec_total; diff --git a/src/coremods/core_user/cmd_part.cpp b/src/coremods/core_user/cmd_part.cpp index 09cd6c0a3..2cb6e5021 100644 --- a/src/coremods/core_user/cmd_part.cpp +++ b/src/coremods/core_user/cmd_part.cpp @@ -49,7 +49,7 @@ CmdResult CommandPart::Handle(User* user, const Params& parameters) if (CommandParser::LoopCall(user, this, parameters, 0)) return CmdResult::SUCCESS; - Channel* c = ServerInstance->FindChan(parameters[0]); + Channel* c = ServerInstance->Channels.Find(parameters[0]); if (!c) { diff --git a/src/coremods/core_who.cpp b/src/coremods/core_who.cpp index 7a0b64520..2e32e6dd7 100644 --- a/src/coremods/core_who.cpp +++ b/src/coremods/core_who.cpp @@ -556,7 +556,7 @@ CmdResult CommandWho::HandleLocal(LocalUser* user, const Params& parameters) WhoData data(parameters); // Is the source running a WHO on a channel? - Channel* chan = ServerInstance->FindChan(data.matchtext); + Channel* chan = ServerInstance->Channels.Find(data.matchtext); if (chan) WhoChannel(user, parameters, chan, data); diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 275065997..709dcca17 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -36,19 +36,6 @@ #include "inspircd.h" #include "xline.h" -/* find a channel record by channel name and return a pointer to it */ - -Channel* InspIRCd::FindChan(const std::string &chan) -{ - chan_hash::iterator iter = chanlist.find(chan); - - if (iter == chanlist.end()) - /* Couldn't find it */ - return NULL; - - return iter->second; -} - bool InspIRCd::IsValidMask(const std::string &mask) { const char* dest = mask.c_str(); @@ -171,29 +158,6 @@ void InspIRCd::ProcessColors(file_cache& input) } } -/* true for valid channel name, false else */ -bool InspIRCd::DefaultIsChannel(const std::string& chname) -{ - if (chname.empty() || chname.length() > ServerInstance->Config->Limits.MaxChannel) - return false; - - if (chname[0] != '#') - return false; - - for (const auto& chr : insp::iterator_range(chname.begin() + 1, chname.end())) - { - switch (chr) - { - case ' ': - case ',': - case 7: - return false; - } - } - - return true; -} - /* true for valid nickname, false else */ bool InspIRCd::DefaultIsNick(const std::string& n) { diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 680d4b5b2..b5d87913c 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -448,7 +448,6 @@ void InspIRCd::WritePID(bool exitonfail) InspIRCd::InspIRCd(int argc, char** argv) : PI(&DefaultProtocolInterface) , GenRandom(&DefaultGenRandom) - , IsChannel(&DefaultIsChannel) , IsNick(&DefaultIsNick) , IsIdent(&DefaultIsIdent) { diff --git a/src/listmode.cpp b/src/listmode.cpp index 5bc1c12c8..d38dc8f6a 100644 --- a/src/listmode.cpp +++ b/src/listmode.cpp @@ -95,7 +95,7 @@ void ListModeBase::DoRehash() chanlimits.swap(newlimits); - for (const auto& [_, chan] : ServerInstance->GetChans()) + for (const auto& [_, chan] : ServerInstance->Channels.GetChans()) { ChanData* cd = extItem.Get(chan); if (cd) diff --git a/src/mode.cpp b/src/mode.cpp index eb00f4fec..cdfc4b8d0 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -662,8 +662,8 @@ bool ModeParser::DelMode(ModeHandler* mh) break; case MODETYPE_CHANNEL: { - const chan_hash& chans = ServerInstance->GetChans(); - for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ) + const ChannelMap& chans = ServerInstance->Channels.GetChans(); + for (ChannelMap::const_iterator i = chans.begin(); i != chans.end(); ) { // The channel may not be in the hash after RemoveMode(), see m_permchannels Channel* chan = i->second; diff --git a/src/modules.cpp b/src/modules.cpp index bc2970a7d..d66d2e8ae 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -391,8 +391,8 @@ void ModuleManager::DoSafeUnload(Module* mod) std::vector<ExtensionItem*> items; ServerInstance->Extensions.BeginUnregister(modfind->second, items); /* Give the module a chance to tidy out all its metadata */ - const chan_hash& chans = ServerInstance->GetChans(); - for (chan_hash::const_iterator c = chans.begin(); c != chans.end(); ) + const ChannelMap& chans = ServerInstance->Channels.GetChans(); + for (ChannelMap::const_iterator c = chans.begin(); c != chans.end(); ) { Channel* chan = c->second; ++c; diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp index 618e5ba26..3b5e3fdd5 100644 --- a/src/modules/m_banredirect.cpp +++ b/src/modules/m_banredirect.cpp @@ -155,13 +155,13 @@ class BanRedirect : public ModeWatcher { if (change.adding && IS_LOCAL(source)) { - if (!ServerInstance->IsChannel(mask[CHAN])) + if (!ServerInstance->Channels.IsChannel(mask[CHAN])) { source->WriteNumeric(ERR_NOSUCHCHANNEL, channel->name, InspIRCd::Format("Invalid channel name in redirection (%s)", mask[CHAN].c_str())); return false; } - Channel *c = ServerInstance->FindChan(mask[CHAN]); + Channel* c = ServerInstance->Channels.Find(mask[CHAN]); if (!c) { source->WriteNumeric(690, InspIRCd::Format("Target channel %s must exist to be set as a redirect.", mask[CHAN].c_str())); @@ -325,7 +325,7 @@ class ModuleBanRedirect : public Module return MOD_RES_DENY; /* tell them they're banned and are being transferred */ - Channel* destchan = ServerInstance->FindChan(redir->targetchan); + Channel* destchan = ServerInstance->Channels.Find(redir->targetchan); std::string destlimit; if (destchan) diff --git a/src/modules/m_chanlog.cpp b/src/modules/m_chanlog.cpp index 939010613..8096ec133 100644 --- a/src/modules/m_chanlog.cpp +++ b/src/modules/m_chanlog.cpp @@ -72,7 +72,7 @@ class ModuleChanLog : public Module const std::string snotice = "\002" + desc + "\002: " + msg; for (const auto& [_, channel] : channels) { - Channel* c = ServerInstance->FindChan(channel); + Channel* c = ServerInstance->Channels.Find(channel); if (c) { ClientProtocol::Messages::Privmsg privmsg(ClientProtocol::Messages::Privmsg::nocopy, ServerInstance->Config->ServerName, c, snotice); diff --git a/src/modules/m_channames.cpp b/src/modules/m_channames.cpp index bbfc9b030..353b50873 100644 --- a/src/modules/m_channames.cpp +++ b/src/modules/m_channames.cpp @@ -55,14 +55,14 @@ class ModuleChannelNames : public Module public: ModuleChannelNames() : Module(VF_VENDOR, "Allows the server administrator to define what characters are allowed in channel names.") - , rememberer(ServerInstance->IsChannel) + , rememberer(ServerInstance->Channels.IsChannel) , permchannelmode(this, "permanent") { } void init() override { - ServerInstance->IsChannel = NewIsChannelHandler::Call; + ServerInstance->Channels.IsChannel = NewIsChannelHandler::Call; } void ValidateChans() @@ -70,13 +70,13 @@ class ModuleChannelNames : public Module Modes::ChangeList removepermchan; badchan = true; - const chan_hash& chans = ServerInstance->GetChans(); - for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ) + const ChannelMap& chans = ServerInstance->Channels.GetChans(); + for (ChannelMap::const_iterator i = chans.begin(); i != chans.end(); ) { Channel* c = i->second; // Move iterator before we begin kicking ++i; - if (ServerInstance->IsChannel(c->name)) + if (ServerInstance->Channels.IsChannel(c->name)) continue; // The name of this channel is still valid if (c->IsModeSet(permchannelmode) && c->GetUserCounter()) @@ -146,7 +146,7 @@ class ModuleChannelNames : public Module Cullable::Result Cull() override { - ServerInstance->IsChannel = rememberer; + ServerInstance->Channels.IsChannel = rememberer; ValidateChans(); return Module::Cull(); } diff --git a/src/modules/m_check.cpp b/src/modules/m_check.cpp index cbb65264a..cad459a69 100644 --- a/src/modules/m_check.cpp +++ b/src/modules/m_check.cpp @@ -170,7 +170,7 @@ class CommandCheck : public Command Channel *targchan; targuser = ServerInstance->Users.Find(parameters[0]); - targchan = ServerInstance->FindChan(parameters[0]); + targchan = ServerInstance->Channels.Find(parameters[0]); /* * Syntax of a /check reply: diff --git a/src/modules/m_clearchan.cpp b/src/modules/m_clearchan.cpp index 0d656a023..7d726fafd 100644 --- a/src/modules/m_clearchan.cpp +++ b/src/modules/m_clearchan.cpp @@ -39,7 +39,7 @@ class CommandClearChan : public Command CmdResult Handle(User* user, const Params& parameters) override { - Channel* chan = activechan = ServerInstance->FindChan(parameters[0]); + Channel* chan = activechan = ServerInstance->Channels.Find(parameters[0]); if (!chan) { user->WriteNotice("The channel " + parameters[0] + " does not exist."); diff --git a/src/modules/m_codepage.cpp b/src/modules/m_codepage.cpp index 1e19fcf15..fae2398c5 100644 --- a/src/modules/m_codepage.cpp +++ b/src/modules/m_codepage.cpp @@ -223,7 +223,7 @@ class ModuleCodepage final RehashHashmap(ServerInstance->Users.clientlist); RehashHashmap(ServerInstance->Users.uuidlist); - RehashHashmap(ServerInstance->chanlist); + RehashHashmap(ServerInstance->Channels.GetChans()); } public: diff --git a/src/modules/m_conn_join.cpp b/src/modules/m_conn_join.cpp index afd464a17..a40f70327 100644 --- a/src/modules/m_conn_join.cpp +++ b/src/modules/m_conn_join.cpp @@ -34,7 +34,7 @@ static void JoinChannels(LocalUser* u, const std::string& chanlist) while (chans.GetToken(chan)) { - if (ServerInstance->IsChannel(chan)) + if (ServerInstance->Channels.IsChannel(chan)) Channel::JoinUser(u, chan); } } diff --git a/src/modules/m_cycle.cpp b/src/modules/m_cycle.cpp index 05ca78436..3b330ac8a 100644 --- a/src/modules/m_cycle.cpp +++ b/src/modules/m_cycle.cpp @@ -42,7 +42,7 @@ class CommandCycle : public SplitCommand CmdResult HandleLocal(LocalUser* user, const Params& parameters) override { - Channel* channel = ServerInstance->FindChan(parameters[0]); + Channel* channel = ServerInstance->Channels.Find(parameters[0]); std::string reason = "Cycling"; if (parameters.size() > 1) diff --git a/src/modules/m_denychans.cpp b/src/modules/m_denychans.cpp index 7d66aa701..c316a9da4 100644 --- a/src/modules/m_denychans.cpp +++ b/src/modules/m_denychans.cpp @@ -99,7 +99,7 @@ class ModuleDenyChannels : public Module if (!redirect.empty()) { // Ensure that <badchan:redirect> contains a channel name. - if (!ServerInstance->IsChannel(redirect)) + if (!ServerInstance->Channels.IsChannel(redirect)) throw ModuleException("<badchan:redirect> is not a valid channel name, at " + tag->source.str()); // We defer the rest of the validation of the redirect channel until we have @@ -166,7 +166,7 @@ class ModuleDenyChannels : public Module // the target channel redirects elsewhere we just tell the user and deny the join. Channel* target = NULL; if (badchan.redirect.empty() || user->IsModeSet(antiredirectmode) - || ((target = ServerInstance->FindChan(badchan.redirect)) && target->IsModeSet(redirectmode))) + || ((target = ServerInstance->Channels.Find(badchan.redirect)) && target->IsModeSet(redirectmode))) { user->WriteNumeric(ERR_BADCHANNEL, cname, InspIRCd::Format("Channel %s is forbidden: %s", cname.c_str(), badchan.reason.c_str())); diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index df127fe8b..b568f8d64 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -131,7 +131,7 @@ namespace Stats data << "<general>"; data << "<usercount>" << ServerInstance->Users.GetUsers().size() << "</usercount>"; data << "<localusercount>" << ServerInstance->Users.GetLocalUsers().size() << "</localusercount>"; - data << "<channelcount>" << ServerInstance->GetChans().size() << "</channelcount>"; + data << "<channelcount>" << ServerInstance->Channels.GetChans().size() << "</channelcount>"; data << "<opercount>" << ServerInstance->Users.all_opers.size() << "</opercount>"; data << "<socketcount>" << (SocketEngine::GetUsedFds()) << "</socketcount><socketmax>" << SocketEngine::GetMaxFds() << "</socketmax>"; data << "<uptime><boot_time_t>" << ServerInstance->startup_time << "</boot_time_t></uptime>"; @@ -177,7 +177,7 @@ namespace Stats { data << "<channellist>"; - for (const auto& [_, c] : ServerInstance->GetChans()) + for (const auto& [_, c] : ServerInstance->Channels.GetChans()) { data << "<channel>"; data << "<usercount>" << c->GetUsers().size() << "</usercount><channelname>" << Sanitize(c->name) << "</channelname>"; diff --git a/src/modules/m_ircv3_ctctags.cpp b/src/modules/m_ircv3_ctctags.cpp index 547a471c2..b4cf560d9 100644 --- a/src/modules/m_ircv3_ctctags.cpp +++ b/src/modules/m_ircv3_ctctags.cpp @@ -67,7 +67,7 @@ class CommandTagMsg : public Command CmdResult HandleChannelTarget(User* source, const Params& parameters, const char* target, PrefixMode* pm) { - Channel* chan = ServerInstance->FindChan(target); + Channel* chan = ServerInstance->Channels.Find(target); if (!chan) { // The target channel does not exist. diff --git a/src/modules/m_knock.cpp b/src/modules/m_knock.cpp index 5da2560e8..3c4d9e414 100644 --- a/src/modules/m_knock.cpp +++ b/src/modules/m_knock.cpp @@ -73,7 +73,7 @@ class CommandKnock : public Command CmdResult Handle(User* user, const Params& parameters) override { - Channel* c = ServerInstance->FindChan(parameters[0]); + Channel* c = ServerInstance->Channels.Find(parameters[0]); if (!c) { user->WriteNumeric(Numerics::NoSuchChannel(parameters[0])); diff --git a/src/modules/m_namedmodes.cpp b/src/modules/m_namedmodes.cpp index 0d2ef0810..37df4f22c 100644 --- a/src/modules/m_namedmodes.cpp +++ b/src/modules/m_namedmodes.cpp @@ -66,7 +66,7 @@ class CommandProp : public SplitCommand CmdResult HandleLocal(LocalUser* src, const Params& parameters) override { - Channel* const chan = ServerInstance->FindChan(parameters[0]); + Channel* const chan = ServerInstance->Channels.Find(parameters[0]); if (!chan) { src->WriteNumeric(Numerics::NoSuchChannel(parameters[0])); diff --git a/src/modules/m_namesx.cpp b/src/modules/m_namesx.cpp index 301f81c37..fed1a00c7 100644 --- a/src/modules/m_namesx.cpp +++ b/src/modules/m_namesx.cpp @@ -128,7 +128,7 @@ class ModuleNamesX continue; } - Channel* chan = ServerInstance->FindChan(channel.substr(hashpos)); + Channel* chan = ServerInstance->Channels.Find(channel.substr(hashpos)); if (!chan) { // Should never happen. diff --git a/src/modules/m_nationalchars.cpp b/src/modules/m_nationalchars.cpp index 0130e5a47..cf957afc6 100644 --- a/src/modules/m_nationalchars.cpp +++ b/src/modules/m_nationalchars.cpp @@ -250,7 +250,7 @@ class ModuleNationalChars : public Module RehashHashmap(ServerInstance->Users.clientlist); RehashHashmap(ServerInstance->Users.uuidlist); - RehashHashmap(ServerInstance->chanlist); + RehashHashmap(ServerInstance->Channels.GetChans()); } public: diff --git a/src/modules/m_ojoin.cpp b/src/modules/m_ojoin.cpp index 775ae708f..2ee355fc3 100644 --- a/src/modules/m_ojoin.cpp +++ b/src/modules/m_ojoin.cpp @@ -47,7 +47,7 @@ class CommandOjoin : public SplitCommand CmdResult HandleLocal(LocalUser* user, const Params& parameters) override { // Make sure the channel name is allowable. - if (!ServerInstance->IsChannel(parameters[0])) + if (!ServerInstance->Channels.IsChannel(parameters[0])) { user->WriteNotice("*** Invalid characters in channel name or name too long"); return CmdResult::FAILURE; @@ -67,7 +67,7 @@ class CommandOjoin : public SplitCommand } else { - channel = ServerInstance->FindChan(parameters[0]); + channel = ServerInstance->Channels.Find(parameters[0]); if (!channel) return CmdResult::FAILURE; diff --git a/src/modules/m_operjoin.cpp b/src/modules/m_operjoin.cpp index 5f5ade036..0f5cf16ac 100644 --- a/src/modules/m_operjoin.cpp +++ b/src/modules/m_operjoin.cpp @@ -58,13 +58,15 @@ class ModuleOperjoin : public Module return; for (const auto& operchan : operChans) - if (ServerInstance->IsChannel(operchan)) + { + if (ServerInstance->Channels.IsChannel(operchan)) Channel::JoinUser(localuser, operchan, override); + } irc::commasepstream ss(localuser->oper->getConfig("autojoin")); for (std::string channame; ss.GetToken(channame); ) { - if (ServerInstance->IsChannel(channame)) + if (ServerInstance->Channels.IsChannel(channame)) Channel::JoinUser(localuser, channame, override); } } diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp index cbafba911..fc8a82f65 100644 --- a/src/modules/m_permchannels.cpp +++ b/src/modules/m_permchannels.cpp @@ -82,7 +82,7 @@ static bool WriteDatabase(PermChannel& permchanmode, Module* mod, bool save_list << "# Any changes to this file will be automatically overwritten." << std::endl << std::endl; - for (const auto& [_, chan] : ServerInstance->GetChans()) + for (const auto& [_, chan] : ServerInstance->Channels.GetChans()) { if (!chan->IsModeSet(permchanmode)) continue; @@ -200,14 +200,13 @@ public: std::string channel = tag->getString("channel"); std::string modes = tag->getString("modes"); - if (!ServerInstance->IsChannel(channel)) + if (!ServerInstance->Channels.IsChannel(channel)) { ServerInstance->Logs.Log(MODNAME, LOG_DEFAULT, "Ignoring permchannels tag with invalid channel name (\"" + channel + "\")"); continue; } - Channel *c = ServerInstance->FindChan(channel); - + Channel* c = ServerInstance->Channels.Find(channel); if (!c) { time_t TS = tag->getInt("ts", ServerInstance->Time(), 1); diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp index a7a10c279..166c89da4 100644 --- a/src/modules/m_redirect.cpp +++ b/src/modules/m_redirect.cpp @@ -43,7 +43,7 @@ class Redirect : public ParamMode<Redirect, StringExtItem> { if (IS_LOCAL(source)) { - if (!ServerInstance->IsChannel(parameter)) + if (!ServerInstance->Channels.IsChannel(parameter)) { source->WriteNumeric(Numerics::NoSuchChannel(parameter)); return MODEACTION_DENY; @@ -52,7 +52,7 @@ class Redirect : public ParamMode<Redirect, StringExtItem> if (IS_LOCAL(source) && !source->IsOper()) { - Channel* c = ServerInstance->FindChan(parameter); + Channel* c = ServerInstance->Channels.Find(parameter); if (!c) { source->WriteNumeric(690, InspIRCd::Format("Target channel %s must exist to be set as a redirect.", parameter.c_str())); @@ -106,7 +106,7 @@ class ModuleRedirect : public Module const std::string& channel = *re.ext.Get(chan); /* sometimes broken services can make circular or chained +L, avoid this */ - Channel* destchan = ServerInstance->FindChan(channel); + Channel* destchan = ServerInstance->Channels.Find(channel); if (destchan && destchan->IsModeSet(re)) { user->WriteNumeric(470, cname, '*', "You may not join this channel. A redirect is set, but you may not be redirected as it is a circular loop."); diff --git a/src/modules/m_remove.cpp b/src/modules/m_remove.cpp index b06d41adf..ef9cdb789 100644 --- a/src/modules/m_remove.cpp +++ b/src/modules/m_remove.cpp @@ -78,7 +78,7 @@ class RemoveBase : public Command target = ServerInstance->Users.Find(username); /* And the channel we're meant to be removing them from */ - channel = ServerInstance->FindChan(channame); + channel = ServerInstance->Channels.Find(channame); /* Fix by brain - someone needs to learn to validate their input! */ if (!channel) diff --git a/src/modules/m_rmode.cpp b/src/modules/m_rmode.cpp index d39119fba..fbb8ed76c 100644 --- a/src/modules/m_rmode.cpp +++ b/src/modules/m_rmode.cpp @@ -37,7 +37,7 @@ class CommandRMode : public Command CmdResult Handle(User* user, const Params& parameters) override { ModeHandler* mh; - Channel* chan = ServerInstance->FindChan(parameters[0]); + Channel* chan = ServerInstance->Channels.Find(parameters[0]); char modeletter = parameters[1][0]; if (chan == NULL) diff --git a/src/modules/m_sajoin.cpp b/src/modules/m_sajoin.cpp index 17307cfa9..8b06d54a4 100644 --- a/src/modules/m_sajoin.cpp +++ b/src/modules/m_sajoin.cpp @@ -63,14 +63,14 @@ class CommandSajoin : public Command user->WriteNumeric(ERR_NOPRIVILEGES, "Cannot use an SA command on a U-lined client"); return CmdResult::FAILURE; } - if (IS_LOCAL(user) && !ServerInstance->IsChannel(channel)) + if (IS_LOCAL(user) && !ServerInstance->Channels.IsChannel(channel)) { /* we didn't need to check this for each character ;) */ user->WriteNotice("*** Invalid characters in channel name or name too long"); return CmdResult::FAILURE; } - Channel* chan = ServerInstance->FindChan(channel); + Channel* chan = ServerInstance->Channels.Find(channel); if ((chan) && (chan->HasUser(dest))) { user->WriteRemoteNotice("*** " + dest->nick + " is already on " + channel); diff --git a/src/modules/m_sakick.cpp b/src/modules/m_sakick.cpp index 1da4c1684..c251619b5 100644 --- a/src/modules/m_sakick.cpp +++ b/src/modules/m_sakick.cpp @@ -39,7 +39,7 @@ class CommandSakick : public Command CmdResult Handle(User* user, const Params& parameters) override { User* dest = ServerInstance->Users.Find(parameters[1]); - Channel* channel = ServerInstance->FindChan(parameters[0]); + Channel* channel = ServerInstance->Channels.Find(parameters[0]); if ((dest) && (dest->registered == REG_ALL) && (channel)) { diff --git a/src/modules/m_sapart.cpp b/src/modules/m_sapart.cpp index 4beaae354..35452172e 100644 --- a/src/modules/m_sapart.cpp +++ b/src/modules/m_sapart.cpp @@ -43,7 +43,7 @@ class CommandSapart : public Command return CmdResult::FAILURE; User* dest = ServerInstance->Users.Find(parameters[0]); - Channel* channel = ServerInstance->FindChan(parameters[1]); + Channel* channel = ServerInstance->Channels.Find(parameters[1]); std::string reason; if ((dest) && (dest->registered == REG_ALL) && (channel)) diff --git a/src/modules/m_satopic.cpp b/src/modules/m_satopic.cpp index 585887cdc..043c31c58 100644 --- a/src/modules/m_satopic.cpp +++ b/src/modules/m_satopic.cpp @@ -42,7 +42,7 @@ class CommandSATopic : public Command /* * Handles a SATOPIC request. Notifies all +s users. */ - Channel* target = ServerInstance->FindChan(parameters[0]); + Channel* target = ServerInstance->Channels.Find(parameters[0]); if(target) { diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp index 5e32b4138..350145e23 100644 --- a/src/modules/m_spanningtree/fjoin.cpp +++ b/src/modules/m_spanningtree/fjoin.cpp @@ -116,7 +116,7 @@ CmdResult CommandFJoin::Handle(User* srcuser, Params& params) time_t TS = ServerCommand::ExtractTS(params[1]); const std::string& channel = params[0]; - Channel* chan = ServerInstance->FindChan(channel); + Channel* chan = ServerInstance->Channels.Find(channel); bool apply_other_sides_modes = true; TreeServer* const sourceserver = TreeServer::Get(srcuser); @@ -152,7 +152,7 @@ CmdResult CommandFJoin::Handle(User* srcuser, Params& params) // XXX: If the channel does not exist in the chan hash at this point, create it so the remote modes can be applied on it. // This happens to 0-user permanent channels on the losing side, because those are removed (from the chan hash, then // deleted later) as soon as the permchan mode is removed from them. - if (ServerInstance->FindChan(channel) == NULL) + if (ServerInstance->Channels.Find(channel) == NULL) { chan = new Channel(channel, TS); } diff --git a/src/modules/m_spanningtree/fmode.cpp b/src/modules/m_spanningtree/fmode.cpp index d836b05e5..e59812efa 100644 --- a/src/modules/m_spanningtree/fmode.cpp +++ b/src/modules/m_spanningtree/fmode.cpp @@ -30,7 +30,7 @@ CmdResult CommandFMode::Handle(User* who, Params& params) { time_t TS = ServerCommand::ExtractTS(params[1]); - Channel* const chan = ServerInstance->FindChan(params[0]); + Channel* const chan = ServerInstance->Channels.Find(params[0]); if (!chan) // Channel doesn't exist return CmdResult::FAILURE; @@ -63,7 +63,7 @@ CmdResult CommandLMode::Handle(User* who, Params& params) // :<sid> LMODE <chan> <chants> <modechr> [<mask> <setts> <setter>]+ time_t chants = ServerCommand::ExtractTS(params[1]); - Channel* const chan = ServerInstance->FindChan(params[0]); + Channel* const chan = ServerInstance->Channels.Find(params[0]); if (!chan) return CmdResult::FAILURE; // Channel doesn't exist. diff --git a/src/modules/m_spanningtree/ftopic.cpp b/src/modules/m_spanningtree/ftopic.cpp index 243d2e398..cf124cb7b 100644 --- a/src/modules/m_spanningtree/ftopic.cpp +++ b/src/modules/m_spanningtree/ftopic.cpp @@ -28,7 +28,7 @@ /** FTOPIC command */ CmdResult CommandFTopic::Handle(User* user, Params& params) { - Channel* c = ServerInstance->FindChan(params[0]); + Channel* c = ServerInstance->Channels.Find(params[0]); if (!c) return CmdResult::FAILURE; diff --git a/src/modules/m_spanningtree/ijoin.cpp b/src/modules/m_spanningtree/ijoin.cpp index 3ffc5d9e2..38d5edebe 100644 --- a/src/modules/m_spanningtree/ijoin.cpp +++ b/src/modules/m_spanningtree/ijoin.cpp @@ -27,7 +27,7 @@ CmdResult CommandIJoin::HandleRemote(RemoteUser* user, Params& params) { - Channel* chan = ServerInstance->FindChan(params[0]); + Channel* chan = ServerInstance->Channels.Find(params[0]); if (!chan) { // Desync detected, recover @@ -60,7 +60,7 @@ CmdResult CommandIJoin::HandleRemote(RemoteUser* user, Params& params) CmdResult CommandResync::HandleServer(TreeServer* server, CommandBase::Params& params) { ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "Resyncing " + params[0]); - Channel* chan = ServerInstance->FindChan(params[0]); + Channel* chan = ServerInstance->Channels.Find(params[0]); if (!chan) { // This can happen for a number of reasons, safe to ignore diff --git a/src/modules/m_spanningtree/metadata.cpp b/src/modules/m_spanningtree/metadata.cpp index aabd4cbbc..f3bc66f77 100644 --- a/src/modules/m_spanningtree/metadata.cpp +++ b/src/modules/m_spanningtree/metadata.cpp @@ -51,7 +51,7 @@ CmdResult CommandMetadata::Handle(User* srcuser, Params& params) if (!u) return CmdResult::FAILURE; // User does not exist. - Channel* c = ServerInstance->FindChan(params[2]); + Channel* c = ServerInstance->Channels.Find(params[2]); if (!c) return CmdResult::FAILURE; // Channel does not exist. @@ -77,7 +77,7 @@ CmdResult CommandMetadata::Handle(User* srcuser, Params& params) if (params.size() < 3) throw ProtocolException("Insufficient parameters for channel METADATA"); - Channel* c = ServerInstance->FindChan(params[0]); + Channel* c = ServerInstance->Channels.Find(params[0]); if (!c) return CmdResult::FAILURE; diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index a72f5f6ce..30476953d 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -112,7 +112,7 @@ void TreeSocket::DoBurst(TreeServer* s) this->SendUsers(bs); // Sync all channels - for (const auto& [_, chan] : ServerInstance->GetChans()) + for (const auto& [_, chan] : ServerInstance->Channels.GetChans()) SyncChannel(chan, bs); // Send all xlines diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp index eb3bc4043..dc75d054c 100644 --- a/src/modules/m_spanningtree/postcommand.cpp +++ b/src/modules/m_spanningtree/postcommand.cpp @@ -97,7 +97,7 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, CommandBase* thiscm } if (dest[0] == '#') { - Channel* c = ServerInstance->FindChan(dest); + Channel* c = ServerInstance->Channels.Find(dest); if (!c) return; // TODO OnBuildExemptList hook was here diff --git a/src/modules/m_spanningtree/svsjoin.cpp b/src/modules/m_spanningtree/svsjoin.cpp index 4eb47587f..1458e2ece 100644 --- a/src/modules/m_spanningtree/svsjoin.cpp +++ b/src/modules/m_spanningtree/svsjoin.cpp @@ -29,7 +29,7 @@ CmdResult CommandSVSJoin::Handle(User* user, Params& parameters) { // Check for valid channel name - if (!ServerInstance->IsChannel(parameters[1])) + if (!ServerInstance->Channels.IsChannel(parameters[1])) return CmdResult::FAILURE; // Check target exists diff --git a/src/modules/m_spanningtree/svspart.cpp b/src/modules/m_spanningtree/svspart.cpp index 12b314d3a..6e5217ace 100644 --- a/src/modules/m_spanningtree/svspart.cpp +++ b/src/modules/m_spanningtree/svspart.cpp @@ -32,7 +32,7 @@ CmdResult CommandSVSPart::Handle(User* user, Params& parameters) if (!u) return CmdResult::FAILURE; - Channel* c = ServerInstance->FindChan(parameters[1]); + Channel* c = ServerInstance->Channels.Find(parameters[1]); if (!c) return CmdResult::FAILURE; diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp index 3a23b8f6d..d4db45d51 100644 --- a/src/modules/m_sslinfo.cpp +++ b/src/modules/m_sslinfo.cpp @@ -212,7 +212,7 @@ class CommandSSLInfo : public SplitCommand CmdResult HandleChannel(LocalUser* source, const std::string& channel) { - Channel* chan = ServerInstance->FindChan(channel); + Channel* chan = ServerInstance->Channels.Find(channel); if (!chan) { source->WriteNumeric(Numerics::NoSuchChannel(channel)); @@ -259,7 +259,7 @@ class CommandSSLInfo : public SplitCommand CmdResult HandleLocal(LocalUser* user, const Params& parameters) override { - if (ServerInstance->IsChannel(parameters[0])) + if (ServerInstance->Channels.IsChannel(parameters[0])) return HandleChannel(user, parameters[0]); else return HandleUser(user, parameters[0]); diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index 134bea869..3a72e7ac9 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -82,7 +82,7 @@ class CommandTban : public Command CmdResult Handle(User* user, const Params& parameters) override { - Channel* channel = ServerInstance->FindChan(parameters[0]); + Channel* channel = ServerInstance->Channels.Find(parameters[0]); if (!channel) { user->WriteNumeric(Numerics::NoSuchChannel(parameters[0])); diff --git a/src/modules/m_topiclock.cpp b/src/modules/m_topiclock.cpp index 07f121faa..45b6a8195 100644 --- a/src/modules/m_topiclock.cpp +++ b/src/modules/m_topiclock.cpp @@ -42,7 +42,7 @@ class CommandSVSTOPIC : public Command return CmdResult::FAILURE; } - Channel* chan = ServerInstance->FindChan(parameters[0]); + Channel* chan = ServerInstance->Channels.Find(parameters[0]); if (!chan) return CmdResult::FAILURE; diff --git a/src/modules/m_uninvite.cpp b/src/modules/m_uninvite.cpp index 007203028..988c9da38 100644 --- a/src/modules/m_uninvite.cpp +++ b/src/modules/m_uninvite.cpp @@ -57,7 +57,7 @@ class CommandUninvite : public Command else u = ServerInstance->Users.Find(parameters[0]); - Channel* c = ServerInstance->FindChan(parameters[1]); + Channel* c = ServerInstance->Channels.Find(parameters[1]); if ((!c) || (!u) || (u->registered != REG_ALL)) { |
