From af8effe4f0876d6fa934806745712f679bd36278 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Tue, 24 Jan 2023 23:41:50 +0000 Subject: Replace getInt/getUInt/getFloat with type safe templated functions. --- src/modules/extra/m_argon2.cpp | 38 +++++++++++------------------------- src/modules/extra/m_log_json.cpp | 2 +- src/modules/extra/m_mysql.cpp | 2 +- src/modules/extra/m_ssl_gnutls.cpp | 4 ++-- src/modules/extra/m_ssl_mbedtls.cpp | 8 ++++---- src/modules/extra/m_ssl_openssl.cpp | 6 +++--- src/modules/m_bcrypt.cpp | 2 +- src/modules/m_callerid.cpp | 2 +- src/modules/m_chanfilter.cpp | 2 +- src/modules/m_chanhistory.cpp | 2 +- src/modules/m_cloak_md5.cpp | 2 +- src/modules/m_cloak_sha256.cpp | 4 ++-- src/modules/m_codepage.cpp | 8 ++++---- src/modules/m_connectban.cpp | 6 +++--- src/modules/m_connflood.cpp | 2 +- src/modules/m_customprefix.cpp | 12 ++++++------ src/modules/m_dccallow.cpp | 2 +- src/modules/m_dnsbl.cpp | 2 +- src/modules/m_hidelist.cpp | 2 +- src/modules/m_hidemode.cpp | 6 +++--- src/modules/m_ircv3_sts.cpp | 2 +- src/modules/m_messageflood.cpp | 6 +++--- src/modules/m_monitor.cpp | 2 +- src/modules/m_operlevels.cpp | 4 ++-- src/modules/m_pbkdf2.cpp | 8 ++++---- src/modules/m_permchannels.cpp | 4 ++-- src/modules/m_remove.cpp | 2 +- src/modules/m_repeat.cpp | 8 ++++---- src/modules/m_securelist.cpp | 2 +- src/modules/m_showfile.cpp | 6 +++--- src/modules/m_silence.cpp | 2 +- src/modules/m_spanningtree/utils.cpp | 2 +- src/modules/m_watch.cpp | 2 +- 33 files changed, 74 insertions(+), 90 deletions(-) (limited to 'src/modules') diff --git a/src/modules/extra/m_argon2.cpp b/src/modules/extra/m_argon2.cpp index aec1b40d5..f2b3301a5 100644 --- a/src/modules/extra/m_argon2.cpp +++ b/src/modules/extra/m_argon2.cpp @@ -34,25 +34,6 @@ class ProviderConfig final { -private: - static Argon2_version SanitizeArgon2Version(unsigned long version) - { - // Note, 10 is 0x10, and 13 is 0x13. Referring to it as - // dec 10 or 13 in the config file, for the name to - // match better. - switch (version) - { - case 10: - return ARGON2_VERSION_10; - case 13: - return ARGON2_VERSION_13; - } - - ServerInstance->Logs.Warning(MODNAME, "Unknown Argon2 version ({}) specified; assuming 13", - version); - return ARGON2_VERSION_13; - } - public: uint32_t iterations; uint32_t lanes; @@ -72,25 +53,28 @@ public: const auto& tag = ServerInstance->Config->ConfValue(tagname); uint32_t def_iterations = def ? def->iterations : 3; - this->iterations = static_cast(tag->getUInt("iterations", def_iterations, 1, UINT32_MAX)); + this->iterations = tag->getNum("iterations", def_iterations, 1); uint32_t def_lanes = def ? def->lanes : 1; - this->lanes = static_cast(tag->getUInt("lanes", def_lanes, ARGON2_MIN_LANES, ARGON2_MAX_LANES)); + this->lanes = tag->getNum("lanes", def_lanes, ARGON2_MIN_LANES, ARGON2_MAX_LANES); uint32_t def_memory = def ? def->memory : 131072; // 128 MiB - this->memory = static_cast(tag->getUInt("memory", def_memory, ARGON2_MIN_MEMORY, ARGON2_MAX_MEMORY)); + this->memory = tag->getNum("memory", def_memory, ARGON2_MIN_MEMORY, ARGON2_MAX_MEMORY); uint32_t def_outlen = def ? def->outlen : 32; - this->outlen = static_cast(tag->getUInt("length", def_outlen, ARGON2_MIN_OUTLEN, ARGON2_MAX_OUTLEN)); + this->outlen = tag->getNum("length", def_outlen, ARGON2_MIN_OUTLEN, ARGON2_MAX_OUTLEN); uint32_t def_saltlen = def ? def->saltlen : 16; - this->saltlen = static_cast(tag->getUInt("saltlength", def_saltlen, ARGON2_MIN_SALT_LENGTH, ARGON2_MAX_SALT_LENGTH)); + this->saltlen = tag->getNum("saltlength", def_saltlen, ARGON2_MIN_SALT_LENGTH, ARGON2_MAX_SALT_LENGTH); uint32_t def_threads = def ? def->threads : 1; - this->threads = static_cast(tag->getUInt("threads", def_threads, ARGON2_MIN_THREADS, ARGON2_MAX_THREADS)); + this->threads = tag->getNum("threads", def_threads, ARGON2_MIN_THREADS, ARGON2_MAX_THREADS); - uint32_t def_version = def ? def->version : 13; - this->version = SanitizeArgon2Version(tag->getUInt("version", def_version)); + Argon2_version def_version = def ? def->version : ARGON2_VERSION_13; + this->version = tag->getEnum("version", def_version, { + { "10", ARGON2_VERSION_10 }, + { "13", ARGON2_VERSION_13 }, + }); } }; diff --git a/src/modules/extra/m_log_json.cpp b/src/modules/extra/m_log_json.cpp index b8ff6e838..4b401be92 100644 --- a/src/modules/extra/m_log_json.cpp +++ b/src/modules/extra/m_log_json.cpp @@ -145,7 +145,7 @@ public: fulltarget, tag->source.str(), strerror(errno))); } - const unsigned long flush = tag->getUInt("flush", 20, 1); + const unsigned long flush = tag->getNum("flush", 20, 1); return std::make_shared(fulltarget, fh, flush, true); } }; diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index 0d89e30a5..b2715dba8 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -335,7 +335,7 @@ public: const std::string user = config->getString("user"); const std::string pass = config->getString("pass"); const std::string dbname = config->getString("name"); - unsigned int port = static_cast(config->getUInt("port", 3306, 1, 65535)); + unsigned int port = config->getNum("port", 3306, 1, 65535); if (!mysql_real_connect(connection, host.c_str(), user.c_str(), pass.c_str(), dbname.c_str(), port, nullptr, CLIENT_IGNORE_SIGPIPE)) { ServerInstance->Logs.Error(MODNAME, "Unable to connect to the {} MySQL server: {}", diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index c9fb76dc0..3a1401636 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -541,7 +541,7 @@ namespace GnuTLS , dh(DHParams::Import(ReadFile(tag->getString("dhfile", "dhparams.pem", 1)))) #endif , priostr(GetPrioStr(profilename, tag)) - , mindh(static_cast(tag->getUInt("mindhbits", 1024, 0, UINT32_MAX))) + , mindh(tag->getNum("mindhbits", 1024)) , hashstr(tag->getString("hash", "sha256", 1)) , requestclientcert(tag->getBool("requestclientcert", true)) { @@ -556,7 +556,7 @@ namespace GnuTLS crl.reset(new X509CRL(ReadFile(filename))); } - outrecsize = static_cast(tag->getUInt("outrecsize", 2048, 512, UINT32_MAX)); + outrecsize = tag->getNum("outrecsize", 2048, 512); } }; diff --git a/src/modules/extra/m_ssl_mbedtls.cpp b/src/modules/extra/m_ssl_mbedtls.cpp index cb5d3acef..61625404f 100644 --- a/src/modules/extra/m_ssl_mbedtls.cpp +++ b/src/modules/extra/m_ssl_mbedtls.cpp @@ -451,12 +451,12 @@ namespace mbedTLS , dhstr(ReadFile(tag->getString("dhfile", "dhparams.pem", 1))) , ciphersuitestr(tag->getString("ciphersuites")) , curvestr(tag->getString("curves")) - , mindh(static_cast(tag->getUInt("mindhbits", 2048, 0, UINT32_MAX))) + , mindh(tag->getNum("mindhbits", 2048)) , hashstr(tag->getString("hash", "sha256", 1)) , castr(tag->getString("cafile")) - , minver(static_cast(tag->getUInt("minver", 0, 0, INT32_MAX))) - , maxver(static_cast(tag->getUInt("maxver", 0, 0, INT32_MAX))) - , outrecsize(static_cast(tag->getUInt("outrecsize", 2048, 512, 16384))) + , minver(tag->getNum("minver", 0)) + , maxver(tag->getNum("maxver", 0)) + , outrecsize(tag->getNum("outrecsize", 2048, 512, 16384)) , requestclientcert(tag->getBool("requestclientcert", true)) { if (!castr.empty()) diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index 448db9180..64dbc8b64 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -326,8 +326,8 @@ namespace OpenSSL */ void SetContextOptions(const std::string& ctxname, const std::shared_ptr& tag, Context& context) { - long setoptions = tag->getInt(ctxname + "setoptions", 0); - long clearoptions = tag->getInt(ctxname + "clearoptions", 0); + long setoptions = tag->getNum(ctxname + "setoptions", 0); + long clearoptions = tag->getNum(ctxname + "clearoptions", 0); #ifdef SSL_OP_NO_COMPRESSION // Disable compression by default @@ -370,7 +370,7 @@ namespace OpenSSL , ctx(SSL_CTX_new(TLS_server_method())) , clientctx(SSL_CTX_new(TLS_client_method())) , allowrenego(tag->getBool("renegotiation")) // Disallow by default - , outrecsize(static_cast(tag->getUInt("outrecsize", 2048, 512, 16384))) + , outrecsize(tag->getNum("outrecsize", 2048, 512, 16384)) { #ifndef INSPIRCD_OPENSSL_AUTO_DH if ((!ctx.SetDH(dh)) || (!clientctx.SetDH(dh))) diff --git a/src/modules/m_bcrypt.cpp b/src/modules/m_bcrypt.cpp index cac81cfa1..9ae763027 100644 --- a/src/modules/m_bcrypt.cpp +++ b/src/modules/m_bcrypt.cpp @@ -87,7 +87,7 @@ public: void ReadConfig(ConfigStatus& status) override { const auto& conf = ServerInstance->Config->ConfValue("bcrypt"); - bcrypt.rounds = conf->getUInt("rounds", 10, 1); + bcrypt.rounds = conf->getNum("rounds", 10, 1); } }; diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index 678d923cb..5d414f9e5 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -460,7 +460,7 @@ public: void ReadConfig(ConfigStatus& status) override { const auto& tag = ServerInstance->Config->ConfValue("callerid"); - cmd.maxaccepts = tag->getUInt("maxaccepts", 30); + cmd.maxaccepts = tag->getNum("maxaccepts", 30, 1); tracknick = tag->getBool("tracknick"); notify_cooldown = tag->getDuration("cooldown", 60); } diff --git a/src/modules/m_chanfilter.cpp b/src/modules/m_chanfilter.cpp index 722b90512..a3eab65c5 100644 --- a/src/modules/m_chanfilter.cpp +++ b/src/modules/m_chanfilter.cpp @@ -107,7 +107,7 @@ public: { const auto& tag = ServerInstance->Config->ConfValue("chanfilter"); hidemask = tag->getBool("hidemask"); - cf.maxlen = tag->getUInt("maxlen", 35, 10, ModeParser::MODE_PARAM_MAX); + cf.maxlen = tag->getNum("maxlen", 35, 10, ModeParser::MODE_PARAM_MAX); notifyuser = tag->getBool("notifyuser", true); cf.DoRehash(); } diff --git a/src/modules/m_chanhistory.cpp b/src/modules/m_chanhistory.cpp index c3b8efd4c..f7dc37265 100644 --- a/src/modules/m_chanhistory.cpp +++ b/src/modules/m_chanhistory.cpp @@ -210,7 +210,7 @@ public: void ReadConfig(ConfigStatus& status) override { const auto& tag = ServerInstance->Config->ConfValue("chanhistory"); - historymode.maxlines = tag->getUInt("maxlines", 50, 1); + historymode.maxlines = tag->getNum("maxlines", 50, 1); prefixmsg = tag->getBool("prefixmsg", true); dobots = tag->getBool("bots", true); } diff --git a/src/modules/m_cloak_md5.cpp b/src/modules/m_cloak_md5.cpp index 45bb07e6a..dd2c970c3 100644 --- a/src/modules/m_cloak_md5.cpp +++ b/src/modules/m_cloak_md5.cpp @@ -306,7 +306,7 @@ public: if (halfcloak) { - unsigned int domainparts = static_cast(tag->getUInt("domainparts", 3, 1, 10)); + unsigned int domainparts = tag->getNum("domainparts", 3, 1, 10); return std::make_shared(this, MODE_HALF_CLOAK, key, prefix, suffix, ignorecase, domainparts); } else diff --git a/src/modules/m_cloak_sha256.cpp b/src/modules/m_cloak_sha256.cpp index 088a3b411..945250b56 100644 --- a/src/modules/m_cloak_sha256.cpp +++ b/src/modules/m_cloak_sha256.cpp @@ -188,9 +188,9 @@ public: SHA256Method(const Cloak::Engine* engine, const std::shared_ptr& tag, const std::string& k, psl_ctx_t* p, bool ch) ATTR_NOT_NULL(2) : Cloak::Method(engine) , cloakhost(ch) - , hostparts(tag->getUInt("hostparts", 3, 0, ServerInstance->Config->Limits.MaxHost / 2)) + , hostparts(tag->getNum("hostparts", 3, 0, ServerInstance->Config->Limits.MaxHost / 2)) , key(k) - , pathparts(tag->getUInt("pathparts", 1, 0, ServerInstance->Config->Limits.MaxHost / 2)) + , pathparts(tag->getNum("pathparts", 1, 0, ServerInstance->Config->Limits.MaxHost / 2)) , prefix(tag->getString("prefix")) #ifdef HAS_LIBPSL , psl(p) diff --git a/src/modules/m_codepage.cpp b/src/modules/m_codepage.cpp index 1f5f2ac88..675255238 100644 --- a/src/modules/m_codepage.cpp +++ b/src/modules/m_codepage.cpp @@ -264,11 +264,11 @@ public: std::unique_ptr newcodepage = std::make_unique(); for (const auto& [_, tag] : ServerInstance->Config->ConfTags("cpchars")) { - unsigned long begin = tag->getUInt("begin", tag->getUInt("index", 0)); + unsigned long begin = tag->getNum("begin", tag->getNum("index", 0)); if (!begin) throw ModuleException(this, " tag without index or begin specified at " + tag->source.str()); - unsigned long end = tag->getUInt("end", begin); + unsigned long end = tag->getNum("end", begin); if (begin > end) throw ModuleException(this, " must be lower than at " + tag->source.str()); @@ -296,11 +296,11 @@ public: for (const auto& [_, tag] : ServerInstance->Config->ConfTags("cpcase")) { - unsigned long lower = tag->getUInt("lower", 0); + unsigned long lower = tag->getNum("lower", 0); if (!lower) throw ModuleException(this, " is required at " + tag->source.str()); - unsigned long upper = tag->getUInt("upper", 0); + unsigned long upper = tag->getNum("upper", 0); if (!upper) throw ModuleException(this, " is required at " + tag->source.str()); diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp index e99c958ba..a65d8ab52 100644 --- a/src/modules/m_connectban.cpp +++ b/src/modules/m_connectban.cpp @@ -100,9 +100,9 @@ public: { const auto& tag = ServerInstance->Config->ConfValue("connectban"); - ipv4_cidr = static_cast(tag->getUInt("ipv4cidr", ServerInstance->Config->c_ipv4_range, 1, 32)); - ipv6_cidr = static_cast(tag->getUInt("ipv6cidr", ServerInstance->Config->c_ipv6_range, 1, 128)); - threshold = tag->getUInt("threshold", 10, 1); + ipv4_cidr = tag->getNum("ipv4cidr", ServerInstance->Config->c_ipv4_range, 1, 32); + ipv6_cidr = tag->getNum("ipv6cidr", ServerInstance->Config->c_ipv6_range, 1, 128); + threshold = tag->getNum("threshold", 10, 1); bootwait = tag->getDuration("bootwait", 60*2); splitwait = tag->getDuration("splitwait", 60*2); banduration = tag->getDuration("banduration", 6*60*60, 1); diff --git a/src/modules/m_connflood.cpp b/src/modules/m_connflood.cpp index 09e9df0fc..d4c5c6596 100644 --- a/src/modules/m_connflood.cpp +++ b/src/modules/m_connflood.cpp @@ -60,7 +60,7 @@ public: const auto& tag = ServerInstance->Config->ConfValue("connflood"); /* throttle configuration */ seconds = tag->getDuration("period", 30); - maxconns = tag->getUInt("maxconns", 3); + maxconns = tag->getNum("maxconns", 3); timeout = tag->getDuration("timeout", 30); quitmsg = tag->getString("quitmsg"); diff --git a/src/modules/m_customprefix.cpp b/src/modules/m_customprefix.cpp index a60b17ec8..be13de1ef 100644 --- a/src/modules/m_customprefix.cpp +++ b/src/modules/m_customprefix.cpp @@ -32,9 +32,9 @@ public: : PrefixMode(parent, Name, Letter, 0, Prefix) , tag(Tag) { - ModeHandler::Rank rank = static_cast(tag->getUInt("rank", 1, 1, std::numeric_limits::max())); - ModeHandler::Rank setrank = static_cast(tag->getUInt("ranktoset", prefixrank, rank, std::numeric_limits::max())); - ModeHandler::Rank unsetrank = static_cast(tag->getUInt("ranktounset", setrank, setrank, std::numeric_limits::max())); + ModeHandler::Rank rank = tag->getNum("rank", 1, 1); + ModeHandler::Rank setrank = tag->getNum("ranktoset", prefixrank, rank); + ModeHandler::Rank unsetrank = tag->getNum("ranktounset", setrank, setrank); bool depriv = tag->getBool("depriv", true); this->Update(rank, setrank, unsetrank, depriv); @@ -77,9 +77,9 @@ public: if (!pm) throw ModuleException(this, " specified for a non-prefix mode at " + tag->source.str()); - ModeHandler::Rank rank = static_cast(tag->getUInt("rank", pm->GetPrefixRank(), 1, std::numeric_limits::max())); - ModeHandler::Rank setrank = static_cast(tag->getUInt("ranktoset", pm->GetLevelRequired(true), rank, std::numeric_limits::max())); - ModeHandler::Rank unsetrank = static_cast(tag->getUInt("ranktounset", pm->GetLevelRequired(false), setrank, std::numeric_limits::max())); + ModeHandler::Rank rank = tag->getNum("rank", pm->GetPrefixRank(), 1); + ModeHandler::Rank setrank = tag->getNum("ranktoset", pm->GetLevelRequired(true), rank); + ModeHandler::Rank unsetrank = tag->getNum("ranktounset", pm->GetLevelRequired(false), setrank); bool depriv = tag->getBool("depriv", pm->CanSelfRemove()); pm->Update(rank, setrank, unsetrank, depriv); diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index 20dfc5897..f1026e528 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -617,7 +617,7 @@ public: bfl.swap(newbfl); const auto& tag = ServerInstance->Config->ConfValue("dccallow"); - cmd.ext.maxentries = tag->getUInt("maxentries", 20, 1); + cmd.ext.maxentries = tag->getNum("maxentries", 20, 1); cmd.defaultlength = tag->getDuration("length", 0); blockchat = tag->getBool("blockchat"); defaultaction = tag->getString("action"); diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index 556a5339d..3d6a5074e 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -134,7 +134,7 @@ public: { type = Type::BITMASK; - bitmask = static_cast(tag->getUInt("bitmask", 0, 0, UINT_MAX)); + bitmask = tag->getNum("bitmask", 0); records = 0; } else if (stdalgo::string::equalsci(typestr, "record")) diff --git a/src/modules/m_hidelist.cpp b/src/modules/m_hidelist.cpp index ba3cc0ae1..be5606808 100644 --- a/src/modules/m_hidelist.cpp +++ b/src/modules/m_hidelist.cpp @@ -71,7 +71,7 @@ public: throw ModuleException(this, "Empty at " + tag->source.str()); // If rank is set to 0 everyone inside the channel can view the list, // but non-members may not - ModeHandler::Rank rank = tag->getUInt("rank", HALFOP_VALUE); + ModeHandler::Rank rank = tag->getNum("rank", HALFOP_VALUE); newconfigs.emplace_back(modename, rank); } diff --git a/src/modules/m_hidemode.cpp b/src/modules/m_hidemode.cpp index c01060580..d858b82e5 100644 --- a/src/modules/m_hidemode.cpp +++ b/src/modules/m_hidemode.cpp @@ -27,11 +27,11 @@ namespace { class Settings final { - typedef insp::flat_map RanksToSeeMap; + typedef insp::flat_map RanksToSeeMap; RanksToSeeMap rankstosee; public: - unsigned int GetRequiredRank(const ModeHandler& mh) const + ModeHandler::Rank GetRequiredRank(const ModeHandler& mh) const { RanksToSeeMap::const_iterator it = rankstosee.find(mh.name); if (it != rankstosee.end()) @@ -49,7 +49,7 @@ public: if (modename.empty()) throw ModuleException(mod, " is empty at " + tag->source.str()); - unsigned long rank = tag->getUInt("rank", 0); + ModeHandler::Rank rank = tag->getNum("rank", 0); if (!rank) throw ModuleException(mod, " must be greater than 0 at " + tag->source.str()); diff --git a/src/modules/m_ircv3_sts.cpp b/src/modules/m_ircv3_sts.cpp index 24874ef97..51099466e 100644 --- a/src/modules/m_ircv3_sts.cpp +++ b/src/modules/m_ircv3_sts.cpp @@ -181,7 +181,7 @@ public: if (host.empty()) throw ModuleException(this, " must contain a hostname, at " + tag->source.str()); - in_port_t port = static_cast(tag->getUInt("port", 6697, 1, 65535)); + in_port_t port = tag->getNum("port", 6697, 1); if (!HasValidSSLPort(port)) throw ModuleException(this, " must be a TLS port, at " + tag->source.str()); diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index e48883324..76e59b1b8 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -138,9 +138,9 @@ public: void ReadConfig(ConfigStatus&) override { const auto& tag = ServerInstance->Config->ConfValue("messageflood"); - notice = tag->getFloat("notice", 1.0); - privmsg = tag->getFloat("privmsg", 1.0); - tagmsg = tag->getFloat("tagmsg", 0.2); + notice = tag->getNum("notice", 1.0); + privmsg = tag->getNum("privmsg", 1.0); + tagmsg = tag->getNum("tagmsg", 0.2); kickmessage = tag->getString("kickmessage", "Message flood (trigger is %lines% messages in %duration%)", 1); } diff --git a/src/modules/m_monitor.cpp b/src/modules/m_monitor.cpp index 3e2b9d514..890736fc5 100644 --- a/src/modules/m_monitor.cpp +++ b/src/modules/m_monitor.cpp @@ -393,7 +393,7 @@ public: void ReadConfig(ConfigStatus& status) override { const auto& tag = ServerInstance->Config->ConfValue("monitor"); - cmd.maxmonitor = tag->getUInt("maxentries", 30, 1); + cmd.maxmonitor = tag->getNum("maxentries", 30, 1); } void OnPostConnect(User* user) override diff --git a/src/modules/m_operlevels.cpp b/src/modules/m_operlevels.cpp index 86ccddce0..c7db667f6 100644 --- a/src/modules/m_operlevels.cpp +++ b/src/modules/m_operlevels.cpp @@ -40,8 +40,8 @@ public: // oper killing an oper? if (dest->IsOper() && source->IsOper()) { - unsigned long dest_level = dest->oper->GetConfig()->getUInt("level", 0); - unsigned long source_level = source->oper->GetConfig()->getUInt("level", 0); + unsigned long dest_level = dest->oper->GetConfig()->getNum("level", 0); + unsigned long source_level = source->oper->GetConfig()->getNum("level", 0); if (dest_level > source_level) { diff --git a/src/modules/m_pbkdf2.cpp b/src/modules/m_pbkdf2.cpp index fbeb52e3b..53afb0ed3 100644 --- a/src/modules/m_pbkdf2.cpp +++ b/src/modules/m_pbkdf2.cpp @@ -185,8 +185,8 @@ class ModulePBKDF2 final // First set the common values const auto& tag = ServerInstance->Config->ConfValue("pbkdf2"); ProviderConfig newglobal; - newglobal.iterations = tag->getUInt("iterations", 12288, 1); - newglobal.dkey_length = tag->getUInt("length", 32, 1, 1024); + newglobal.iterations = tag->getNum("iterations", 12288, 1); + newglobal.dkey_length = tag->getNum("length", 32, 1, 1024); // Then the specific values ProviderConfigMap newconfigs; @@ -195,8 +195,8 @@ class ModulePBKDF2 final std::string hash_name = "hash/" + ptag->getString("hash"); ProviderConfig& config = newconfigs[hash_name]; - config.iterations = ptag->getUInt("iterations", newglobal.iterations, 1); - config.dkey_length = ptag->getUInt("length", newglobal.dkey_length, 1, 1024); + config.iterations = ptag->getNum("iterations", newglobal.iterations, 1); + config.dkey_length = ptag->getNum("length", newglobal.dkey_length, 1, 1024); } // Config is valid, apply it diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp index 24fc5bd8b..904ecf22d 100644 --- a/src/modules/m_permchannels.cpp +++ b/src/modules/m_permchannels.cpp @@ -218,10 +218,10 @@ public: auto* c = ServerInstance->Channels.Find(channel); if (!c) { - time_t TS = tag->getInt("ts", ServerInstance->Time(), 1); + time_t TS = tag->getNum("ts", ServerInstance->Time(), 1); c = new Channel(channel, TS); - time_t topicset = tag->getInt("topicts", 0); + time_t topicset = tag->getNum("topicts", 0); std::string topic = tag->getString("topic"); if ((topicset != 0) || (!topic.empty())) diff --git a/src/modules/m_remove.cpp b/src/modules/m_remove.cpp index 113062b30..864429b04 100644 --- a/src/modules/m_remove.cpp +++ b/src/modules/m_remove.cpp @@ -175,7 +175,7 @@ public: { const auto& tag = ServerInstance->Config->ConfValue("remove"); cmd.supportnokicks = tag->getBool("supportnokicks"); - cmd.protectedrank = tag->getUInt("protectedrank", 50000); + cmd.protectedrank = tag->getNum("protectedrank", 50000, 1); } }; diff --git a/src/modules/m_repeat.cpp b/src/modules/m_repeat.cpp index ec2568779..7e0317a62 100644 --- a/src/modules/m_repeat.cpp +++ b/src/modules/m_repeat.cpp @@ -248,13 +248,13 @@ public: void ReadConfig() { const auto& conf = ServerInstance->Config->ConfValue("repeat"); - ms.MaxLines = conf->getUInt("maxlines", 20); - ms.MaxBacklog = conf->getUInt("maxbacklog", 20); + ms.MaxLines = conf->getNum("maxlines", 20); + ms.MaxBacklog = conf->getNum("maxbacklog", 20); ms.MaxSecs = conf->getDuration("maxtime", 0); - ms.MaxDiff = static_cast(conf->getUInt("maxdistance", 50, 0, 100)); + ms.MaxDiff = conf->getNum("maxdistance", 50, 0, 100); - unsigned long newsize = conf->getUInt("size", 512); + size_t newsize = conf->getNum("size", 512); if (newsize > ServerInstance->Config->Limits.MaxLine) newsize = ServerInstance->Config->Limits.MaxLine; Resize(newsize); diff --git a/src/modules/m_securelist.cpp b/src/modules/m_securelist.cpp index 18d6e495d..1c6dfdc2c 100644 --- a/src/modules/m_securelist.cpp +++ b/src/modules/m_securelist.cpp @@ -67,7 +67,7 @@ public: const auto& tag = ServerInstance->Config->ConfValue("securelist"); exemptregistered = tag->getBool("exemptregistered", true); - fakechans = tag->getUInt("fakechans", 5, 0); + fakechans = tag->getNum("fakechans", 5, 0); fakechanprefix = tag->getString("fakechanprefix", "#", 1, ServerInstance->Config->Limits.MaxChannel - 1); fakechantopic = tag->getString("fakechantopic", "Fake channel for confusing spambots", 1, ServerInstance->Config->Limits.MaxTopic - 1); showmsg = tag->getBool("showmsg", true); diff --git a/src/modules/m_showfile.cpp b/src/modules/m_showfile.cpp index 4fee8b8e6..e4241105b 100644 --- a/src/modules/m_showfile.cpp +++ b/src/modules/m_showfile.cpp @@ -84,9 +84,9 @@ public: { introtext = tag->getString("introtext", "Showing " + name); endtext = tag->getString("endtext", "End of " + name); - intronumeric = static_cast(tag->getUInt("intronumeric", RPL_RULESTART, 0, 999)); - textnumeric = static_cast(tag->getUInt("numeric", RPL_RULES, 0, 999)); - endnumeric = static_cast(tag->getUInt("endnumeric", RPL_RULESEND, 0, 999)); + intronumeric = tag->getNum("intronumeric", RPL_RULESTART, 0, 999); + textnumeric = tag->getNum("numeric", RPL_RULES, 0, 999); + endnumeric = tag->getNum("endnumeric", RPL_RULESEND, 0, 999); std::string smethod = tag->getString("method"); method = SF_NUMERIC; diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp index 15690fb47..321dbeb86 100644 --- a/src/modules/m_silence.cpp +++ b/src/modules/m_silence.cpp @@ -459,7 +459,7 @@ public: { const auto& tag = ServerInstance->Config->ConfValue("silence"); exemptservice = tag->getBool("exemptservice", tag->getBool("exemptuline", true)); - cmd.ext.maxsilence = tag->getUInt("maxentries", 32, 1); + cmd.ext.maxsilence = tag->getNum("maxentries", 32, 1); } void OnBuildISupport(ISupport::TokenMap& tokens) override diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 3a0ec1cfc..d1d931ff3 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -262,7 +262,7 @@ void SpanningTreeUtilities::ReadConfiguration() if (path.empty()) { L->IPAddr = tag->getString("ipaddr"); - L->Port = static_cast(tag->getUInt("port", 0, 0, 65535)); + L->Port = tag->getNum("port", 0); if (tag->getBool("sctp")) { #ifdef IPPROTO_SCTP diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp index 61b20bcf6..43c2d1c85 100644 --- a/src/modules/m_watch.cpp +++ b/src/modules/m_watch.cpp @@ -219,7 +219,7 @@ public: void ReadConfig(ConfigStatus& status) override { const auto& tag = ServerInstance->Config->ConfValue("watch"); - cmd.maxwatch = tag->getUInt("maxwatch", 30, 1); + cmd.maxwatch = tag->getNum("maxwatch", 30, 1); } void OnPostConnect(User* user) override -- cgit v1.3.1-10-gc9f91