diff options
author | Peter Powell <petpow@saberuk.com> | 2018-04-14 15:43:03 +0100 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2018-04-16 15:29:55 +0100 |
commit | 780dda83ba3857bc3c330d4b5d38bb251a9d879b (patch) | |
tree | 75034915142a3e1362f0f9d59c8e96e1eec22931 /src/modules | |
parent | 2d36fcb16ef3209fffbe9f4b600971a1edd2ae4b (diff) |
Add ConfigTag::getUInt for reading unsigned config values.
Diffstat (limited to 'src/modules')
27 files changed, 48 insertions, 51 deletions
diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index 6c65cd87e..0a7d4d993 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -272,7 +272,7 @@ class SQLConnection : public SQL::Provider std::string user = config->getString("user"); std::string pass = config->getString("pass"); std::string dbname = config->getString("name"); - int port = config->getInt("port", 3306); + unsigned int port = config->getUInt("port", 3306); bool rv = mysql_real_connect(connection, host.c_str(), user.c_str(), pass.c_str(), dbname.c_str(), port, NULL, 0); if (!rv) return rv; diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index 56b60de26..51410cfb2 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -650,7 +650,7 @@ namespace GnuTLS , keystr(ReadFile(tag->getString("keyfile", "key.pem"))) , dh(DHParams::Import(ReadFile(tag->getString("dhfile", "dhparams.pem")))) , priostr(GetPrioStr(profilename, tag)) - , mindh(tag->getInt("mindhbits", 1024)) + , mindh(tag->getUInt("mindhbits", 1024)) , hashstr(tag->getString("hash", "md5")) , requestclientcert(tag->getBool("requestclientcert", true)) { @@ -667,9 +667,9 @@ namespace GnuTLS #ifdef INSPIRCD_GNUTLS_HAS_CORK // If cork support is available outrecsize represents the (rough) max amount of data we give GnuTLS while corked - outrecsize = tag->getInt("outrecsize", 2048, 512); + outrecsize = tag->getUInt("outrecsize", 2048, 512); #else - outrecsize = tag->getInt("outrecsize", 2048, 512, 16384); + outrecsize = tag->getUInt("outrecsize", 2048, 512, 16384); #endif } }; diff --git a/src/modules/extra/m_ssl_mbedtls.cpp b/src/modules/extra/m_ssl_mbedtls.cpp index 391d4d79b..8bb0e2bbd 100644 --- a/src/modules/extra/m_ssl_mbedtls.cpp +++ b/src/modules/extra/m_ssl_mbedtls.cpp @@ -410,12 +410,12 @@ namespace mbedTLS , dhstr(ReadFile(tag->getString("dhfile", "dhparams.pem"))) , ciphersuitestr(tag->getString("ciphersuites")) , curvestr(tag->getString("curves")) - , mindh(tag->getInt("mindhbits", 2048)) + , mindh(tag->getUInt("mindhbits", 2048)) , hashstr(tag->getString("hash", "sha256")) , castr(tag->getString("cafile")) - , minver(tag->getInt("minver", 0)) - , maxver(tag->getInt("maxver", 0)) - , outrecsize(tag->getInt("outrecsize", 2048, 512, 16384)) + , minver(tag->getUInt("minver", 0)) + , maxver(tag->getUInt("maxver", 0)) + , outrecsize(tag->getUInt("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 828fcc26a..a70bffb3c 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -359,7 +359,7 @@ namespace OpenSSL , ctx(SSL_CTX_new(SSLv23_server_method())) , clictx(SSL_CTX_new(SSLv23_client_method())) , allowrenego(tag->getBool("renegotiation")) // Disallow by default - , outrecsize(tag->getInt("outrecsize", 2048, 512, 16384)) + , outrecsize(tag->getUInt("outrecsize", 2048, 512, 16384)) { if ((!ctx.SetDH(dh)) || (!clictx.SetDH(dh))) throw Exception("Couldn't set DH parameters"); diff --git a/src/modules/m_bcrypt.cpp b/src/modules/m_bcrypt.cpp index 1698b0727..787d5eab0 100644 --- a/src/modules/m_bcrypt.cpp +++ b/src/modules/m_bcrypt.cpp @@ -975,7 +975,7 @@ class ModuleBCrypt : public Module void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* conf = ServerInstance->Config->ConfValue("bcrypt"); - bcrypt.rounds = conf->getInt("rounds", 10, 1); + bcrypt.rounds = conf->getUInt("rounds", 10, 1); } Version GetVersion() CXX11_OVERRIDE diff --git a/src/modules/m_blockcaps.cpp b/src/modules/m_blockcaps.cpp index 0b5736f64..b79e126a3 100644 --- a/src/modules/m_blockcaps.cpp +++ b/src/modules/m_blockcaps.cpp @@ -109,8 +109,8 @@ public: void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("blockcaps"); - percent = tag->getInt("percent", 100, 1, 100); - minlen = tag->getInt("minlen", 1, 1, ServerInstance->Config->Limits.MaxLine); + percent = tag->getUInt("percent", 100, 1, 100); + minlen = tag->getUInt("minlen", 1, 1, ServerInstance->Config->Limits.MaxLine); lowercase.reset(); const std::string lower = tag->getString("lowercase", "abcdefghijklmnopqrstuvwxyz"); diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index f43dd448d..ecccbe91b 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -418,7 +418,7 @@ public: void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("callerid"); - cmd.maxaccepts = tag->getInt("maxaccepts", 16); + cmd.maxaccepts = tag->getUInt("maxaccepts", 16); 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 dd11cb514..ce2387004 100644 --- a/src/modules/m_chanfilter.cpp +++ b/src/modules/m_chanfilter.cpp @@ -89,7 +89,7 @@ class ModuleChanFilter : public Module { ConfigTag* tag = ServerInstance->Config->ConfValue("chanfilter"); hidemask = tag->getBool("hidemask"); - cf.maxlen = tag->getInt("maxlen", 35, 10, 100); + cf.maxlen = tag->getUInt("maxlen", 35, 10, 100); cf.DoRehash(); } diff --git a/src/modules/m_chanhistory.cpp b/src/modules/m_chanhistory.cpp index 5f081d9de..081731126 100644 --- a/src/modules/m_chanhistory.cpp +++ b/src/modules/m_chanhistory.cpp @@ -123,7 +123,7 @@ class ModuleChanHistory : public Module void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("chanhistory"); - m.maxlines = tag->getInt("maxlines", 50, 1); + m.maxlines = tag->getUInt("maxlines", 50, 1); sendnotice = tag->getBool("notice", true); dobots = tag->getBool("bots", true); } diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index e5f912c95..515244231 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -353,7 +353,7 @@ class ModuleCloaking : public Module if (modestr == "half") { mode = MODE_HALF_CLOAK; - domainparts = tag->getInt("domainparts", 3, 1, 10); + domainparts = tag->getUInt("domainparts", 3, 1, 10); } else if (modestr == "full") mode = MODE_OPAQUE; diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp index 58b3bfeda..906724249 100644 --- a/src/modules/m_connectban.cpp +++ b/src/modules/m_connectban.cpp @@ -40,9 +40,9 @@ class ModuleConnectBan : public Module { ConfigTag* tag = ServerInstance->Config->ConfValue("connectban"); - ipv4_cidr = tag->getInt("ipv4cidr", 32, 1, 32); - ipv6_cidr = tag->getInt("ipv6cidr", 128, 1, 128); - threshold = tag->getInt("threshold", 10, 1); + ipv4_cidr = tag->getUInt("ipv4cidr", 32, 1, 32); + ipv6_cidr = tag->getUInt("ipv6cidr", 128, 1, 128); + threshold = tag->getUInt("threshold", 10, 1); banduration = tag->getDuration("duration", 10*60, 1); banmessage = tag->getString("banmessage", "Your IP range has been attempting to connect too many times in too short a duration. Wait a while, and you will be able to connect."); } diff --git a/src/modules/m_connflood.cpp b/src/modules/m_connflood.cpp index 32d36188b..5070dd3a7 100644 --- a/src/modules/m_connflood.cpp +++ b/src/modules/m_connflood.cpp @@ -49,7 +49,7 @@ public: ConfigTag* tag = ServerInstance->Config->ConfValue("connflood"); /* throttle configuration */ seconds = tag->getDuration("period", tag->getDuration("seconds", 30)); - maxconns = tag->getInt("maxconns", 3); + maxconns = tag->getUInt("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 5874e02d9..befc9750d 100644 --- a/src/modules/m_customprefix.cpp +++ b/src/modules/m_customprefix.cpp @@ -28,9 +28,9 @@ class CustomPrefixMode : public PrefixMode : PrefixMode(parent, Name, Letter, 0, Prefix) , tag(Tag) { - long rank = tag->getInt("rank", 0, 0, UINT_MAX); - long setrank = tag->getInt("ranktoset", prefixrank, rank, UINT_MAX); - long unsetrank = tag->getInt("ranktounset", setrank, setrank, UINT_MAX); + unsigned long rank = tag->getUInt("rank", 0, 0, UINT_MAX); + unsigned long setrank = tag->getUInt("ranktoset", prefixrank, rank, UINT_MAX); + unsigned long unsetrank = tag->getUInt("ranktounset", setrank, setrank, UINT_MAX); bool depriv = tag->getBool("depriv", true); this->Update(rank, setrank, unsetrank, depriv); @@ -64,9 +64,9 @@ class ModuleCustomPrefix : public Module if (!pm) throw ModuleException("<customprefix:change> specified for a non-prefix mode at " + tag->getTagLocation()); - long rank = tag->getInt("rank", pm->GetPrefixRank(), 0, UINT_MAX); - long setrank = tag->getInt("ranktoset", pm->GetLevelRequired(true), rank, UINT_MAX); - long unsetrank = tag->getInt("ranktounset", pm->GetLevelRequired(false), setrank, UINT_MAX); + unsigned long rank = tag->getUInt("rank", pm->GetPrefixRank(), 0, UINT_MAX); + unsigned long setrank = tag->getUInt("ranktoset", pm->GetLevelRequired(true), rank, UINT_MAX); + unsigned long unsetrank = tag->getUInt("ranktounset", pm->GetLevelRequired(false), setrank, UINT_MAX); 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 0e6188339..9d85f01da 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -506,7 +506,7 @@ class ModuleDCCAllow : public Module void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("dccallow"); - cmd.maxentries = tag->getInt("maxentries", 20); + cmd.maxentries = tag->getUInt("maxentries", 20); bfl.clear(); ConfigTagList tags = ServerInstance->Config->ConfTags("banfile"); diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp index 377cad9dd..16694de93 100644 --- a/src/modules/m_dnsbl.cpp +++ b/src/modules/m_dnsbl.cpp @@ -281,7 +281,7 @@ class ModuleDNSBL : public Module, public Stats::EventListener if (tag->getString("type") == "bitmask") { e->type = DNSBLConfEntry::A_BITMASK; - e->bitmask = tag->getInt("bitmask", 0, 0, UINT_MAX); + e->bitmask = tag->getUInt("bitmask", 0, 0, UINT_MAX); } else { diff --git a/src/modules/m_hidelist.cpp b/src/modules/m_hidelist.cpp index 0691ab81c..2d3f0be7c 100644 --- a/src/modules/m_hidelist.cpp +++ b/src/modules/m_hidelist.cpp @@ -68,7 +68,7 @@ class ModuleHideList : public Module std::string modename = tag->getString("mode"); // If rank is set to 0 everyone inside the channel can view the list, // but non-members may not - unsigned int rank = tag->getInt("rank", HALFOP_VALUE, 0); + unsigned int rank = tag->getUInt("rank", HALFOP_VALUE); watchers.push_back(new ListWatcher(this, modename, rank)); } } diff --git a/src/modules/m_ircv3_sts.cpp b/src/modules/m_ircv3_sts.cpp index 9dc36df60..c78b79b46 100644 --- a/src/modules/m_ircv3_sts.cpp +++ b/src/modules/m_ircv3_sts.cpp @@ -163,7 +163,7 @@ class ModuleIRCv3STS : public Module if (host.empty()) throw ModuleException("<sts:host> must contain a hostname, at " + tag->getTagLocation()); - unsigned int port = tag->getInt("port", 0, 0, UINT16_MAX); + unsigned int port = tag->getUInt("port", 0, 0, UINT16_MAX); if (!HasValidSSLPort(port)) throw ModuleException("<sts:port> must be a TLS port, at " + tag->getTagLocation()); diff --git a/src/modules/m_monitor.cpp b/src/modules/m_monitor.cpp index af792743a..75fa11cf0 100644 --- a/src/modules/m_monitor.cpp +++ b/src/modules/m_monitor.cpp @@ -402,7 +402,7 @@ class ModuleMonitor : public Module void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("monitor"); - cmd.maxmonitor = tag->getInt("maxentries", 30, 1); + cmd.maxmonitor = tag->getUInt("maxentries", 30, 1); } void OnPostConnect(User* user) CXX11_OVERRIDE diff --git a/src/modules/m_pbkdf2.cpp b/src/modules/m_pbkdf2.cpp index 8b1346c84..89bc39ef4 100644 --- a/src/modules/m_pbkdf2.cpp +++ b/src/modules/m_pbkdf2.cpp @@ -147,8 +147,8 @@ class ModulePBKDF2 : public Module { // First set the common values ConfigTag* tag = ServerInstance->Config->ConfValue("pbkdf2"); - unsigned int global_iterations = tag->getInt("iterations", 12288, 1); - unsigned int global_dkey_length = tag->getInt("length", 32, 1, 1024); + unsigned int global_iterations = tag->getUInt("iterations", 12288, 1); + unsigned int global_dkey_length = tag->getUInt("length", 32, 1, 1024); for (std::vector<PBKDF2Provider*>::iterator i = providers.begin(); i != providers.end(); ++i) { PBKDF2Provider* pi = *i; @@ -168,8 +168,8 @@ class ModulePBKDF2 : public Module if (pi->provider->name != hash_name) continue; - pi->iterations = tag->getInt("iterations", global_iterations, 1); - pi->dkey_length = tag->getInt("length", global_dkey_length, 1, 1024); + pi->iterations = tag->getUInt("iterations", global_iterations, 1); + pi->dkey_length = tag->getUInt("length", global_dkey_length, 1, 1024); } } } diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp index 95f01839e..a7be6df08 100644 --- a/src/modules/m_permchannels.cpp +++ b/src/modules/m_permchannels.cpp @@ -206,7 +206,7 @@ public: time_t TS = tag->getInt("ts", ServerInstance->Time(), 1); c = new Channel(channel, TS); - unsigned int topicset = tag->getInt("topicts", 0); + time_t topicset = tag->getInt("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 0d816cc41..35b7fbf03 100644 --- a/src/modules/m_remove.cpp +++ b/src/modules/m_remove.cpp @@ -217,7 +217,7 @@ class ModuleRemove : public Module { ConfigTag* tag = ServerInstance->Config->ConfValue("remove"); supportnokicks = tag->getBool("supportnokicks"); - cmd1.protectedrank = cmd2.protectedrank = tag->getInt("protectedrank", 50000); + cmd1.protectedrank = cmd2.protectedrank = tag->getUInt("protectedrank", 50000); } Version GetVersion() CXX11_OVERRIDE diff --git a/src/modules/m_repeat.cpp b/src/modules/m_repeat.cpp index 18732d705..ef62e9ab1 100644 --- a/src/modules/m_repeat.cpp +++ b/src/modules/m_repeat.cpp @@ -233,15 +233,15 @@ class RepeatMode : public ParamMode<RepeatMode, SimpleExtItem<ChannelSettings> > void ReadConfig() { ConfigTag* conf = ServerInstance->Config->ConfValue("repeat"); - ms.MaxLines = conf->getInt("maxlines", 20); - ms.MaxBacklog = conf->getInt("maxbacklog", 20); + ms.MaxLines = conf->getUInt("maxlines", 20); + ms.MaxBacklog = conf->getUInt("maxbacklog", 20); ms.MaxSecs = conf->getDuration("maxtime", conf->getDuration("maxsecs", 0)); - ms.MaxDiff = conf->getInt("maxdistance", 50); + ms.MaxDiff = conf->getUInt("maxdistance", 50); if (ms.MaxDiff > 100) ms.MaxDiff = 100; - unsigned int newsize = conf->getInt("size", 512); + unsigned int newsize = conf->getUInt("size", 512); if (newsize > ServerInstance->Config->Limits.MaxLine) newsize = ServerInstance->Config->Limits.MaxLine; Resize(newsize); diff --git a/src/modules/m_showfile.cpp b/src/modules/m_showfile.cpp index 57c501e90..b04b699c4 100644 --- a/src/modules/m_showfile.cpp +++ b/src/modules/m_showfile.cpp @@ -70,9 +70,9 @@ class CommandShowFile : public Command { introtext = tag->getString("introtext", "Showing " + name); endtext = tag->getString("endtext", "End of " + name); - intronumeric = tag->getInt("intronumeric", RPL_RULESTART, 0, 999); - textnumeric = tag->getInt("numeric", RPL_RULES, 0, 999); - endnumeric = tag->getInt("endnumeric", RPL_RULESEND, 0, 999); + intronumeric = tag->getUInt("intronumeric", RPL_RULESTART, 0, 999); + textnumeric = tag->getUInt("numeric", RPL_RULES, 0, 999); + endnumeric = tag->getUInt("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 fd6d889d4..cc510c3dd 100644 --- a/src/modules/m_silence.cpp +++ b/src/modules/m_silence.cpp @@ -313,10 +313,7 @@ class ModuleSilence : public Module { ConfigTag* tag = ServerInstance->Config->ConfValue("silence"); - maxsilence = tag->getInt("maxentries", 32); - if (!maxsilence) - maxsilence = 32; - + maxsilence = tag->getUInt("maxentries", 32, 1); ExemptULine = tag->getBool("exemptuline", true); } diff --git a/src/modules/m_spanningtree/link.h b/src/modules/m_spanningtree/link.h index 465e65ff8..5b9361fcd 100644 --- a/src/modules/m_spanningtree/link.h +++ b/src/modules/m_spanningtree/link.h @@ -26,7 +26,7 @@ class Link : public refcountbase reference<ConfigTag> tag; std::string Name; std::string IPAddr; - int Port; + unsigned int Port; std::string SendPass; std::string RecvPass; std::string Fingerprint; diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index d6f74cc69..f42822daa 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -250,7 +250,7 @@ void SpanningTreeUtilities::ReadConfiguration() L->AllowMasks.push_back(s); L->IPAddr = tag->getString("ipaddr"); - L->Port = tag->getInt("port", 0); + L->Port = tag->getUInt("port", 0); L->SendPass = tag->getString("sendpass", tag->getString("password")); L->RecvPass = tag->getString("recvpass", tag->getString("password")); L->Fingerprint = tag->getString("fingerprint"); diff --git a/src/modules/m_watch.cpp b/src/modules/m_watch.cpp index 63e34220a..6406f0573 100644 --- a/src/modules/m_watch.cpp +++ b/src/modules/m_watch.cpp @@ -219,7 +219,7 @@ class ModuleWatch : public Module void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("watch"); - cmd.maxwatch = tag->getInt("maxwatch", 30, 1); + cmd.maxwatch = tag->getUInt("maxwatch", 30, 1); } void OnPostConnect(User* user) CXX11_OVERRIDE |