diff options
| author | 2018-12-18 19:06:56 -0600 | |
|---|---|---|
| committer | 2018-12-19 01:06:56 +0000 | |
| commit | 4fbd6681fedbff9b4cb04cc774f785cbe8b5c35b (patch) | |
| tree | 9df58ec3e4cf2c191b4ae0051118606957d89db6 /src/modules/m_dnsbl.cpp | |
| parent | Fix not propagating rehashes properly across the network. (diff) | |
| download | inspircd++-4fbd6681fedbff9b4cb04cc774f785cbe8b5c35b.tar.gz inspircd++-4fbd6681fedbff9b4cb04cc774f785cbe8b5c35b.tar.bz2 inspircd++-4fbd6681fedbff9b4cb04cc774f785cbe8b5c35b.zip | |
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_dnsbl.cpp')
| -rw-r--r-- | src/modules/m_dnsbl.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index 7b88bc961..d1ca800b3 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -228,9 +228,11 @@ class DNSBLResolver : public DNS::Request } }; +typedef std::vector<reference<DNSBLConfEntry> > DNSBLConfList; + class ModuleDNSBL : public Module, public Stats::EventListener { - std::vector<reference<DNSBLConfEntry> > DNSBLConfEntries; + DNSBLConfList DNSBLConfEntries; dynamic_reference<DNS::Manager> DNS; LocalStringExt nameExt; LocalIntExt countExt; @@ -276,7 +278,7 @@ class ModuleDNSBL : public Module, public Stats::EventListener */ void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { - DNSBLConfEntries.clear(); + DNSBLConfList newentries; ConfigTagList dnsbls = ServerInstance->Config->ConfTags("dnsbl"); for(ConfigIter i = dnsbls.first; i != dnsbls.second; ++i) @@ -313,23 +315,19 @@ class ModuleDNSBL : public Module, public Stats::EventListener /* yeah, logic here is a little messy */ if ((e->bitmask <= 0) && (DNSBLConfEntry::A_BITMASK == e->type)) { - std::string location = tag->getTagLocation(); - ServerInstance->SNO->WriteGlobalSno('d', "DNSBL(%s): invalid bitmask", location.c_str()); + throw ModuleException("Invalid <dnsbl:bitmask> at " + tag->getTagLocation()); } else if (e->name.empty()) { - std::string location = tag->getTagLocation(); - ServerInstance->SNO->WriteGlobalSno('d', "DNSBL(%s): Invalid name", location.c_str()); + throw ModuleException("Empty <dnsbl:name> at " + tag->getTagLocation()); } else if (e->domain.empty()) { - std::string location = tag->getTagLocation(); - ServerInstance->SNO->WriteGlobalSno('d', "DNSBL(%s): Invalid domain", location.c_str()); + throw ModuleException("Empty <dnsbl:domain> at " + tag->getTagLocation()); } else if (e->banaction == DNSBLConfEntry::I_UNKNOWN) { - std::string location = tag->getTagLocation(); - ServerInstance->SNO->WriteGlobalSno('d', "DNSBL(%s): Invalid banaction", location.c_str()); + throw ModuleException("Unknown <dnsbl:action> at " + tag->getTagLocation()); } else { @@ -341,9 +339,11 @@ class ModuleDNSBL : public Module, public Stats::EventListener } /* add it, all is ok */ - DNSBLConfEntries.push_back(e); + newentries.push_back(e); } } + + DNSBLConfEntries.swap(newentries); } void OnSetUserIP(LocalUser* user) CXX11_OVERRIDE |
