diff options
author | attilamolnar <attilamolnar@hush.com> | 2012-10-06 21:43:20 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2012-11-12 21:48:42 +0100 |
commit | a4db7bf9af00b32d4f5c1922997d02b0b8be59e5 (patch) | |
tree | 2fd4c4ee2344300285f919968760f27f9ca41df4 /src | |
parent | 62149fcd86711d3ca7457a327c4e8fa2e7d85582 (diff) |
Remove usage of the deprecated ConfigReader
Diffstat (limited to 'src')
40 files changed, 191 insertions, 230 deletions
diff --git a/src/modules/extra/m_ldapauth.cpp b/src/modules/extra/m_ldapauth.cpp index f51b41e0b..2102b7492 100644 --- a/src/modules/extra/m_ldapauth.cpp +++ b/src/modules/extra/m_ldapauth.cpp @@ -76,20 +76,20 @@ public: void OnRehash(User* user) { - ConfigReader Conf; + ConfigTag* tag = ServerInstance->Config->ConfValue("ldapauth"); whitelistedcidrs.clear(); requiredattributes.clear(); - base = Conf.ReadValue("ldapauth", "baserdn", 0); - attribute = Conf.ReadValue("ldapauth", "attribute", 0); - ldapserver = Conf.ReadValue("ldapauth", "server", 0); - allowpattern = Conf.ReadValue("ldapauth", "allowpattern", 0); - killreason = Conf.ReadValue("ldapauth", "killreason", 0); - std::string scope = Conf.ReadValue("ldapauth", "searchscope", 0); - username = Conf.ReadValue("ldapauth", "binddn", 0); - password = Conf.ReadValue("ldapauth", "bindauth", 0); - verbose = Conf.ReadFlag("ldapauth", "verbose", 0); /* Set to true if failed connects should be reported to operators */ - useusername = Conf.ReadFlag("ldapauth", "userfield", 0); + base = tag->getString("baserdn"); + attribute = tag->getString("attribute"); + ldapserver = tag->getString("server"); + allowpattern = tag->getString("allowpattern"); + killreason = tag->getString("killreason"); + std::string scope = tag->getString("searchscope"); + username = tag->getString("binddn"); + password = tag->getString("bindauth"); + verbose = tag->getBool("verbose"); /* Set to true if failed connects should be reported to operators */ + useusername = tag->getBool("userfield"); ConfigTagList whitelisttags = ServerInstance->Config->ConfTags("ldapwhitelist"); diff --git a/src/modules/extra/m_ldapoper.cpp b/src/modules/extra/m_ldapoper.cpp index 2166b0823..84a3b8729 100644 --- a/src/modules/extra/m_ldapoper.cpp +++ b/src/modules/extra/m_ldapoper.cpp @@ -61,13 +61,13 @@ public: virtual void OnRehash(User* user) { - ConfigReader Conf; + ConfigTag* tag = ServerInstance->Config->ConfValue("ldapoper"); - base = Conf.ReadValue("ldapoper", "baserdn", 0); - ldapserver = Conf.ReadValue("ldapoper", "server", 0); - std::string scope = Conf.ReadValue("ldapoper", "searchscope", 0); - username = Conf.ReadValue("ldapoper", "binddn", 0); - password = Conf.ReadValue("ldapoper", "bindauth", 0); + base = tag->getString("baserdn"); + ldapserver = tag->getString("server"); + std::string scope = tag->getString("searchscope"); + username = tag->getString("binddn"); + password = tag->getString("bindaut"); if (scope == "base") searchscope = LDAP_SCOPE_BASE; diff --git a/src/modules/extra/m_mssql.cpp b/src/modules/extra/m_mssql.cpp index eca646fcf..27410e95b 100644 --- a/src/modules/extra/m_mssql.cpp +++ b/src/modules/extra/m_mssql.cpp @@ -707,16 +707,17 @@ class ModuleMsSQL : public Module bool HostInConf(const SQLhost &h) { - ConfigReader conf; - for(int i = 0; i < conf.Enumerate("database"); i++) + ConfigTagList tags = ServerInstance->Config->ConfTags("database"); + for (ConfigIter i = tags.first; i != tags.second; ++i) { + ConfigTag* tag = i->second; SQLhost host; - host.id = conf.ReadValue("database", "id", i); - host.host = conf.ReadValue("database", "hostname", i); - host.port = conf.ReadInteger("database", "port", "1433", i, true); - host.name = conf.ReadValue("database", "name", i); - host.user = conf.ReadValue("database", "username", i); - host.pass = conf.ReadValue("database", "password", i); + host.id = tag->getString("id"); + host.host = tag->getString("hostname"); + host.port = tag->getInt("port", 1433); + host.name = tag->getString("name"); + host.user = tag->getString("username"); + host.pass = tag->getString("password"); if (h == host) return true; } @@ -727,17 +728,18 @@ class ModuleMsSQL : public Module { ClearOldConnections(); - ConfigReader conf; - for(int i = 0; i < conf.Enumerate("database"); i++) + ConfigTagList tags = ServerInstance->Config->ConfTags("database"); + for (ConfigIter i = tags.first; i != tags.second; ++i) { + ConfigTag* tag = i->second; SQLhost host; - host.id = conf.ReadValue("database", "id", i); - host.host = conf.ReadValue("database", "hostname", i); - host.port = conf.ReadInteger("database", "port", "1433", i, true); - host.name = conf.ReadValue("database", "name", i); - host.user = conf.ReadValue("database", "username", i); - host.pass = conf.ReadValue("database", "password", i); + host.id = tag->getString("id"); + host.host = tag->getString("hostname"); + host.port = tag->getInt("port", 1433); + host.name = tag->getString("name"); + host.user = tag->getString("username"); + host.pass = tag->getString("password"); if (HasHost(host)) continue; diff --git a/src/modules/extra/m_regex_posix.cpp b/src/modules/extra/m_regex_posix.cpp index 6e837bcb6..e3e436bd6 100644 --- a/src/modules/extra/m_regex_posix.cpp +++ b/src/modules/extra/m_regex_posix.cpp @@ -107,8 +107,7 @@ public: void OnRehash(User* u) { - ConfigReader Conf; - ref.extended = Conf.ReadFlag("posix", "extended", 0); + ref.extended = ServerInstance->Config->ConfValue("posix")->getBool("extended"); } }; diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index 686938eb4..6e06af74a 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -74,11 +74,9 @@ class ModuleAlias : public Module virtual void ReadAliases() { - ConfigReader MyConf; - - AllowBots = MyConf.ReadFlag("fantasy", "allowbots", "no", 0); - - std::string fpre = MyConf.ReadValue("fantasy","prefix",0); + ConfigTag* fantasy = ServerInstance->Config->ConfValue("fantasy"); + AllowBots = fantasy->getBool("allowbots", false); + std::string fpre = fantasy->getString("prefix", "!"); fprefix = fpre.empty() ? '!' : fpre[0]; Aliases.clear(); diff --git a/src/modules/m_blockamsg.cpp b/src/modules/m_blockamsg.cpp index c570e0a71..865626f87 100644 --- a/src/modules/m_blockamsg.cpp +++ b/src/modules/m_blockamsg.cpp @@ -75,14 +75,9 @@ class ModuleBlockAmsg : public Module virtual void OnRehash(User* user) { - ConfigReader Conf; - - ForgetDelay = Conf.ReadInteger("blockamsg", "delay", 0, false); - - if(Conf.GetError() == CONF_VALUE_NOT_FOUND) - ForgetDelay = -1; - - std::string act = Conf.ReadValue("blockamsg", "action", 0); + ConfigTag* tag = ServerInstance->Config->ConfValue("blockamsg"); + ForgetDelay = tag->getInt("delay", -1); + std::string act = tag->getString("action"); if(act == "notice") action = IBLOCK_NOTICE; diff --git a/src/modules/m_blockcaps.cpp b/src/modules/m_blockcaps.cpp index 1530a85e0..4c19ef0a7 100644 --- a/src/modules/m_blockcaps.cpp +++ b/src/modules/m_blockcaps.cpp @@ -109,12 +109,10 @@ public: void ReadConf() { - ConfigReader Conf; - percent = Conf.ReadInteger("blockcaps", "percent", "100", 0, true); - minlen = Conf.ReadInteger("blockcaps", "minlen", "1", 0, true); - std::string hmap = Conf.ReadValue("blockcaps", "capsmap", 0); - if (hmap.empty()) - hmap = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + ConfigTag* tag = ServerInstance->Config->ConfValue("blockcaps"); + percent = tag->getInt("percent", 100); + minlen = tag->getInt("minlen", 1); + std::string hmap = tag->getString("capsmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); memset(capsmap, 0, sizeof(capsmap)); for (std::string::iterator n = hmap.begin(); n != hmap.end(); n++) capsmap[(unsigned char)*n] = 1; diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index f24c38b65..e28a4084b 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -412,11 +412,11 @@ public: virtual void OnRehash(User* user) { - ConfigReader Conf; - cmd.maxaccepts = Conf.ReadInteger("callerid", "maxaccepts", "16", 0, true); - operoverride = Conf.ReadFlag("callerid", "operoverride", "0", 0); - tracknick = Conf.ReadFlag("callerid", "tracknick", "0", 0); - notify_cooldown = Conf.ReadInteger("callerid", "cooldown", "60", 0, true); + ConfigTag* tag = ServerInstance->Config->ConfValue("callerid"); + cmd.maxaccepts = tag->getInt("maxaccepts", 16); + operoverride = tag->getBool("operoverride"); + tracknick = tag->getBool("tracknick"); + notify_cooldown = tag->getInt("cooldown", 60); } }; diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp index bbf061f7e..03a211ad8 100644 --- a/src/modules/m_censor.cpp +++ b/src/modules/m_censor.cpp @@ -123,14 +123,15 @@ class ModuleCensor : public Module * reload our config file on rehash - we must destroy and re-allocate the classes * to call the constructor again and re-read our data. */ - ConfigReader MyConf; censors.clear(); - for (int index = 0; index < MyConf.Enumerate("badword"); index++) + ConfigTagList badwords = ServerInstance->Config->ConfTags("badword"); + for (ConfigIter i = badwords.first; i != badwords.second; ++i) { - std::string str = MyConf.ReadValue("badword","text",index); + ConfigTag* tag = i->second; + std::string str = tag->getString("text"); irc::string pattern(str.c_str()); - str = MyConf.ReadValue("badword","replace",index); + str = tag->getString("replace"); censors[pattern] = irc::string(str.c_str()); } } diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp index c899d7a4b..95fd9b3e1 100644 --- a/src/modules/m_chanfilter.cpp +++ b/src/modules/m_chanfilter.cpp @@ -88,8 +88,7 @@ class ModuleChanFilter : public Module virtual void OnRehash(User* user) { - ConfigReader Conf; - hidemask = Conf.ReadFlag("chanfilter", "hidemask", 0); + hidemask = ServerInstance->Config->ConfValue("chanfilter")->getBool("hidemask"); cf.DoRehash(); } diff --git a/src/modules/m_chanlog.cpp b/src/modules/m_chanlog.cpp index 29385b8e2..d7d074b3a 100644 --- a/src/modules/m_chanlog.cpp +++ b/src/modules/m_chanlog.cpp @@ -45,16 +45,16 @@ class ModuleChanLog : public Module virtual void OnRehash(User *user) { - ConfigReader MyConf; std::string snomasks; std::string channel; logstreams.clear(); - for (int i = 0; i < MyConf.Enumerate("chanlog"); i++) + ConfigTagList tags = ServerInstance->Config->ConfTags("chanlog"); + for (ConfigIter i = tags.first; i != tags.second; ++i) { - channel = MyConf.ReadValue("chanlog", "channel", i); - snomasks = MyConf.ReadValue("chanlog", "snomasks", i); + channel = i->second->getString("channel"); + snomasks = i->second->getString("snomasks"); if (channel.empty() || snomasks.empty()) { diff --git a/src/modules/m_channames.cpp b/src/modules/m_channames.cpp index 92774edff..49fd7af7b 100644 --- a/src/modules/m_channames.cpp +++ b/src/modules/m_channames.cpp @@ -95,9 +95,9 @@ class ModuleChannelNames : public Module virtual void OnRehash(User* user) { - ConfigReader Conf; - std::string denyToken = Conf.ReadValue("channames", "denyrange", 0); - std::string allowToken = Conf.ReadValue("channames", "allowrange", 0); + ConfigTag* tag = ServerInstance->Config->ConfValue("channames"); + std::string denyToken = tag->getString("denyrange"); + std::string allowToken = tag->getString("allowrange"); allowedmap.set(); irc::portparser denyrange(denyToken, false); diff --git a/src/modules/m_chanprotect.cpp b/src/modules/m_chanprotect.cpp index 2a46f2f17..85405ec25 100644 --- a/src/modules/m_chanprotect.cpp +++ b/src/modules/m_chanprotect.cpp @@ -260,14 +260,14 @@ class ModuleChanProtect : public Module void LoadSettings() { - ConfigReader Conf; + ConfigTag* tag = ServerInstance->Config->ConfValue("chanprotect"); - settings.FirstInGetsFounder = Conf.ReadFlag("chanprotect", "noservices", 0); + settings.FirstInGetsFounder = tag->getBool("noservices"); - std::string qpre = Conf.ReadValue("chanprotect", "qprefix", 0); + std::string qpre = tag->getString("qprefix"); char QPrefix = qpre.empty() ? 0 : qpre[0]; - std::string apre = Conf.ReadValue("chanprotect", "aprefix", 0); + std::string apre = tag->getString("aprefix"); char APrefix = apre.empty() ? 0 : apre[0]; if ((APrefix && QPrefix) && APrefix == QPrefix) @@ -284,8 +284,8 @@ class ModuleChanProtect : public Module cp.setPrefix(APrefix); cf.setPrefix(QPrefix); } - settings.DeprivSelf = Conf.ReadFlag("chanprotect","deprotectself", "yes", 0); - settings.DeprivOthers = Conf.ReadFlag("chanprotect","deprotectothers", "yes", 0); + settings.DeprivSelf = tag->getBool("deprotectself", true); + settings.DeprivOthers = tag->getBool("deprotectothers", true); } ModResult OnUserPreJoin(User *user, Channel *chan, const char *cname, std::string &privs, const std::string &keygiven) diff --git a/src/modules/m_chghost.cpp b/src/modules/m_chghost.cpp index 6991814f6..b259bea8e 100644 --- a/src/modules/m_chghost.cpp +++ b/src/modules/m_chghost.cpp @@ -102,11 +102,7 @@ class ModuleChgHost : public Module void OnRehash(User* user) { - ConfigReader Conf; - std::string hmap = Conf.ReadValue("hostname", "charmap", 0); - - if (hmap.empty()) - hmap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789"; + std::string hmap = ServerInstance->Config->ConfValue("hostname")->getString("charmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789"); memset(hostmap, 0, sizeof(hostmap)); for (std::string::iterator n = hmap.begin(); n != hmap.end(); n++) diff --git a/src/modules/m_conn_waitpong.cpp b/src/modules/m_conn_waitpong.cpp index 764246e84..50aeffd0a 100644 --- a/src/modules/m_conn_waitpong.cpp +++ b/src/modules/m_conn_waitpong.cpp @@ -44,17 +44,9 @@ class ModuleWaitPong : public Module void OnRehash(User* user) { - ConfigReader Conf; - - sendsnotice = Conf.ReadFlag("waitpong", "sendsnotice", 0); - - if(Conf.GetError() == CONF_VALUE_NOT_FOUND) - sendsnotice = true; - - killonbadreply = Conf.ReadFlag("waitpong", "killonbadreply", 0); - - if(Conf.GetError() == CONF_VALUE_NOT_FOUND) - killonbadreply = true; + ConfigTag* tag = ServerInstance->Config->ConfValue("waitpong"); + sendsnotice = tag->getBool("sendsnotice", true); + killonbadreply = tag->getBool("killonbadreply", true); } ModResult OnUserRegister(LocalUser* user) diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp index aebe9a4ca..6ba7f53a9 100644 --- a/src/modules/m_connectban.cpp +++ b/src/modules/m_connectban.cpp @@ -48,28 +48,23 @@ class ModuleConnectBan : public Module virtual void OnRehash(User* user) { - ConfigReader Conf; - std::string duration; + ConfigTag* tag = ServerInstance->Config->ConfValue("connectban"); - ipv4_cidr = Conf.ReadInteger("connectban", "ipv4cidr", 0, true); + ipv4_cidr = tag->getInt("ipv4cidr", 32); if (ipv4_cidr == 0) ipv4_cidr = 32; - ipv6_cidr = Conf.ReadInteger("connectban", "ipv6cidr", 0, true); + ipv6_cidr = tag->getInt("ipv6cidr", 128); if (ipv6_cidr == 0) ipv6_cidr = 128; - threshold = Conf.ReadInteger("connectban", "threshold", 0, true); - + threshold = tag->getInt("threshold", 10); if (threshold == 0) threshold = 10; - duration = Conf.ReadValue("connectban", "duration", 0, true); - - if (duration.empty()) - duration = "10m"; - - banduration = ServerInstance->Duration(duration); + banduration = ServerInstance->Duration(tag->getString("duration", "10m")); + if (banduration == 0) + banduration = 10*60; } virtual void OnUserConnect(LocalUser *u) diff --git a/src/modules/m_connflood.cpp b/src/modules/m_connflood.cpp index 9d7c9cb2c..71516063b 100644 --- a/src/modules/m_connflood.cpp +++ b/src/modules/m_connflood.cpp @@ -50,15 +50,15 @@ public: void InitConf() { /* read configuration variables */ - ConfigReader conf; + ConfigTag* tag = ServerInstance->Config->ConfValue("connflood"); /* throttle configuration */ - seconds = conf.ReadInteger("connflood", "seconds", 0, true); - maxconns = conf.ReadInteger("connflood", "maxconns", 0, true); - timeout = conf.ReadInteger("connflood", "timeout", 0, true); - quitmsg = conf.ReadValue("connflood", "quitmsg", 0); + seconds = tag->getInt("seconds"); + maxconns = tag->getInt("maxconns"); + timeout = tag->getInt("timeout"); + quitmsg = tag->getString("quitmsg"); /* seconds to wait when the server just booted */ - boot_wait = conf.ReadInteger("connflood", "bootwait", 0, true); + boot_wait = tag->getInt("bootwait"); first = ServerInstance->Time(); } diff --git a/src/modules/m_customtitle.cpp b/src/modules/m_customtitle.cpp index fd5ec6f09..a9704e7de 100644 --- a/src/modules/m_customtitle.cpp +++ b/src/modules/m_customtitle.cpp @@ -58,15 +58,15 @@ class CommandTitle : public Command snprintf(TheHost,MAXBUF,"%s@%s",user->ident.c_str(), user->host.c_str()); snprintf(TheIP, MAXBUF,"%s@%s",user->ident.c_str(), user->GetIPString()); - ConfigReader Conf; - for (int i=0; i<Conf.Enumerate("title"); i++) + ConfigTagList tags = ServerInstance->Config->ConfTags("title"); + for (ConfigIter i = tags.first; i != tags.second; ++i) { - std::string Name = Conf.ReadValue("title", "name", "", i); - std::string pass = Conf.ReadValue("title", "password", "", i); - std::string hash = Conf.ReadValue("title", "hash", "", i); - std::string host = Conf.ReadValue("title", "host", "*@*", i); - std::string title = Conf.ReadValue("title", "title", "", i); - std::string vhost = Conf.ReadValue("title", "vhost", "", i); + std::string Name = i->second->getString("name"); + std::string pass = i->second->getString("password"); + std::string hash = i->second->getString("hash"); + std::string host = i->second->getString("host", "*@*"); + std::string title = i->second->getString("title"); + std::string vhost = i->second->getString("vhost"); if (!strcmp(Name.c_str(),parameters[0].c_str()) && !ServerInstance->PassCompare(user, pass.c_str(), parameters[1].c_str(), hash.c_str()) && OneOfMatches(TheHost,TheIP,host.c_str()) && !title.empty()) { diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index 10b1b98ac..3b0467ae5 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -150,8 +150,7 @@ class CommandDccallow : public Command } std::string mask = target->nick+"!"+target->ident+"@"+target->dhost; - ConfigReader Conf; - std::string default_length = Conf.ReadValue("dccallow", "length", 0); + std::string default_length = ServerInstance->Config->ConfValue("dccallow")->getString("length"); long length; if (parameters.size() < 2) @@ -334,12 +333,12 @@ class ModuleDCCAllow : public Module irc::string type = tokens[1].c_str(); - ConfigReader Conf; - bool blockchat = Conf.ReadFlag("dccallow", "blockchat", 0); + ConfigTag* conftag = ServerInstance->Config->ConfValue("dccallow"); + bool blockchat = conftag->getBool("blockchat"); if (type == "SEND") { - std::string defaultaction = Conf.ReadValue("dccallow", "action", 0); + std::string defaultaction = conftag->getString("action"); std::string filename = tokens[2]; bool found = false; @@ -461,18 +460,15 @@ class ModuleDCCAllow : public Module void ReadFileConf() { - ConfigReader Conf; bfl.clear(); - for (int i = 0; i < Conf.Enumerate("banfile"); i++) + ConfigTagList tags = ServerInstance->Config->ConfTags("banfile"); + for (ConfigIter i = tags.first; i != tags.second; ++i) { BannedFileList bf; - std::string fileglob = Conf.ReadValue("banfile", "pattern", i); - std::string action = Conf.ReadValue("banfile", "action", i); - bf.filemask = fileglob; - bf.action = action; + bf.filemask = i->second->getString("pattern"); + bf.action = i->second->getString("action"); bfl.push_back(bf); } - } virtual ~ModuleDCCAllow() diff --git a/src/modules/m_deaf.cpp b/src/modules/m_deaf.cpp index 3e0d205ba..958abcdd4 100644 --- a/src/modules/m_deaf.cpp +++ b/src/modules/m_deaf.cpp @@ -75,9 +75,9 @@ class ModuleDeaf : public Module virtual void OnRehash(User* user) { - ConfigReader conf; - deaf_bypasschars = conf.ReadValue("deaf", "bypasschars", 0); - deaf_bypasschars_uline = conf.ReadValue("deaf", "bypasscharsuline", 0); + ConfigTag* tag = ServerInstance->Config->ConfValue("deaf"); + deaf_bypasschars = tag->getString("bypasschars"); + deaf_bypasschars_uline = tag->getString("bypasscharsuline"); } virtual ModResult OnUserPreNotice(User* user,void* dest,int target_type, std::string &text, char status, CUList &exempt_list) diff --git a/src/modules/m_denychans.cpp b/src/modules/m_denychans.cpp index d4dcdec5a..c280174f5 100644 --- a/src/modules/m_denychans.cpp +++ b/src/modules/m_denychans.cpp @@ -34,12 +34,12 @@ class ModuleDenyChannels : public Module virtual void OnRehash(User* user) { - ConfigReader Conf; /* check for redirect validity and loops/chains */ - for (int i =0; i < Conf.Enumerate("badchan"); i++) + ConfigTagList tags = ServerInstance->Config->ConfTags("badchan"); + for (ConfigIter i = tags.first; i != tags.second; ++i) { - std::string name = Conf.ReadValue("badchan","name",i); - std::string redirect = Conf.ReadValue("badchan","redirect",i); + std::string name = i->second->getString("name"); + std::string redirect = i->second->getString("redirect"); if (!redirect.empty()) { @@ -51,14 +51,15 @@ class ModuleDenyChannels : public Module throw ModuleException("Invalid badchan redirect, not a channel"); } - for (int j =0; j < Conf.Enumerate("badchan"); j++) + for (ConfigIter j = tags.first; j != tags.second; ++j) { - if (InspIRCd::Match(redirect, Conf.ReadValue("badchan","name",j))) + if (InspIRCd::Match(redirect, j->second->getString("name"))) { bool goodchan = false; - for (int k =0; k < Conf.Enumerate("goodchan"); k++) + ConfigTagList goodchans = ServerInstance->Config->ConfTags("badchan"); + for (ConfigIter k = goodchans.first; k != goodchans.second; ++k) { - if (InspIRCd::Match(redirect, Conf.ReadValue("goodchan","name",k))) + if (InspIRCd::Match(redirect, k->second->getString("name"))) goodchan = true; } @@ -87,23 +88,24 @@ class ModuleDenyChannels : public Module virtual ModResult OnUserPreJoin(User* user, Channel* chan, const char* cname, std::string &privs, const std::string &keygiven) { - ConfigReader Conf; - for (int j =0; j < Conf.Enumerate("badchan"); j++) + ConfigTagList tags = ServerInstance->Config->ConfTags("badchan"); + for (ConfigIter j = tags.first; j != tags.second; ++j) { - if (InspIRCd::Match(cname, Conf.ReadValue("badchan","name",j))) + if (InspIRCd::Match(cname, j->second->getString("name"))) { - if (IS_OPER(user) && Conf.ReadFlag("badchan","allowopers",j)) + if (IS_OPER(user) && j->second->getBool("allowopers")) { return MOD_RES_PASSTHRU; } else { - std::string reason = Conf.ReadValue("badchan","reason",j); - std::string redirect = Conf.ReadValue("badchan","redirect",j); + std::string reason = j->second->getString("reason"); + std::string redirect = j->second->getString("redirect"); - for (int i = 0; i < Conf.Enumerate("goodchan"); i++) + ConfigTagList goodchans = ServerInstance->Config->ConfTags("goodchan"); + for (ConfigIter i = goodchans.first; i != goodchans.second; ++i) { - if (InspIRCd::Match(cname, Conf.ReadValue("goodchan", "name", i))) + if (InspIRCd::Match(cname, i->second->getString("name"))) { return MOD_RES_PASSTHRU; } diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index 6105fe024..683db179a 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -192,7 +192,7 @@ class ModuleFilter : public Module ModResult OnStats(char symbol, User* user, string_list &results); ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *user, bool validated, const std::string &original_line); bool AppliesToMe(User* user, FilterResult* filter, int flags); - void ReadFilters(ConfigReader &MyConf); + void ReadFilters(); static bool StringToFilterAction(const std::string& str, FilterAction& fa); static std::string FilterActionToString(FilterAction fa); }; @@ -449,15 +449,15 @@ ModResult ModuleFilter::OnPreCommand(std::string &command, std::vector<std::stri void ModuleFilter::OnRehash(User* user) { - ConfigReader MyConf; + ConfigTagList tags = ServerInstance->Config->ConfTags("exemptfromfilter"); exemptfromfilter.clear(); - for (int index = 0; index < MyConf.Enumerate("exemptfromfilter"); ++index) + for (ConfigIter i = tags.first; i != tags.second; ++i) { - std::string chan = MyConf.ReadValue("exemptfromfilter", "channel", index); + std::string chan = i->second->getString("channel"); if (!chan.empty()) exemptfromfilter.insert(chan); } - std::string newrxengine = "regex/" + MyConf.ReadValue("filteropts", "engine", 0); + std::string newrxengine = "regex/" + ServerInstance->Config->ConfValue("filteropts")->getString("engine"); if (newrxengine == "regex/") newrxengine = "regex"; if (RegexEngine.GetProvider() == newrxengine) @@ -471,7 +471,7 @@ void ModuleFilter::OnRehash(User* user) { ServerInstance->SNO->WriteGlobalSno('a', "WARNING: Regex engine '%s' is not loaded - Filter functionality disabled until this is corrected.", newrxengine.c_str()); } - ReadFilters(MyConf); + ReadFilters(); } Version ModuleFilter::GetVersion() @@ -650,17 +650,18 @@ std::string ModuleFilter::FilterActionToString(FilterAction fa) } } -void ModuleFilter::ReadFilters(ConfigReader &MyConf) +void ModuleFilter::ReadFilters() { - for (int index = 0; index < MyConf.Enumerate("keyword"); index++) + ConfigTagList tags = ServerInstance->Config->ConfTags("keyword"); + for (ConfigIter i = tags.first; i != tags.second; ++i) { - this->DeleteFilter(MyConf.ReadValue("keyword", "pattern", index)); + std::string pattern = i->second->getString("pattern"); + this->DeleteFilter(pattern); - std::string pattern = MyConf.ReadValue("keyword", "pattern", index); - std::string reason = MyConf.ReadValue("keyword", "reason", index); - std::string action = MyConf.ReadValue("keyword", "action", index); - std::string flgs = MyConf.ReadValue("keyword", "flags", index); - long gline_time = ServerInstance->Duration(MyConf.ReadValue("keyword", "duration", index)); + std::string reason = i->second->getString("reason"); + std::string action = i->second->getString("action"); + std::string flgs = i->second->getString("flags"); + long gline_time = ServerInstance->Duration(i->second->getString("duration")); if (flgs.empty()) flgs = "*"; diff --git a/src/modules/m_hidechans.cpp b/src/modules/m_hidechans.cpp index 9c582551b..023189748 100644 --- a/src/modules/m_hidechans.cpp +++ b/src/modules/m_hidechans.cpp @@ -55,8 +55,7 @@ class ModuleHideChans : public Module virtual void OnRehash(User* user) { - ConfigReader conf; - AffectsOpers = conf.ReadFlag("hidechans", "affectsopers", 0); + AffectsOpers = ServerInstance->Config->ConfValue("hidechans")->getBool("affectsopers"); } ModResult OnWhoisLine(User* user, User* dest, int &numeric, std::string &text) diff --git a/src/modules/m_hostchange.cpp b/src/modules/m_hostchange.cpp index 6efa9974b..508171c96 100644 --- a/src/modules/m_hostchange.cpp +++ b/src/modules/m_hostchange.cpp @@ -63,10 +63,10 @@ class ModuleHostChange : public Module virtual void OnRehash(User* user) { - ConfigReader Conf; - MySuffix = Conf.ReadValue("host","suffix",0); - MyPrefix = Conf.ReadValue("host","prefix","",0); - MySeparator = Conf.ReadValue("host","separator",".",0); + ConfigTag* host = ServerInstance->Config->ConfValue("host"); + MySuffix = host->getString("suffix"); + MyPrefix = host->getString("prefix"); + MySeparator = host->getString("separator", "."); hostchanges.clear(); std::set<std::string> dupecheck; diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index 460b81023..35084fd45 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -289,9 +289,7 @@ class ModuleIdent : public Module virtual void OnRehash(User *user) { - ConfigReader Conf; - - RequestTimeout = Conf.ReadInteger("ident", "timeout", 0, true); + RequestTimeout = ServerInstance->Config->ConfValue("ident")->getInt("timeout", 5); if (!RequestTimeout) RequestTimeout = 5; } diff --git a/src/modules/m_maphide.cpp b/src/modules/m_maphide.cpp index b78cd2c7e..f3f472519 100644 --- a/src/modules/m_maphide.cpp +++ b/src/modules/m_maphide.cpp @@ -34,8 +34,7 @@ class ModuleMapHide : public Module void OnRehash(User* user) { - ConfigReader MyConf; - url = MyConf.ReadValue("security", "maphide", 0); + url = ServerInstance->Config->ConfValue("security")->getString("maphide"); } ModResult OnPreCommand(std::string &command, std::vector<std::string> ¶meters, LocalUser *user, bool validated, const std::string &original_line) diff --git a/src/modules/m_nationalchars.cpp b/src/modules/m_nationalchars.cpp index 1cd21420c..c59c1ba2a 100644 --- a/src/modules/m_nationalchars.cpp +++ b/src/modules/m_nationalchars.cpp @@ -252,14 +252,14 @@ class ModuleNationalChars : public Module virtual void OnRehash(User* user) { - ConfigReader conf; - charset = conf.ReadValue("nationalchars", "file", 0); - casemapping = conf.ReadValue("nationalchars", "casemapping", charset, 0, false); + ConfigTag* tag = ServerInstance->Config->ConfValue("nationalchars"); + charset = tag->getString("file"); + casemapping = tag->getString("casemapping", charset); if(charset[0] != '/') charset.insert(0, "../locales/"); unsigned char * tables[8] = { m_additional, m_additionalMB, m_additionalUp, m_lower, m_upper, m_additionalUtf8, m_additionalUtf8range, m_additionalUtf8interval }; loadtables(charset, tables, 8, 5); - forcequit = conf.ReadFlag("nationalchars", "forcequit", 0); + forcequit = tag->getBool("forcequit"); CheckForceQuit("National character set changed"); } diff --git a/src/modules/m_nonicks.cpp b/src/modules/m_nonicks.cpp index f5c404682..4fa717d73 100644 --- a/src/modules/m_nonicks.cpp +++ b/src/modules/m_nonicks.cpp @@ -91,8 +91,7 @@ class ModuleNoNickChange : public Module virtual void OnRehash(User* user) { - ConfigReader Conf; - override = Conf.ReadFlag("nonicks", "operoverride", "no", 0); + override = ServerInstance->Config->ConfValue("nonicks")->getBool("operoverride", false); } }; diff --git a/src/modules/m_operjoin.cpp b/src/modules/m_operjoin.cpp index af787b815..b717ac3ef 100644 --- a/src/modules/m_operjoin.cpp +++ b/src/modules/m_operjoin.cpp @@ -63,10 +63,10 @@ class ModuleOperjoin : public Module virtual void OnRehash(User* user) { - ConfigReader conf; + ConfigTag* tag = ServerInstance->Config->ConfValue("operjoin"); - operChan = conf.ReadValue("operjoin", "channel", 0); - override = conf.ReadFlag("operjoin", "override", "0", 0); + operChan = tag->getString("channel"); + override = tag->getBool("override", false); operChans.clear(); if (!operChan.empty()) tokenize(operChan,operChans); diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp index bbd1c4e51..c7b365790 100644 --- a/src/modules/m_override.cpp +++ b/src/modules/m_override.cpp @@ -46,12 +46,10 @@ class ModuleOverride : public Module void OnRehash(User* user) { - // on a rehash we delete our classes for good measure and create them again. - ConfigReader Conf; - // re-read our config options on a rehash - NoisyOverride = Conf.ReadFlag("override", "noisy", 0); - RequireKey = Conf.ReadFlag("override", "requirekey", 0); + ConfigTag* tag = ServerInstance->Config->ConfValue("override"); + NoisyOverride = tag->getBool("noisy"); + RequireKey = tag->getBool("requirekey"); } void On005Numeric(std::string &output) diff --git a/src/modules/m_passforward.cpp b/src/modules/m_passforward.cpp index fb7bae234..047992d12 100644 --- a/src/modules/m_passforward.cpp +++ b/src/modules/m_passforward.cpp @@ -41,10 +41,10 @@ class ModulePassForward : public Module void OnRehash(User* user) { - ConfigReader Conf; - nickrequired = Conf.ReadValue("passforward", "nick", "NickServ", 0); - forwardmsg = Conf.ReadValue("passforward", "forwardmsg", "NOTICE $nick :*** Forwarding PASS to $nickrequired", 0); - forwardcmd = Conf.ReadValue("passforward", "cmd", "PRIVMSG $nickrequired :IDENTIFY $pass", 0); + ConfigTag* tag = ServerInstance->Config->ConfValue("passforward"); + nickrequired = tag->getString("nick", "NickServ"); + forwardmsg = tag->getString("forwardmsg", "NOTICE $nick :*** Forwarding PASS to $nickrequired"); + forwardcmd = tag->getString("cmd", "PRIVMSG $nickrequired :IDENTIFY $pass"); } void FormatStr(std::string& result, const std::string& format, const LocalUser* user) diff --git a/src/modules/m_remove.cpp b/src/modules/m_remove.cpp index 454780d03..7d0ae7eea 100644 --- a/src/modules/m_remove.cpp +++ b/src/modules/m_remove.cpp @@ -219,8 +219,7 @@ class ModuleRemove : public Module virtual void OnRehash(User* user) { - ConfigReader conf; - supportnokicks = conf.ReadFlag("remove", "supportnokicks", 0); + supportnokicks = ServerInstance->Config->ConfValue("remove")->getBool("supportnokicks"); } virtual ~ModuleRemove() diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp index 41d2bb274..43cd31a2d 100644 --- a/src/modules/m_rline.cpp +++ b/src/modules/m_rline.cpp @@ -263,11 +263,11 @@ class ModuleRLine : public Module virtual void OnRehash(User *user) { - ConfigReader Conf; + ConfigTag* tag = ServerInstance->Config->ConfValue("rline"); - MatchOnNickChange = Conf.ReadFlag("rline", "matchonnickchange", 0); - ZlineOnMatch = Conf.ReadFlag("rline", "zlineonmatch", 0); - std::string newrxengine = Conf.ReadValue("rline", "engine", 0); + MatchOnNickChange = tag->getBool("matchonnickchange"); + ZlineOnMatch = tag->getBool("zlineonmatch"); + std::string newrxengine = tag->getString("engine"); if (newrxengine.empty()) rxfactory.SetProvider("regex"); diff --git a/src/modules/m_securelist.cpp b/src/modules/m_securelist.cpp index c13e1a892..e04a61e9e 100644 --- a/src/modules/m_securelist.cpp +++ b/src/modules/m_securelist.cpp @@ -46,13 +46,13 @@ class ModuleSecureList : public Module void OnRehash(User* user) { - ConfigReader MyConf; allowlist.clear(); - for (int i = 0; i < MyConf.Enumerate("securehost"); i++) - allowlist.push_back(MyConf.ReadValue("securehost", "exception", i)); + ConfigTagList tags = ServerInstance->Config->ConfTags("securehost"); + for (ConfigIter i = tags.first; i != tags.second; ++i) + allowlist.push_back(i->second->getString("exception")); - WaitTime = MyConf.ReadInteger("securelist", "waittime", "60", 0, true); + WaitTime = ServerInstance->Config->ConfValue("securelist")->getInt("waittime", 60); } diff --git a/src/modules/m_sethost.cpp b/src/modules/m_sethost.cpp index ae0cc7c56..907649158 100644 --- a/src/modules/m_sethost.cpp +++ b/src/modules/m_sethost.cpp @@ -86,11 +86,7 @@ class ModuleSetHost : public Module void OnRehash(User* user) { - ConfigReader Conf; - std::string hmap = Conf.ReadValue("hostname", "charmap", 0); - - if (hmap.empty()) - hmap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789"; + std::string hmap = ServerInstance->Config->ConfValue("hostname")->getString("charmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-_/0123456789"); memset(hostmap, 0, sizeof(hostmap)); for (std::string::iterator n = hmap.begin(); n != hmap.end(); n++) diff --git a/src/modules/m_showwhois.cpp b/src/modules/m_showwhois.cpp index d81dd553d..3b2ea7de9 100644 --- a/src/modules/m_showwhois.cpp +++ b/src/modules/m_showwhois.cpp @@ -76,9 +76,10 @@ class ModuleShowwhois : public Module ModuleShowwhois() : cmd(this) { - ConfigReader conf; - bool OpersOnly = conf.ReadFlag("showwhois", "opersonly", "yes", 0); - ShowWhoisFromOpers = conf.ReadFlag("showwhois", "showfromopers", "yes", 0); + ConfigTag* tag = ServerInstance->Config->ConfValue("showwhois"); + + bool OpersOnly = tag->getBool("opersonly", true); + ShowWhoisFromOpers = tag->getBool("showfromopers", true); sw = new SeeWhois(this, OpersOnly); if (!ServerInstance->Modes->AddMode(sw)) diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index 7e84b8fda..096d2f9ee 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -214,8 +214,8 @@ class ModuleShun : public Module virtual void OnRehash(User* user) { - ConfigReader MyConf; - std::string cmds = MyConf.ReadValue("shun", "enabledcommands", 0); + ConfigTag* tag = ServerInstance->Config->ConfValue("shun"); + std::string cmds = tag->getString("enabledcommands"); std::transform(cmds.begin(), cmds.end(), cmds.begin(), ::toupper); if (cmds.empty()) @@ -231,8 +231,8 @@ class ModuleShun : public Module ShunEnabledCommands.insert(thiscmd); } - NotifyOfShun = MyConf.ReadFlag("shun", "notifyuser", "yes", 0); - affectopers = MyConf.ReadFlag("shun", "affectopers", "no", 0); + NotifyOfShun = tag->getBool("notifyuser", true); + affectopers = tag->getBool("affectopers", false); } virtual ModResult OnPreCommand(std::string &command, std::vector<std::string>& parameters, LocalUser* user, bool validated, const std::string &original_line) diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp index 81e4bc3d8..d56ee145d 100644 --- a/src/modules/m_silence.cpp +++ b/src/modules/m_silence.cpp @@ -310,8 +310,7 @@ class ModuleSilence : public Module void OnRehash(User* user) { - ConfigReader Conf; - maxsilence = Conf.ReadInteger("silence", "maxentries", 0, true); + maxsilence = ServerInstance->Config->ConfValue("showwhois")->getInt("maxentries", 32); if (!maxsilence) maxsilence = 32; } diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 471026887..cc1c400db 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -327,16 +327,16 @@ void SpanningTreeUtilities::RefreshIPCache() void SpanningTreeUtilities::ReadConfiguration() { - ConfigReader Conf; - - FlatLinks = Conf.ReadFlag("security","flatlinks",0); - HideULines = Conf.ReadFlag("security","hideulines",0); - AnnounceTSChange = Conf.ReadFlag("options","announcets",0); - AllowOptCommon = Conf.ReadFlag("options", "allowmismatch", 0); - ChallengeResponse = !Conf.ReadFlag("security", "disablehmac", 0); - quiet_bursts = Conf.ReadFlag("performance", "quietbursts", 0); - PingWarnTime = Conf.ReadInteger("options", "pingwarning", 0, true); - PingFreq = Conf.ReadInteger("options", "serverpingfreq", 0, true); + ConfigTag* security = ServerInstance->Config->ConfValue("security"); + ConfigTag* options = ServerInstance->Config->ConfValue("options"); + FlatLinks = security->getBool("flatlinks"); + HideULines = security->getBool("hideulines"); + AnnounceTSChange = options->getBool("announcets"); + AllowOptCommon = options->getBool("allowmismatch"); + ChallengeResponse = !security->getBool("disablehmac"); + quiet_bursts = ServerInstance->Config->ConfValue("performance")->getBool("quietbursts"); + PingWarnTime = options->getInt("pingwarning"); + PingFreq = options->getInt("serverpingfreq"); if (PingFreq == 0) PingFreq = 60; diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp index 6aa12b4e7..3750fceac 100644 --- a/src/modules/m_watch.cpp +++ b/src/modules/m_watch.cpp @@ -390,8 +390,7 @@ class Modulewatch : public Module virtual void OnRehash(User* user) { - ConfigReader Conf; - maxwatch = Conf.ReadInteger("watch", "maxentries", 0, true); + maxwatch = ServerInstance->Config->ConfValue("watch")->getInt("maxentries", 32); if (!maxwatch) maxwatch = 32; } |