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 | |
parent | 2d36fcb16ef3209fffbe9f4b600971a1edd2ae4b (diff) |
Add ConfigTag::getUInt for reading unsigned config values.
34 files changed, 99 insertions, 83 deletions
diff --git a/include/configreader.h b/include/configreader.h index 85ce21f14..dba092920 100644 --- a/include/configreader.h +++ b/include/configreader.h @@ -47,6 +47,8 @@ class CoreExport ConfigTag : public refcountbase /** Get the value of an option, using def if it does not exist */ long getInt(const std::string& key, long def, long min = LONG_MIN, long max = LONG_MAX); /** Get the value of an option, using def if it does not exist */ + unsigned long getUInt(const std::string& key, unsigned long def, unsigned long min = 0, unsigned long max = ULONG_MAX); + /** Get the value of an option, using def if it does not exist */ double getFloat(const std::string& key, double def); /** Get the value of an option, using def if it does not exist */ bool getBool(const std::string& key, bool def = false); diff --git a/src/configparser.cpp b/src/configparser.cpp index 624f3aea6..5ee86c811 100644 --- a/src/configparser.cpp +++ b/src/configparser.cpp @@ -496,6 +496,23 @@ long ConfigTag::getInt(const std::string &key, long def, long min, long max) return res; } +unsigned long ConfigTag::getUInt(const std::string& key, unsigned long def, unsigned long min, unsigned long max) +{ + std::string result; + if (!readString(key, result)) + return def; + + const char* res_cstr = result.c_str(); + char* res_tail = NULL; + unsigned long res = strtoul(res_cstr, &res_tail, 0); + if (res_tail == res_cstr) + return def; + + CheckMagnitude(tag, key, result, res, def, res_tail); + CheckRange(tag, key, res, def, min, max); + return res; +} + unsigned long ConfigTag::getDuration(const std::string& key, unsigned long def, unsigned long min, unsigned long max) { std::string duration; diff --git a/src/configreader.cpp b/src/configreader.cpp index 76bd268f2..e4ce955f8 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -30,17 +30,17 @@ #include <iostream> ServerLimits::ServerLimits(ConfigTag* tag) - : NickMax(tag->getInt("maxnick", 30)) - , ChanMax(tag->getInt("maxchan", 64)) - , MaxModes(tag->getInt("maxmodes", 20)) - , IdentMax(tag->getInt("maxident", 10)) - , MaxQuit(tag->getInt("maxquit", 255)) - , MaxTopic(tag->getInt("maxtopic", 307)) - , MaxKick(tag->getInt("maxkick", 255)) - , MaxGecos(tag->getInt("maxgecos", 128)) - , MaxAway(tag->getInt("maxaway", 200)) - , MaxLine(tag->getInt("maxline", 512)) - , MaxHost(tag->getInt("maxhost", 64)) + : NickMax(tag->getUInt("maxnick", 30)) + , ChanMax(tag->getUInt("maxchan", 64)) + , MaxModes(tag->getUInt("maxmodes", 20)) + , IdentMax(tag->getUInt("maxident", 10)) + , MaxQuit(tag->getUInt("maxquit", 255)) + , MaxTopic(tag->getUInt("maxtopic", 307)) + , MaxKick(tag->getUInt("maxkick", 255)) + , MaxGecos(tag->getUInt("maxgecos", 128)) + , MaxAway(tag->getUInt("maxaway", 200)) + , MaxLine(tag->getUInt("maxline", 512)) + , MaxHost(tag->getUInt("maxhost", 64)) { } @@ -318,17 +318,17 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) me->softsendqmax = value; me->hardsendqmax = value * 8; } - me->softsendqmax = tag->getInt("softsendq", me->softsendqmax); - me->hardsendqmax = tag->getInt("hardsendq", me->hardsendqmax); - me->recvqmax = tag->getInt("recvq", me->recvqmax); - me->penaltythreshold = tag->getInt("threshold", me->penaltythreshold); - me->commandrate = tag->getInt("commandrate", me->commandrate); + me->softsendqmax = tag->getUInt("softsendq", me->softsendqmax); + me->hardsendqmax = tag->getUInt("hardsendq", me->hardsendqmax); + me->recvqmax = tag->getUInt("recvq", me->recvqmax); + me->penaltythreshold = tag->getUInt("threshold", me->penaltythreshold); + me->commandrate = tag->getUInt("commandrate", me->commandrate); me->fakelag = tag->getBool("fakelag", me->fakelag); - me->maxlocal = tag->getInt("localmax", me->maxlocal); - me->maxglobal = tag->getInt("globalmax", me->maxglobal); - me->maxchans = tag->getInt("maxchans", me->maxchans); + me->maxlocal = tag->getUInt("localmax", me->maxlocal); + me->maxglobal = tag->getUInt("globalmax", me->maxglobal); + me->maxchans = tag->getUInt("maxchans", me->maxchans); me->maxconnwarn = tag->getBool("maxconnwarn", me->maxconnwarn); - me->limit = tag->getInt("limit", me->limit); + me->limit = tag->getUInt("limit", me->limit); me->resolvehostnames = tag->getBool("resolvehostnames", me->resolvehostnames); std::string ports = tag->getString("port"); @@ -419,9 +419,9 @@ void ServerConfig::Fill() throw CoreException("You must restart to change the server casemapping"); } - SoftLimit = ConfValue("performance")->getInt("softlimit", (SocketEngine::GetMaxFds() > 0 ? SocketEngine::GetMaxFds() : LONG_MAX), 10); + SoftLimit = ConfValue("performance")->getUInt("softlimit", (SocketEngine::GetMaxFds() > 0 ? SocketEngine::GetMaxFds() : LONG_MAX), 10); CCOnConnect = ConfValue("performance")->getBool("clonesonconnect", true); - MaxConn = ConfValue("performance")->getInt("somaxconn", SOMAXCONN); + MaxConn = ConfValue("performance")->getUInt("somaxconn", SOMAXCONN); XLineMessage = options->getString("xlinemessage", options->getString("moronbanner", "You're banned!")); ServerDesc = server->getString("description", "Configure Me"); Network = server->getString("network", "Network"); @@ -439,13 +439,13 @@ void ServerConfig::Fill() SyntaxHints = options->getBool("syntaxhints"); CycleHostsFromUser = options->getBool("cyclehostsfromuser"); FullHostInTopic = options->getBool("hostintopic"); - MaxTargets = security->getInt("maxtargets", 20, 1, 31); + MaxTargets = security->getUInt("maxtargets", 20, 1, 31); DefaultModes = options->getString("defaultmodes", "not"); PID = ConfValue("pid")->getString("file"); - MaxChans = ConfValue("channels")->getInt("users", 20); - OperMaxChans = ConfValue("channels")->getInt("opers", 0); - c_ipv4_range = ConfValue("cidr")->getInt("ipv4clone", 32, 1, 32); - c_ipv6_range = ConfValue("cidr")->getInt("ipv6clone", 128, 1, 128); + MaxChans = ConfValue("channels")->getUInt("users", 20); + OperMaxChans = ConfValue("channels")->getUInt("opers", 0); + c_ipv4_range = ConfValue("cidr")->getUInt("ipv4clone", 32, 1, 32); + c_ipv6_range = ConfValue("cidr")->getUInt("ipv6clone", 128, 1, 128); Limits = ServerLimits(ConfValue("limits")); Paths = ServerPaths(ConfValue("path")); NoSnoticeStack = options->getBool("nosnoticestack", false); diff --git a/src/coremods/core_dns.cpp b/src/coremods/core_dns.cpp index 0a835a67a..ea234861a 100644 --- a/src/coremods/core_dns.cpp +++ b/src/coremods/core_dns.cpp @@ -817,7 +817,7 @@ class ModuleDNS : public Module ConfigTag* tag = ServerInstance->Config->ConfValue("dns"); DNSServer = tag->getString("server"); SourceIP = tag->getString("sourceip"); - SourcePort = tag->getInt("sourceport", 0, 0, 65535); + SourcePort = tag->getUInt("sourceport", 0, 0, UINT16_MAX); if (DNSServer.empty()) FindDNSServer(); diff --git a/src/coremods/core_whowas.cpp b/src/coremods/core_whowas.cpp index 689340a8d..188b0e4d5 100644 --- a/src/coremods/core_whowas.cpp +++ b/src/coremods/core_whowas.cpp @@ -294,8 +294,8 @@ class ModuleWhoWas : public Module, public Stats::EventListener void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { ConfigTag* tag = ServerInstance->Config->ConfValue("whowas"); - unsigned int NewGroupSize = tag->getInt("groupsize", 10, 0, 10000); - unsigned int NewMaxGroups = tag->getInt("maxgroups", 10240, 0, 1000000); + unsigned int NewGroupSize = tag->getUInt("groupsize", 10, 0, 10000); + unsigned int NewMaxGroups = tag->getUInt("maxgroups", 10240, 0, 1000000); unsigned int NewMaxKeep = tag->getDuration("maxkeep", 3600, 3600); cmd.manager.UpdateConfig(NewGroupSize, NewMaxGroups, NewMaxKeep); diff --git a/src/listmode.cpp b/src/listmode.cpp index d106bfa1d..74977b866 100644 --- a/src/listmode.cpp +++ b/src/listmode.cpp @@ -69,7 +69,7 @@ void ListModeBase::DoRehash() { // For each <banlist> tag ConfigTag* c = i->second; - ListLimit limit(c->getString("chan"), c->getInt("limit", 0)); + ListLimit limit(c->getString("chan"), c->getUInt("limit", 0)); if (limit.mask.size() && limit.limit > 0) chanlimits.push_back(limit); diff --git a/src/logger.cpp b/src/logger.cpp index 6fa972c73..22896bd4f 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -119,7 +119,7 @@ void LogManager::OpenFileLogs() struct tm *mytime = gmtime(&time); strftime(realtarget, sizeof(realtarget), target.c_str(), mytime); FILE* f = fopen(realtarget, "a"); - fw = new FileWriter(f, static_cast<unsigned int>(tag->getInt("flush", 20, 1, INT_MAX))); + fw = new FileWriter(f, tag->getUInt("flush", 20, 1, UINT_MAX)); logmap.insert(std::make_pair(target, fw)); } else 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 |