diff options
| author | 2020-10-31 20:03:19 +0000 | |
|---|---|---|
| committer | 2020-10-31 22:33:35 +0000 | |
| commit | 441bd151da733d32e194de6e4a1744ae273b83ee (patch) | |
| tree | 74eb1ee2aef413185bf3906a17f1b2c27373e03a /src/modules | |
| parent | Fix reading the <sslprofile> config. (diff) | |
Add stdalgo::iterator_range and switch config tag reading to use it.
This allows us to use range-based for loops which were not possible
with the previous config tag system.
Diffstat (limited to 'src/modules')
35 files changed, 92 insertions, 162 deletions
diff --git a/src/modules/extra/m_ldap.cpp b/src/modules/extra/m_ldap.cpp index 503ef4b3c..0f3ac68d6 100644 --- a/src/modules/extra/m_ldap.cpp +++ b/src/modules/extra/m_ldap.cpp @@ -545,11 +545,8 @@ class ModuleLDAP : public Module { ServiceMap conns; - ConfigTagList tags = ServerInstance->Config->ConfTags("database"); - for (ConfigIter i = tags.first; i != tags.second; i++) + for (auto& [_, tag] : ServerInstance->Config->ConfTags("database")) { - const reference<ConfigTag>& tag = i->second; - if (!stdalgo::string::equalsci(tag->getString("module"), "ldap")) continue; diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index 622bb7e24..40d3f107a 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -467,16 +467,17 @@ ModuleSQL::~ModuleSQL() void ModuleSQL::ReadConfig(ConfigStatus& status) { ConnMap conns; - ConfigTagList tags = ServerInstance->Config->ConfTags("database"); - for(ConfigIter i = tags.first; i != tags.second; i++) + + for (auto& [_, tag] : ServerInstance->Config->ConfTags("database")) { - if (!stdalgo::string::equalsci(i->second->getString("module"), "mysql")) + if (!stdalgo::string::equalsci(tag->getString("module"), "mysql")) continue; - std::string id = i->second->getString("id"); + + std::string id = tag->getString("id"); ConnMap::iterator curr = connections.find(id); if (curr == connections.end()) { - SQLConnection* conn = new SQLConnection(this, i->second); + SQLConnection* conn = new SQLConnection(this, tag); conns.insert(std::make_pair(id, conn)); ServerInstance->Modules.AddService(*conn); } diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index dc9be948e..cb5c492bf 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -546,16 +546,17 @@ class ModulePgSQL : public Module void ReadConf() { ConnMap conns; - ConfigTagList tags = ServerInstance->Config->ConfTags("database"); - for(ConfigIter i = tags.first; i != tags.second; i++) + + for (auto& [_, tag] : ServerInstance->Config->ConfTags("database")) { - if (!stdalgo::string::equalsci(i->second->getString("module"), "pgsql")) + if (!stdalgo::string::equalsci(tag->getString("module"), "pgsql")) continue; - std::string id = i->second->getString("id"); + + std::string id = tag->getString("id"); ConnMap::iterator curr = connections.find(id); if (curr == connections.end()) { - SQLConn* conn = new SQLConn(this, i->second); + SQLConn* conn = new SQLConn(this, tag); if (conn->status != DEAD) { conns.insert(std::make_pair(id, conn)); diff --git a/src/modules/extra/m_sqlite3.cpp b/src/modules/extra/m_sqlite3.cpp index b0cd39588..bf11f25e3 100644 --- a/src/modules/extra/m_sqlite3.cpp +++ b/src/modules/extra/m_sqlite3.cpp @@ -256,13 +256,14 @@ class ModuleSQLite3 : public Module void ReadConfig(ConfigStatus& status) override { ClearConns(); - ConfigTagList tags = ServerInstance->Config->ConfTags("database"); - for(ConfigIter i = tags.first; i != tags.second; i++) + + for (auto& [_, tag] : ServerInstance->Config->ConfTags("database")) { - if (!stdalgo::string::equalsci(i->second->getString("module"), "sqlite")) + if (!stdalgo::string::equalsci(tag->getString("module"), "sqlite")) continue; - SQLConn* conn = new SQLConn(this, i->second); - conns.insert(std::make_pair(i->second->getString("id"), conn)); + + SQLConn* conn = new SQLConn(this, tag); + conns.insert(std::make_pair(tag->getString("id"), conn)); ServerInstance->Modules.AddService(*conn); } } diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index 5b921cbd4..da40e6e34 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -1126,12 +1126,11 @@ class ModuleSSLGnuTLS : public Module ProfileList newprofiles; ConfigTagList tags = ServerInstance->Config->ConfTags("sslprofile"); - if (tags.first == tags.second) + if (tags.empty()) throw ModuleException("You have not specified any <sslprofile> tags that are usable by this module!"); - for (ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, tag] : tags) { - ConfigTag* tag = i->second; if (!stdalgo::string::equalsci(tag->getString("provider"), "gnutls")) { ServerInstance->Logs.Log(MODNAME, LOG_DEFAULT, "Ignoring non-GnuTLS <sslprofile> tag at " + tag->getTagLocation()); diff --git a/src/modules/extra/m_ssl_mbedtls.cpp b/src/modules/extra/m_ssl_mbedtls.cpp index c5208cf03..67246ce76 100644 --- a/src/modules/extra/m_ssl_mbedtls.cpp +++ b/src/modules/extra/m_ssl_mbedtls.cpp @@ -859,12 +859,11 @@ class ModuleSSLmbedTLS : public Module ProfileList newprofiles; ConfigTagList tags = ServerInstance->Config->ConfTags("sslprofile"); - if (tags.first == tags.second) + if (tags.empty()) throw ModuleException("You have not specified any <sslprofile> tags that are usable by this module!"); - for (ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, tag] : tags) { - ConfigTag* tag = i->second; if (!stdalgo::string::equalsci(tag->getString("provider"), "mbedtls")) { ServerInstance->Logs.Log(MODNAME, LOG_DEFAULT, "Ignoring non-mbedTLS <sslprofile> tag at " + tag->getTagLocation()); diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index 3f517348d..401dfaeb1 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -906,12 +906,11 @@ class ModuleSSLOpenSSL : public Module { ProfileList newprofiles; ConfigTagList tags = ServerInstance->Config->ConfTags("sslprofile"); - if (tags.first == tags.second) + if (tags.empty()) throw ModuleException("You have not specified any <sslprofile> tags that are usable by this module!"); - for (ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, tag] : tags) { - ConfigTag* tag = i->second; if (!stdalgo::string::equalsci(tag->getString("provider"), "openssl")) { ServerInstance->Logs.Log(MODNAME, LOG_DEFAULT, "Ignoring non-OpenSSL <sslprofile> tag at " + tag->getTagLocation()); diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index 33bf47a2c..769b1ffcb 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -83,10 +83,8 @@ class ModuleAlias : public Module void ReadConfig(ConfigStatus& status) override { AliasMap newAliases; - ConfigTagList tags = ServerInstance->Config->ConfTags("alias"); - for(ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, tag] : ServerInstance->Config->ConfTags("alias")) { - ConfigTag* tag = i->second; Alias a; a.AliasedCommand = tag->getString("text"); if (a.AliasedCommand.empty()) diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp index 70e19bbfd..a576ae287 100644 --- a/src/modules/m_censor.cpp +++ b/src/modules/m_censor.cpp @@ -108,10 +108,8 @@ class ModuleCensor : public Module */ censor_t newcensors; - ConfigTagList badwords = ServerInstance->Config->ConfTags("badword"); - for (ConfigIter i = badwords.first; i != badwords.second; ++i) + for (auto& [_, tag] : ServerInstance->Config->ConfTags("badword")) { - ConfigTag* tag = i->second; const std::string text = tag->getString("text"); if (text.empty()) throw ModuleException("<badword:text> is empty! at " + tag->getTagLocation()); diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp index b4aed47ee..72566b460 100644 --- a/src/modules/m_cgiirc.cpp +++ b/src/modules/m_cgiirc.cpp @@ -285,11 +285,8 @@ class ModuleCgiIRC std::vector<IdentHost> identhosts; std::vector<WebIRCHost> webirchosts; - ConfigTagList tags = ServerInstance->Config->ConfTags("cgihost"); - for (ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, tag] : ServerInstance->Config->ConfTags("cgihost")) { - ConfigTag* tag = i->second; - // Ensure that we have the <cgihost:mask> parameter. const std::string mask = tag->getString("mask"); if (mask.empty()) diff --git a/src/modules/m_chanlog.cpp b/src/modules/m_chanlog.cpp index 8dff4123d..8250a5d98 100644 --- a/src/modules/m_chanlog.cpp +++ b/src/modules/m_chanlog.cpp @@ -42,19 +42,14 @@ class ModuleChanLog : public Module void ReadConfig(ConfigStatus& status) override { - std::string snomasks; - std::string channel; ChanLogTargets newlogs; - - ConfigTagList tags = ServerInstance->Config->ConfTags("chanlog"); - for (ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, tag] : ServerInstance->Config->ConfTags("chanlog")) { - channel = i->second->getString("channel"); - snomasks = i->second->getString("snomasks"); - + std::string channel = tag->getString("channel"); + std::string snomasks = tag->getString("snomasks"); if (channel.empty() || snomasks.empty()) { - throw ModuleException("Malformed chanlog tag at " + i->second->getTagLocation()); + throw ModuleException("Malformed chanlog tag at " + tag->getTagLocation()); } for (std::string::const_iterator it = snomasks.begin(); it != snomasks.end(); it++) diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index 60868b79f..f4f76a033 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -427,23 +427,23 @@ class ModuleCloaking : public Module void ReadConfig(ConfigStatus& status) override { ConfigTagList tags = ServerInstance->Config->ConfTags("cloak"); - if (tags.first == tags.second) + if (tags.empty()) throw ModuleException("You have loaded the cloaking module but not configured any <cloak> tags!"); + bool firstcloak = true; std::vector<CloakInfo> newcloaks; - for (ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, tag] : tags) { - ConfigTag* tag = i->second; - // Ensure that we have the <cloak:key> parameter. const std::string key = tag->getString("key"); if (key.empty()) throw ModuleException("You have not defined a cloaking key. Define <cloak:key> as a " + ConvToStr(minkeylen) + "+ character network-wide secret, at " + tag->getTagLocation()); // If we are the first cloak method then mandate a strong key. - if (i == tags.first && key.length() < minkeylen) + if (firstcloak && key.length() < minkeylen) throw ModuleException("Your cloaking key is not secure. It should be at least " + ConvToStr(minkeylen) + " characters long, at " + tag->getTagLocation()); + firstcloak = false; const bool ignorecase = tag->getBool("ignorecase"); const std::string mode = tag->getString("mode"); const std::string prefix = tag->getString("prefix"); diff --git a/src/modules/m_codepage.cpp b/src/modules/m_codepage.cpp index 3343efbef..fcff62ff5 100644 --- a/src/modules/m_codepage.cpp +++ b/src/modules/m_codepage.cpp @@ -124,11 +124,9 @@ class ModuleCodepage AllowedChars newallowedchars; AllowedChars newallowedfrontchars; - ConfigTagList cpchars = ServerInstance->Config->ConfTags("cpchars"); - for (ConfigIter i = cpchars.first; i != cpchars.second; ++i) - { - ConfigTag* tag = i->second; + for (auto& [_, tag] : ServerInstance->Config->ConfTags("cpchars")) + { unsigned char begin = tag->getUInt("begin", tag->getUInt("index", 0), 1, UCHAR_MAX); if (!begin) throw ModuleException("<cpchars> tag without index or begin specified at " + tag->getTagLocation()); @@ -162,11 +160,9 @@ class ModuleCodepage unsigned char newcasemap[UCHAR_MAX]; for (size_t i = 0; i < UCHAR_MAX; ++i) newcasemap[i] = i; - ConfigTagList cpcase = ServerInstance->Config->ConfTags("cpcase"); - for (ConfigIter i = cpcase.first; i != cpcase.second; ++i) - { - ConfigTag* tag = i->second; + for (auto& [_, tag] : ServerInstance->Config->ConfTags("cpcase")) + { unsigned char lower = tag->getUInt("lower", 0, 1, UCHAR_MAX); if (!lower) throw ModuleException("<cpcase:lower> is required at " + tag->getTagLocation()); diff --git a/src/modules/m_customprefix.cpp b/src/modules/m_customprefix.cpp index 6a98c1f7b..70cf68f77 100644 --- a/src/modules/m_customprefix.cpp +++ b/src/modules/m_customprefix.cpp @@ -55,11 +55,8 @@ class ModuleCustomPrefix : public Module void init() override { - ConfigTagList tags = ServerInstance->Config->ConfTags("customprefix"); - for (ConfigIter iter = tags.first; iter != tags.second; ++iter) + for (auto& [_, tag] : ServerInstance->Config->ConfTags("customprefix")) { - ConfigTag* tag = iter->second; - const std::string name = tag->getString("name"); if (name.empty()) throw ModuleException("<customprefix:name> must be specified at " + tag->getTagLocation()); diff --git a/src/modules/m_customtitle.cpp b/src/modules/m_customtitle.cpp index b51d71c6e..61b1ed42a 100644 --- a/src/modules/m_customtitle.cpp +++ b/src/modules/m_customtitle.cpp @@ -126,11 +126,9 @@ class ModuleCustomTitle : public Module, public Whois::LineEventListener void ReadConfig(ConfigStatus& status) override { - ConfigTagList tags = ServerInstance->Config->ConfTags("title"); CustomVhostMap newtitles; - for (ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, tag] : ServerInstance->Config->ConfTags("title")) { - reference<ConfigTag> tag = i->second; std::string name = tag->getString("name", "", 1); if (name.empty()) throw ModuleException("<title:name> is empty at " + tag->getTagLocation()); diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index 8198d712b..88a599fe8 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -589,12 +589,12 @@ class ModuleDCCAllow : public Module void ReadConfig(ConfigStatus& status) override { bannedfilelist newbfl; - ConfigTagList tags = ServerInstance->Config->ConfTags("banfile"); - for (ConfigIter i = tags.first; i != tags.second; ++i) + + for (auto& [_, tag] : ServerInstance->Config->ConfTags("banfile")) { BannedFileList bf; - bf.filemask = i->second->getString("pattern"); - bf.action = i->second->getString("action"); + bf.filemask = tag->getString("pattern"); + bf.action = tag->getString("action"); newbfl.push_back(bf); } bfl.swap(newbfl); diff --git a/src/modules/m_denychans.cpp b/src/modules/m_denychans.cpp index 745170221..3fa768953 100644 --- a/src/modules/m_denychans.cpp +++ b/src/modules/m_denychans.cpp @@ -71,11 +71,9 @@ class ModuleDenyChannels : public Module void ReadConfig(ConfigStatus& status) override { GoodChannels goodchans; - ConfigTagList tags = ServerInstance->Config->ConfTags("goodchan"); - for (ConfigIter iter = tags.first; iter != tags.second; ++iter) - { - ConfigTag* tag = iter->second; + for (auto& [_, tag] : ServerInstance->Config->ConfTags("goodchan")) + { // Ensure that we have the <goodchan:name> parameter. const std::string name = tag->getString("name"); if (name.empty()) @@ -85,11 +83,8 @@ class ModuleDenyChannels : public Module } BadChannels badchans; - tags = ServerInstance->Config->ConfTags("badchan"); - for (ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, tag] : ServerInstance->Config->ConfTags("badchan")) { - ConfigTag* tag = i->second; - // Ensure that we have the <badchan:name> parameter. const std::string name = tag->getString("name"); if (name.empty()) diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index 6ba3a0024..2b8665629 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -284,10 +284,8 @@ class ModuleDNSBL : public Module, public Stats::EventListener { DNSBLConfList newentries; - ConfigTagList dnsbls = ServerInstance->Config->ConfTags("dnsbl"); - for(ConfigIter i = dnsbls.first; i != dnsbls.second; ++i) + for (auto& [_, tag] : ServerInstance->Config->ConfTags("dnsbl")) { - ConfigTag* tag = i->second; auto e = std::make_shared<DNSBLConfEntry>(); e->name = tag->getString("name"); diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index 9e2aae709..620eb13e7 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -612,14 +612,11 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params& void ModuleFilter::ReadConfig(ConfigStatus& status) { - ConfigTagList tags = ServerInstance->Config->ConfTags("exemptfromfilter"); exemptedchans.clear(); exemptednicks.clear(); - for (ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, tag] : ServerInstance->Config->ConfTags("exemptfromfilter")) { - ConfigTag* tag = i->second; - const std::string target = tag->getString("target"); if (!target.empty()) { @@ -856,16 +853,13 @@ void ModuleFilter::ReadFilters() filter++; } - ConfigTagList tags = ServerInstance->Config->ConfTags("keyword"); - for (ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, tag] : ServerInstance->Config->ConfTags("keyword")) { - std::string pattern = i->second->getString("pattern"); - std::string reason = i->second->getString("reason"); - std::string action = i->second->getString("action"); - std::string flgs = i->second->getString("flags"); - unsigned long duration = i->second->getDuration("duration", 10*60, 1); - if (flgs.empty()) - flgs = "*"; + std::string pattern = tag->getString("pattern"); + std::string reason = tag->getString("reason"); + std::string action = tag->getString("action"); + std::string flgs = tag->getString("flags", "*", 1); + unsigned long duration = tag->getDuration("duration", 10*60, 1); FilterAction fa; if (!StringToFilterAction(action, fa)) diff --git a/src/modules/m_helpop.cpp b/src/modules/m_helpop.cpp index a9b732145..37901c612 100644 --- a/src/modules/m_helpop.cpp +++ b/src/modules/m_helpop.cpp @@ -116,13 +116,11 @@ class ModuleHelpop HelpMap newhelp; ConfigTagList tags = ServerInstance->Config->ConfTags("helpop"); - if (tags.first == tags.second) + if (tags.empty()) throw ModuleException("You have loaded the helpop module but not configured any help topics!"); - for (ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, tag] : tags) { - ConfigTag* tag = i->second; - // Attempt to read the help key. const std::string key = tag->getString("key"); if (key.empty()) diff --git a/src/modules/m_hidelist.cpp b/src/modules/m_hidelist.cpp index fe314c47c..4f8539944 100644 --- a/src/modules/m_hidelist.cpp +++ b/src/modules/m_hidelist.cpp @@ -60,12 +60,11 @@ class ModuleHideList : public Module public: void ReadConfig(ConfigStatus& status) override { - ConfigTagList tags = ServerInstance->Config->ConfTags("hidelist"); typedef std::vector<std::pair<std::string, unsigned int> > NewConfigs; NewConfigs newconfigs; - for (ConfigIter i = tags.first; i != tags.second; ++i) + + for (auto& [_, tag] : ServerInstance->Config->ConfTags("hidelist")) { - ConfigTag* tag = i->second; std::string modename = tag->getString("mode"); if (modename.empty()) throw ModuleException("Empty <hidelist:mode> at " + tag->getTagLocation()); diff --git a/src/modules/m_hidemode.cpp b/src/modules/m_hidemode.cpp index a6619496a..360a7aa56 100644 --- a/src/modules/m_hidemode.cpp +++ b/src/modules/m_hidemode.cpp @@ -42,10 +42,8 @@ class Settings { RanksToSeeMap newranks; - ConfigTagList tags = ServerInstance->Config->ConfTags("hidemode"); - for (ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, tag] : ServerInstance->Config->ConfTags("hidemode")) { - ConfigTag* tag = i->second; const std::string modename = tag->getString("mode"); if (modename.empty()) throw ModuleException("<hidemode:mode> is empty at " + tag->getTagLocation()); diff --git a/src/modules/m_hostchange.cpp b/src/modules/m_hostchange.cpp index a6358e44a..89e9783db 100644 --- a/src/modules/m_hostchange.cpp +++ b/src/modules/m_hostchange.cpp @@ -133,11 +133,8 @@ private: { HostRules rules; - ConfigTagList tags = ServerInstance->Config->ConfTags("hostchange"); - for (ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, tag] : ServerInstance->Config->ConfTags("hostchange")) { - ConfigTag* tag = i->second; - // Ensure that we have the <hostchange:mask> parameter. const std::string mask = tag->getString("mask"); if (mask.empty()) diff --git a/src/modules/m_httpd_acl.cpp b/src/modules/m_httpd_acl.cpp index 7715d9b1e..dcf8bda1d 100644 --- a/src/modules/m_httpd_acl.cpp +++ b/src/modules/m_httpd_acl.cpp @@ -58,10 +58,8 @@ class ModuleHTTPAccessList : public Module, public HTTPACLEventListener void ReadConfig(ConfigStatus& status) override { std::vector<HTTPACL> new_acls; - ConfigTagList acls = ServerInstance->Config->ConfTags("httpdacl"); - for (ConfigIter i = acls.first; i != acls.second; i++) + for (auto& [_, c] : ServerInstance->Config->ConfTags("httpdacl")) { - ConfigTag* c = i->second; std::string path = c->getString("path"); std::string types = c->getString("types"); irc::commasepstream sep(types); diff --git a/src/modules/m_ldapauth.cpp b/src/modules/m_ldapauth.cpp index 1dd7bac75..55a6b4c8f 100644 --- a/src/modules/m_ldapauth.cpp +++ b/src/modules/m_ldapauth.cpp @@ -338,22 +338,18 @@ public: LDAP.SetProvider("LDAP/" + tag->getString("dbid")); - ConfigTagList whitelisttags = ServerInstance->Config->ConfTags("ldapwhitelist"); - - for (ConfigIter i = whitelisttags.first; i != whitelisttags.second; ++i) + for (auto& [_, wtag] : ServerInstance->Config->ConfTags("ldapwhitelist")) { - std::string cidr = i->second->getString("cidr"); + std::string cidr = wtag->getString("cidr"); if (!cidr.empty()) { whitelistedcidrs.push_back(cidr); } } - ConfigTagList attributetags = ServerInstance->Config->ConfTags("ldaprequire"); - - for (ConfigIter i = attributetags.first; i != attributetags.second; ++i) + for (auto& [_, rtag] : ServerInstance->Config->ConfTags("ldaprequire")) { - const std::string attr = i->second->getString("attribute"); - const std::string val = i->second->getString("value"); + const std::string attr = rtag->getString("attribute"); + const std::string val = rtag->getString("value"); if (!attr.empty() && !val.empty()) requiredattributes.push_back(make_pair(attr, val)); diff --git a/src/modules/m_pbkdf2.cpp b/src/modules/m_pbkdf2.cpp index 706c61e89..9aaf68c96 100644 --- a/src/modules/m_pbkdf2.cpp +++ b/src/modules/m_pbkdf2.cpp @@ -186,15 +186,13 @@ class ModulePBKDF2 : public Module // Then the specific values ProviderConfigMap newconfigs; - ConfigTagList tags = ServerInstance->Config->ConfTags("pbkdf2prov"); - for (ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, ptag] : ServerInstance->Config->ConfTags("pbkdf2prov")) { - tag = i->second; - std::string hash_name = "hash/" + tag->getString("hash"); + std::string hash_name = "hash/" + ptag->getString("hash"); ProviderConfig& config = newconfigs[hash_name]; - config.iterations = tag->getUInt("iterations", newglobal.iterations, 1); - config.dkey_length = tag->getUInt("length", newglobal.dkey_length, 1, 1024); + config.iterations = ptag->getUInt("iterations", newglobal.iterations, 1); + config.dkey_length = ptag->getUInt("length", newglobal.dkey_length, 1, 1024); } // Config is valid, apply it @@ -208,7 +206,7 @@ class ModulePBKDF2 : public Module : Module(VF_VENDOR, "Allows other modules to generate PBKDF2 hashes.") { } - + ~ModulePBKDF2() { stdalgo::delete_all(providers); diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp index 8353a5b00..383b2ad07 100644 --- a/src/modules/m_permchannels.cpp +++ b/src/modules/m_permchannels.cpp @@ -198,10 +198,8 @@ public: * Process config-defined list of permanent channels. * -- w00t */ - ConfigTagList permchannels = ServerInstance->Config->ConfTags("permchannels"); - for (ConfigIter i = permchannels.first; i != permchannels.second; ++i) + for (auto& [_, tag] : ServerInstance->Config->ConfTags("permchannels")) { - ConfigTag* tag = i->second; std::string channel = tag->getString("channel"); std::string modes = tag->getString("modes"); diff --git a/src/modules/m_restrictchans.cpp b/src/modules/m_restrictchans.cpp index 6bc2c13dd..f08e806dd 100644 --- a/src/modules/m_restrictchans.cpp +++ b/src/modules/m_restrictchans.cpp @@ -61,12 +61,11 @@ class ModuleRestrictChans : public Module void ReadConfig(ConfigStatus& status) override { AllowChans newallows; - ConfigTagList tags = ServerInstance->Config->ConfTags("allowchannel"); - for (ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, tag] : ServerInstance->Config->ConfTags("allowchannel")) { - const std::string name = i->second->getString("name"); + const std::string name = tag->getString("name"); if (name.empty()) - throw ModuleException("Empty <allowchannel:name> at " + i->second->getTagLocation()); + throw ModuleException("Empty <allowchannel:name> at " + tag->getTagLocation()); newallows.insert(name); } diff --git a/src/modules/m_securelist.cpp b/src/modules/m_securelist.cpp index cb9a04f48..8e74314f9 100644 --- a/src/modules/m_securelist.cpp +++ b/src/modules/m_securelist.cpp @@ -51,13 +51,11 @@ class ModuleSecureList void ReadConfig(ConfigStatus& status) override { AllowList newallows; - - ConfigTagList tags = ServerInstance->Config->ConfTags("securehost"); - for (ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, tag] : ServerInstance->Config->ConfTags("securehost")) { - std::string host = i->second->getString("exception"); + std::string host = tag->getString("exception"); if (host.empty()) - throw ModuleException("<securehost:exception> is a required field at " + i->second->getTagLocation()); + throw ModuleException("<securehost:exception> is a required field at " + tag->getTagLocation()); newallows.push_back(host); } diff --git a/src/modules/m_showfile.cpp b/src/modules/m_showfile.cpp index 64b54ec28..624d6c249 100644 --- a/src/modules/m_showfile.cpp +++ b/src/modules/m_showfile.cpp @@ -150,10 +150,8 @@ class ModuleShowFile : public Module { std::vector<CommandShowFile*> newcmds; - ConfigTagList tags = ServerInstance->Config->ConfTags("showfile"); - for (ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, tag] : ServerInstance->Config->ConfTags("showfile")) { - ConfigTag* tag = i->second; try { ReadTag(tag, newcmds); diff --git a/src/modules/m_spanningtree/override_stats.cpp b/src/modules/m_spanningtree/override_stats.cpp index 78d7ee226..299d1db6e 100644 --- a/src/modules/m_spanningtree/override_stats.cpp +++ b/src/modules/m_spanningtree/override_stats.cpp @@ -47,10 +47,9 @@ ModResult ModuleSpanningTree::OnStats(Stats::Context& stats) } else if (stats.GetSymbol() == 'U') { - ConfigTagList tags = ServerInstance->Config->ConfTags("uline"); - for (ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, tag] : ServerInstance->Config->ConfTags("uline")) { - std::string name = i->second->getString("server"); + std::string name = tag->getString("server"); if (!name.empty()) stats.AddRow(248, 'U', name); } diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index 63baaf706..ce4469a9a 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -242,10 +242,8 @@ void TreeServer::CheckULine() { uline = silentuline = false; - ConfigTagList tags = ServerInstance->Config->ConfTags("uline"); - for (ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, tag] : ServerInstance->Config->ConfTags("uline")) { - ConfigTag* tag = i->second; std::string server = tag->getString("server"); if (irc::equals(server, GetName())) { diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index dd4575445..8c3786aff 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -254,10 +254,9 @@ void SpanningTreeUtilities::ReadConfiguration() AutoconnectBlocks.clear(); LinkBlocks.clear(); - ConfigTagList tags = ServerInstance->Config->ConfTags("link"); - for(ConfigIter i = tags.first; i != tags.second; ++i) + + for (auto& [_, tag] : ServerInstance->Config->ConfTags("link")) { - ConfigTag* tag = i->second; auto L = std::make_shared<Link>(tag); irc::spacesepstream sep = tag->getString("allowmask"); @@ -310,10 +309,8 @@ void SpanningTreeUtilities::ReadConfiguration() LinkBlocks.push_back(L); } - tags = ServerInstance->Config->ConfTags("autoconnect"); - for(ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, tag] : ServerInstance->Config->ConfTags("autoconnect")) { - ConfigTag* tag = i->second; auto A = std::make_shared<Autoconnect>(tag); A->Period = tag->getDuration("period", 60, 1); A->NextConnectTime = ServerInstance->Time() + A->Period; diff --git a/src/modules/m_vhost.cpp b/src/modules/m_vhost.cpp index 3f580029b..2a519f23d 100644 --- a/src/modules/m_vhost.cpp +++ b/src/modules/m_vhost.cpp @@ -98,10 +98,8 @@ class ModuleVHost : public Module void ReadConfig(ConfigStatus& status) override { CustomVhostMap newhosts; - ConfigTagList tags = ServerInstance->Config->ConfTags("vhost"); - for (ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, tag] : ServerInstance->Config->ConfTags("vhost")) { - ConfigTag* tag = i->second; std::string mask = tag->getString("host"); if (mask.empty()) throw ModuleException("<vhost:host> is empty! at " + tag->getTagLocation()); diff --git a/src/modules/m_websocket.cpp b/src/modules/m_websocket.cpp index 31124dede..8fd59fb1c 100644 --- a/src/modules/m_websocket.cpp +++ b/src/modules/m_websocket.cpp @@ -511,14 +511,12 @@ class ModuleWebSocket : public Module void ReadConfig(ConfigStatus& status) override { ConfigTagList tags = ServerInstance->Config->ConfTags("wsorigin"); - if (tags.first == tags.second) + if (tags.empty()) throw ModuleException("You have loaded the websocket module but not configured any allowed origins!"); WebSocketConfig config; - for (ConfigIter i = tags.first; i != tags.second; ++i) + for (auto& [_, tag] : tags) { - ConfigTag* tag = i->second; - // Ensure that we have the <wsorigin:allow> parameter. const std::string allow = tag->getString("allow"); if (allow.empty()) |
