diff options
author | linuxdaemon <linuxdaemon@users.noreply.github.com> | 2018-12-18 19:06:56 -0600 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2018-12-19 01:06:56 +0000 |
commit | 4fbd6681fedbff9b4cb04cc774f785cbe8b5c35b (patch) | |
tree | 9df58ec3e4cf2c191b4ae0051118606957d89db6 /src/modules/m_dccallow.cpp | |
parent | bf0bf05ac07a4bd0afeba5a276ef86308f0f9e54 (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_dccallow.cpp')
-rw-r--r-- | src/modules/m_dccallow.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index eb364089a..85f9d20d0 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -106,6 +106,7 @@ class CommandDccallow : public Command public: unsigned int maxentries; + unsigned long defaultlength; CommandDccallow(Module* parent, DCCAllowExt& Ext) : Command(parent, "DCCALLOW", 0) , ext(Ext) @@ -206,12 +207,10 @@ class CommandDccallow : public Command } std::string mask = target->nick+"!"+target->ident+"@"+target->GetDisplayedHost(); - std::string default_length = ServerInstance->Config->ConfValue("dccallow")->getString("length"); - unsigned long length; if (parameters.size() < 2) { - length = InspIRCd::Duration(default_length); + length = defaultlength; } else if (!InspIRCd::IsValidDuration(parameters[1])) { @@ -293,11 +292,14 @@ class ModuleDCCAllow : public Module { DCCAllowExt ext; CommandDccallow cmd; + bool blockchat; + std::string defaultaction; public: ModuleDCCAllow() : ext("dccallow", ExtensionItem::EXT_USER, this) , cmd(this, ext) + , blockchat(false) { } @@ -356,9 +358,6 @@ class ModuleDCCAllow : public Module const std::string type = buf.substr(0, s); - ConfigTag* conftag = ServerInstance->Config->ConfValue("dccallow"); - bool blockchat = conftag->getBool("blockchat"); - if (stdalgo::string::equalsci(type, "SEND")) { size_t first; @@ -384,7 +383,6 @@ class ModuleDCCAllow : public Module if (s == std::string::npos) return MOD_RES_PASSTHRU; - std::string defaultaction = conftag->getString("action"); std::string filename = buf.substr(first, s); bool found = false; @@ -507,18 +505,22 @@ class ModuleDCCAllow : public Module void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { - ConfigTag* tag = ServerInstance->Config->ConfValue("dccallow"); - cmd.maxentries = tag->getUInt("maxentries", 20); - - bfl.clear(); + bannedfilelist newbfl; ConfigTagList tags = ServerInstance->Config->ConfTags("banfile"); for (ConfigIter i = tags.first; i != tags.second; ++i) { BannedFileList bf; bf.filemask = i->second->getString("pattern"); bf.action = i->second->getString("action"); - bfl.push_back(bf); + newbfl.push_back(bf); } + bfl.swap(newbfl); + + ConfigTag* tag = ServerInstance->Config->ConfValue("dccallow"); + cmd.maxentries = tag->getUInt("maxentries", 20); + cmd.defaultlength = tag->getDuration("length", 0); + blockchat = tag->getBool("blockchat"); + defaultaction = tag->getString("action"); } Version GetVersion() CXX11_OVERRIDE |