aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/m_restrictchans.cpp
diff options
context:
space:
mode:
authorGravatar linuxdaemon2018-12-18 19:06:56 -0600
committerGravatar Peter Powell2018-12-19 01:06:56 +0000
commit4fbd6681fedbff9b4cb04cc774f785cbe8b5c35b (patch)
tree9df58ec3e4cf2c191b4ae0051118606957d89db6 /src/modules/m_restrictchans.cpp
parentFix not propagating rehashes properly across the network. (diff)
Make more modules rehash atomically (#1535)
Have each module validate the values it loads before setting them, so any errors don't result in partial application of the configs
Diffstat (limited to 'src/modules/m_restrictchans.cpp')
-rw-r--r--src/modules/m_restrictchans.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/modules/m_restrictchans.cpp b/src/modules/m_restrictchans.cpp
index 9c7ed1213..348beed2c 100644
--- a/src/modules/m_restrictchans.cpp
+++ b/src/modules/m_restrictchans.cpp
@@ -22,21 +22,26 @@
#include "inspircd.h"
+typedef insp::flat_set<std::string, irc::insensitive_swo> AllowChans;
+
class ModuleRestrictChans : public Module
{
- insp::flat_set<std::string, irc::insensitive_swo> allowchans;
+ AllowChans allowchans;
public:
void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
{
- allowchans.clear();
+ AllowChans newallows;
ConfigTagList tags = ServerInstance->Config->ConfTags("allowchannel");
for(ConfigIter i = tags.first; i != tags.second; ++i)
{
- ConfigTag* tag = i->second;
- std::string txt = tag->getString("name");
- allowchans.insert(txt);
+ const std::string name = i->second->getString("name");
+ if (name.empty())
+ throw ModuleException("Empty <allowchannel:name> at " + i->second->getTagLocation());
+
+ newallows.insert(name);
}
+ allowchans.swap(newallows);
}
ModResult OnUserPreJoin(LocalUser* user, Channel* chan, const std::string& cname, std::string& privs, const std::string& keygiven) CXX11_OVERRIDE