mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 18:49:03 -04:00
Replace getInt/getUInt/getFloat with type safe templated functions.
This commit is contained in:
parent
babc733d2d
commit
af8effe4f0
@ -67,6 +67,30 @@ public:
|
|||||||
private:
|
private:
|
||||||
Items items;
|
Items items;
|
||||||
|
|
||||||
|
/** Retrieves the value of a signed integer from the server config.
|
||||||
|
* @param key The config key to retrieve.
|
||||||
|
* @param def The default value to return if not set, empty, or out of range.
|
||||||
|
* @param min The minimum valid value.
|
||||||
|
* @param max The maximum valid value.
|
||||||
|
*/
|
||||||
|
long double getFloat(const std::string& key, long double def, long double min, long double max) const;
|
||||||
|
|
||||||
|
/** Retrieves the value of a signed integer from the server config.
|
||||||
|
* @param key The config key to retrieve.
|
||||||
|
* @param def The default value to return if not set, empty, or out of range.
|
||||||
|
* @param min The minimum valid value.
|
||||||
|
* @param max The maximum valid value.
|
||||||
|
*/
|
||||||
|
intmax_t getSInt(const std::string& key, intmax_t def, intmax_t min, intmax_t max) const;
|
||||||
|
|
||||||
|
/** Retrieves the value of an unsigned integer from the server config.
|
||||||
|
* @param key The config key to retrieve.
|
||||||
|
* @param def The default value to return if not set, empty, or out of range.
|
||||||
|
* @param min The minimum valid value.
|
||||||
|
* @param max The maximum valid value.
|
||||||
|
*/
|
||||||
|
uintmax_t getUInt(const std::string& key, uintmax_t def, uintmax_t min, uintmax_t max) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** The name of the configuration tag (e.g. "foo" for \<foo bar="baz">). */
|
/** The name of the configuration tag (e.g. "foo" for \<foo bar="baz">). */
|
||||||
const std::string name;
|
const std::string name;
|
||||||
@ -80,17 +104,32 @@ public:
|
|||||||
*/
|
*/
|
||||||
ConfigTag(const std::string& Name, const FilePosition& Source);
|
ConfigTag(const std::string& Name, const FilePosition& Source);
|
||||||
|
|
||||||
|
/** @copydoc getFloat */
|
||||||
|
template<typename T>
|
||||||
|
std::enable_if_t<std::is_floating_point_v<T>, T> getNum(const std::string& key, T def, T min = std::numeric_limits<T>::min(), T max = std::numeric_limits<T>::max()) const
|
||||||
|
{
|
||||||
|
return static_cast<T>(getFloat(key, def, min, max));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @copydoc getSInt */
|
||||||
|
template<typename T>
|
||||||
|
std::enable_if_t<std::is_signed_v<T> && !std::is_floating_point_v<T>, T> getNum(const std::string& key, T def, T min = std::numeric_limits<T>::min(), T max = std::numeric_limits<T>::max()) const
|
||||||
|
{
|
||||||
|
return static_cast<T>(getSInt(key, def, min, max));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @copydoc getUInt */
|
||||||
|
template<typename T>
|
||||||
|
std::enable_if_t<std::is_unsigned_v<T> && !std::is_floating_point_v<T>, T> getNum(const std::string& key, T def, T min = std::numeric_limits<T>::min(), T max = std::numeric_limits<T>::max()) const
|
||||||
|
{
|
||||||
|
return static_cast<T>(getUInt(key, def, min, max));
|
||||||
|
}
|
||||||
|
|
||||||
/** Get the value of an option, using def if it does not exist */
|
/** Get the value of an option, using def if it does not exist */
|
||||||
std::string getString(const std::string& key, const std::string& def, const std::function<bool(const std::string&)>& validator) const;
|
std::string getString(const std::string& key, const std::string& def, const std::function<bool(const std::string&)>& validator) const;
|
||||||
/** Get the value of an option, using def if it does not exist */
|
/** Get the value of an option, using def if it does not exist */
|
||||||
std::string getString(const std::string& key, const std::string& def = "", size_t minlen = 0, size_t maxlen = UINT32_MAX) const;
|
std::string getString(const std::string& key, const std::string& def = "", size_t minlen = 0, size_t maxlen = UINT32_MAX) const;
|
||||||
/** Get the value of an option, using def if it does not exist */
|
/** 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) const;
|
|
||||||
/** 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) const;
|
|
||||||
/** Get the value of an option, using def if it does not exist */
|
|
||||||
double getFloat(const std::string& key, double def, double min = DBL_MIN, double max = DBL_MAX) const;
|
|
||||||
/** Get the value of an option, using def if it does not exist */
|
|
||||||
bool getBool(const std::string& key, bool def = false) const;
|
bool getBool(const std::string& key, bool def = false) const;
|
||||||
/** Get the value of an option, using def if it does not exist */
|
/** Get the value of an option, using def if it does not exist */
|
||||||
unsigned char getCharacter(const std::string& key, unsigned char def = '\0') const;
|
unsigned char getCharacter(const std::string& key, unsigned char def = '\0') const;
|
||||||
@ -408,7 +447,7 @@ public:
|
|||||||
* The IRC server will not allow more than this
|
* The IRC server will not allow more than this
|
||||||
* number of local users.
|
* number of local users.
|
||||||
*/
|
*/
|
||||||
unsigned long SoftLimit;
|
size_t SoftLimit;
|
||||||
|
|
||||||
/** Maximum number of targets for a multi target command
|
/** Maximum number of targets for a multi target command
|
||||||
* such as PRIVMSG or KICK
|
* such as PRIVMSG or KICK
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <cinttypes>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
@ -655,7 +656,7 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
long ConfigTag::getInt(const std::string& key, long def, long min, long max) const
|
intmax_t ConfigTag::getSInt(const std::string& key, intmax_t def, intmax_t min, intmax_t max) const
|
||||||
{
|
{
|
||||||
std::string result;
|
std::string result;
|
||||||
if(!readString(key, result) || result.empty())
|
if(!readString(key, result) || result.empty())
|
||||||
@ -663,7 +664,7 @@ long ConfigTag::getInt(const std::string& key, long def, long min, long max) con
|
|||||||
|
|
||||||
const char* res_cstr = result.c_str();
|
const char* res_cstr = result.c_str();
|
||||||
char* res_tail = nullptr;
|
char* res_tail = nullptr;
|
||||||
long res = strtol(res_cstr, &res_tail, 0);
|
intmax_t res = strtoimax(res_cstr, &res_tail, 0);
|
||||||
if (res_tail == res_cstr)
|
if (res_tail == res_cstr)
|
||||||
return def;
|
return def;
|
||||||
|
|
||||||
@ -672,7 +673,7 @@ long ConfigTag::getInt(const std::string& key, long def, long min, long max) con
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long ConfigTag::getUInt(const std::string& key, unsigned long def, unsigned long min, unsigned long max) const
|
uintmax_t ConfigTag::getUInt(const std::string& key, uintmax_t def, uintmax_t min, uintmax_t max) const
|
||||||
{
|
{
|
||||||
std::string result;
|
std::string result;
|
||||||
if (!readString(key, result) || result.empty())
|
if (!readString(key, result) || result.empty())
|
||||||
@ -680,7 +681,7 @@ unsigned long ConfigTag::getUInt(const std::string& key, unsigned long def, unsi
|
|||||||
|
|
||||||
const char* res_cstr = result.c_str();
|
const char* res_cstr = result.c_str();
|
||||||
char* res_tail = nullptr;
|
char* res_tail = nullptr;
|
||||||
unsigned long res = strtoul(res_cstr, &res_tail, 0);
|
uintmax_t res = strtoumax(res_cstr, &res_tail, 0);
|
||||||
if (res_tail == res_cstr)
|
if (res_tail == res_cstr)
|
||||||
return def;
|
return def;
|
||||||
|
|
||||||
@ -706,13 +707,13 @@ unsigned long ConfigTag::getDuration(const std::string& key, unsigned long def,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
double ConfigTag::getFloat(const std::string& key, double def, double min, double max) const
|
long double ConfigTag::getFloat(const std::string& key, long double def, long double min, long double max) const
|
||||||
{
|
{
|
||||||
std::string result;
|
std::string result;
|
||||||
if (!readString(key, result))
|
if (!readString(key, result))
|
||||||
return def;
|
return def;
|
||||||
|
|
||||||
double res = strtod(result.c_str(), nullptr);
|
long double res = strtold(result.c_str(), nullptr);
|
||||||
CheckRange(this, key, res, def, min, max);
|
CheckRange(this, key, res, def, min, max);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -41,17 +41,17 @@
|
|||||||
#include "exitcodes.h"
|
#include "exitcodes.h"
|
||||||
|
|
||||||
ServerLimits::ServerLimits(const std::shared_ptr<ConfigTag>& tag)
|
ServerLimits::ServerLimits(const std::shared_ptr<ConfigTag>& tag)
|
||||||
: MaxLine(tag->getUInt("maxline", 512, 512))
|
: MaxLine(tag->getNum<size_t>("maxline", 512, 512))
|
||||||
, MaxNick(tag->getUInt("maxnick", 30, 1, MaxLine))
|
, MaxNick(tag->getNum<size_t>("maxnick", 30, 1, MaxLine))
|
||||||
, MaxChannel(tag->getUInt("maxchan", 60, 1, MaxLine))
|
, MaxChannel(tag->getNum<size_t>("maxchan", 60, 1, MaxLine))
|
||||||
, MaxModes(tag->getUInt("maxmodes", 20, 1))
|
, MaxModes(tag->getNum<size_t>("maxmodes", 20, 1))
|
||||||
, MaxUser(tag->getUInt("maxident", 10, 1))
|
, MaxUser(tag->getNum<size_t>("maxident", 10, 1))
|
||||||
, MaxQuit(tag->getUInt("maxquit", 300, 0, MaxLine))
|
, MaxQuit(tag->getNum<size_t>("maxquit", 300, 0, MaxLine))
|
||||||
, MaxTopic(tag->getUInt("maxtopic", 330, 1, MaxLine))
|
, MaxTopic(tag->getNum<size_t>("maxtopic", 330, 1, MaxLine))
|
||||||
, MaxKick(tag->getUInt("maxkick", 300, 1, MaxLine))
|
, MaxKick(tag->getNum<size_t>("maxkick", 300, 1, MaxLine))
|
||||||
, MaxReal(tag->getUInt("maxreal", 130, 1, MaxLine))
|
, MaxReal(tag->getNum<size_t>("maxreal", 130, 1, MaxLine))
|
||||||
, MaxAway(tag->getUInt("maxaway", 200, 1, MaxLine))
|
, MaxAway(tag->getNum<size_t>("maxaway", 200, 1, MaxLine))
|
||||||
, MaxHost(tag->getUInt("maxhost", 64, 1, MaxLine))
|
, MaxHost(tag->getNum<size_t>("maxhost", 64, 1, MaxLine))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,22 +298,22 @@ void ServerConfig::Fill()
|
|||||||
if (!nsid.empty() && nsid != sid)
|
if (!nsid.empty() && nsid != sid)
|
||||||
throw CoreException("You must restart to change the server id");
|
throw CoreException("You must restart to change the server id");
|
||||||
}
|
}
|
||||||
SoftLimit = ConfValue("performance")->getUInt("softlimit", (SocketEngine::GetMaxFds() > 0 ? SocketEngine::GetMaxFds() : LONG_MAX), 10);
|
SoftLimit = ConfValue("performance")->getNum<size_t>("softlimit", (SocketEngine::GetMaxFds() > 0 ? SocketEngine::GetMaxFds() : SIZE_MAX), 10);
|
||||||
MaxConn = static_cast<int>(ConfValue("performance")->getUInt("somaxconn", SOMAXCONN));
|
MaxConn = ConfValue("performance")->getNum<int>("somaxconn", SOMAXCONN, 1);
|
||||||
TimeSkipWarn = ConfValue("performance")->getDuration("timeskipwarn", 2, 0, 30);
|
TimeSkipWarn = ConfValue("performance")->getDuration("timeskipwarn", 2, 0, 30);
|
||||||
XLineMessage = options->getString("xlinemessage", "You're banned!", 1);
|
XLineMessage = options->getString("xlinemessage", "You're banned!", 1);
|
||||||
ServerDesc = server->getString("description", "Configure Me", 1);
|
ServerDesc = server->getString("description", "Configure Me", 1);
|
||||||
Network = server->getString("network", "Network", 1);
|
Network = server->getString("network", "Network", 1);
|
||||||
NetBufferSize = ConfValue("performance")->getInt("netbuffersize", 10240, 1024, 65534);
|
NetBufferSize = ConfValue("performance")->getNum<size_t>("netbuffersize", 10240, 1024, 65534);
|
||||||
CustomVersion = security->getString("customversion");
|
CustomVersion = security->getString("customversion");
|
||||||
HideBans = security->getBool("hidebans");
|
HideBans = security->getBool("hidebans");
|
||||||
HideServer = security->getString("hideserver", "", InspIRCd::IsFQDN);
|
HideServer = security->getString("hideserver", "", InspIRCd::IsFQDN);
|
||||||
SyntaxHints = options->getBool("syntaxhints");
|
SyntaxHints = options->getBool("syntaxhints");
|
||||||
FullHostInTopic = options->getBool("hostintopic");
|
FullHostInTopic = options->getBool("hostintopic");
|
||||||
MaxTargets = security->getUInt("maxtargets", 20, 1, 31);
|
MaxTargets = security->getNum<unsigned long>("maxtargets", 5, 1, 50);
|
||||||
DefaultModes = options->getString("defaultmodes", "not");
|
DefaultModes = options->getString("defaultmodes", "not");
|
||||||
c_ipv4_range = ConfValue("cidr")->getUInt("ipv4clone", 32, 1, 32);
|
c_ipv4_range = ConfValue("cidr")->getNum<unsigned char>("ipv4clone", 32, 1, 32);
|
||||||
c_ipv6_range = ConfValue("cidr")->getUInt("ipv6clone", 128, 1, 128);
|
c_ipv6_range = ConfValue("cidr")->getNum<unsigned char>("ipv6clone", 128, 1, 128);
|
||||||
Limits = ServerLimits(ConfValue("limits"));
|
Limits = ServerLimits(ConfValue("limits"));
|
||||||
Paths = ServerPaths(ConfValue("path"));
|
Paths = ServerPaths(ConfValue("path"));
|
||||||
NoSnoticeStack = options->getBool("nosnoticestack", false);
|
NoSnoticeStack = options->getBool("nosnoticestack", false);
|
||||||
|
@ -215,7 +215,7 @@ public:
|
|||||||
ServerInstance->Modules.Detach(events, this, sizeof(events)/sizeof(Implementation));
|
ServerInstance->Modules.Detach(events, this, sizeof(events)/sizeof(Implementation));
|
||||||
|
|
||||||
const auto& limitstag = ServerInstance->Config->ConfValue("limits");
|
const auto& limitstag = ServerInstance->Config->ConfValue("limits");
|
||||||
keymode.maxkeylen = limitstag->getUInt("maxkey", 32, 1, ModeParser::MODE_PARAM_MAX);
|
keymode.maxkeylen = limitstag->getNum<size_t>("maxkey", 32, 1, ModeParser::MODE_PARAM_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnBuildISupport(ISupport::TokenMap& tokens) override
|
void OnBuildISupport(ISupport::TokenMap& tokens) override
|
||||||
@ -258,7 +258,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
unsigned long maxchans = user->GetClass()->maxchans;
|
unsigned long maxchans = user->GetClass()->maxchans;
|
||||||
if (user->IsOper())
|
if (user->IsOper())
|
||||||
maxchans = user->oper->GetConfig()->getUInt("maxchans", maxchans, maxchans);
|
maxchans = user->oper->GetConfig()->getNum<unsigned long>("maxchans", maxchans, maxchans);
|
||||||
|
|
||||||
if (user->chans.size() >= maxchans)
|
if (user->chans.size() >= maxchans)
|
||||||
{
|
{
|
||||||
|
@ -919,7 +919,7 @@ public:
|
|||||||
SourceIP = tag->getString("sourceip");
|
SourceIP = tag->getString("sourceip");
|
||||||
|
|
||||||
const in_port_t oldport = SourcePort;
|
const in_port_t oldport = SourcePort;
|
||||||
SourcePort = static_cast<in_port_t>(tag->getUInt("sourceport", 0, 0, 65535));
|
SourcePort = tag->getNum<in_port_t>("sourceport", 0);
|
||||||
|
|
||||||
if (DNSServer.empty())
|
if (DNSServer.empty())
|
||||||
FindDNSServer();
|
FindDNSServer();
|
||||||
|
@ -448,8 +448,8 @@ public:
|
|||||||
void ReadConfig(ConfigStatus& status) override
|
void ReadConfig(ConfigStatus& status) override
|
||||||
{
|
{
|
||||||
const auto& tag = ServerInstance->Config->ConfValue("whowas");
|
const auto& tag = ServerInstance->Config->ConfValue("whowas");
|
||||||
unsigned int NewGroupSize = static_cast<unsigned int>(tag->getUInt("groupsize", 10, 0, 10000));
|
unsigned int NewGroupSize = tag->getNum<unsigned int>("groupsize", 10, 0, 10000);
|
||||||
unsigned int NewMaxGroups = static_cast<unsigned int>(tag->getUInt("maxgroups", 10240, 0, 1000000));
|
unsigned int NewMaxGroups = tag->getNum<unsigned int>("maxgroups", 10240, 0, 1000000);
|
||||||
unsigned int NewMaxKeep = static_cast<unsigned int>(tag->getDuration("maxkeep", 3600, 3600));
|
unsigned int NewMaxKeep = static_cast<unsigned int>(tag->getDuration("maxkeep", 3600, 3600));
|
||||||
|
|
||||||
cmd.manager.UpdateConfig(NewGroupSize, NewMaxGroups, NewMaxKeep);
|
cmd.manager.UpdateConfig(NewGroupSize, NewMaxGroups, NewMaxKeep);
|
||||||
|
@ -32,7 +32,7 @@ bool InsaneBan::MatchesEveryone(const std::string& mask, MatcherBase& test, User
|
|||||||
if (insane->getBool(confkey))
|
if (insane->getBool(confkey))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
float itrigger = insane->getFloat("trigger", 95.5, 0.0, 100.0);
|
float itrigger = insane->getNum<float>("trigger", 95.5, 0.0, 100.0);
|
||||||
|
|
||||||
long matches = test.Run(mask);
|
long matches = test.Run(mask);
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ void ListModeBase::DoRehash()
|
|||||||
if (!mname.empty() && !stdalgo::string::equalsci(mname, name) && !(mname.length() == 1 && GetModeChar() == mname[0]))
|
if (!mname.empty() && !stdalgo::string::equalsci(mname, name) && !(mname.length() == 1 && GetModeChar() == mname[0]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ListLimit limit(c->getString("chan", "*", 1), c->getUInt("limit", DEFAULT_LIST_SIZE));
|
ListLimit limit(c->getString("chan", "*", 1), c->getNum<unsigned long>("limit", DEFAULT_LIST_SIZE));
|
||||||
|
|
||||||
if (limit.mask.empty())
|
if (limit.mask.empty())
|
||||||
throw ModuleException(creator, INSP_FORMAT("<maxlist:chan> is empty, at {}", c->source.str()));
|
throw ModuleException(creator, INSP_FORMAT("<maxlist:chan> is empty, at {}", c->source.str()));
|
||||||
|
@ -131,7 +131,7 @@ Log::MethodPtr Log::FileEngine::Create(const std::shared_ptr<ConfigTag>& tag)
|
|||||||
tag->source.str(), strerror(errno)));
|
tag->source.str(), strerror(errno)));
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned long flush = tag->getUInt("flush", 20, 1);
|
const unsigned long flush = tag->getNum<unsigned long>("flush", 20, 1);
|
||||||
return std::make_shared<FileMethod>(fulltarget, fh, flush, true);
|
return std::make_shared<FileMethod>(fulltarget, fh, flush, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,25 +34,6 @@
|
|||||||
|
|
||||||
class ProviderConfig final
|
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:
|
public:
|
||||||
uint32_t iterations;
|
uint32_t iterations;
|
||||||
uint32_t lanes;
|
uint32_t lanes;
|
||||||
@ -72,25 +53,28 @@ public:
|
|||||||
const auto& tag = ServerInstance->Config->ConfValue(tagname);
|
const auto& tag = ServerInstance->Config->ConfValue(tagname);
|
||||||
|
|
||||||
uint32_t def_iterations = def ? def->iterations : 3;
|
uint32_t def_iterations = def ? def->iterations : 3;
|
||||||
this->iterations = static_cast<uint32_t>(tag->getUInt("iterations", def_iterations, 1, UINT32_MAX));
|
this->iterations = tag->getNum<uint32_t>("iterations", def_iterations, 1);
|
||||||
|
|
||||||
uint32_t def_lanes = def ? def->lanes : 1;
|
uint32_t def_lanes = def ? def->lanes : 1;
|
||||||
this->lanes = static_cast<uint32_t>(tag->getUInt("lanes", def_lanes, ARGON2_MIN_LANES, ARGON2_MAX_LANES));
|
this->lanes = tag->getNum<uint32_t>("lanes", def_lanes, ARGON2_MIN_LANES, ARGON2_MAX_LANES);
|
||||||
|
|
||||||
uint32_t def_memory = def ? def->memory : 131072; // 128 MiB
|
uint32_t def_memory = def ? def->memory : 131072; // 128 MiB
|
||||||
this->memory = static_cast<uint32_t>(tag->getUInt("memory", def_memory, ARGON2_MIN_MEMORY, ARGON2_MAX_MEMORY));
|
this->memory = tag->getNum<uint32_t>("memory", def_memory, ARGON2_MIN_MEMORY, ARGON2_MAX_MEMORY);
|
||||||
|
|
||||||
uint32_t def_outlen = def ? def->outlen : 32;
|
uint32_t def_outlen = def ? def->outlen : 32;
|
||||||
this->outlen = static_cast<uint32_t>(tag->getUInt("length", def_outlen, ARGON2_MIN_OUTLEN, ARGON2_MAX_OUTLEN));
|
this->outlen = tag->getNum<int32_t>("length", def_outlen, ARGON2_MIN_OUTLEN, ARGON2_MAX_OUTLEN);
|
||||||
|
|
||||||
uint32_t def_saltlen = def ? def->saltlen : 16;
|
uint32_t def_saltlen = def ? def->saltlen : 16;
|
||||||
this->saltlen = static_cast<uint32_t>(tag->getUInt("saltlength", def_saltlen, ARGON2_MIN_SALT_LENGTH, ARGON2_MAX_SALT_LENGTH));
|
this->saltlen = tag->getNum<uint32_t>("saltlength", def_saltlen, ARGON2_MIN_SALT_LENGTH, ARGON2_MAX_SALT_LENGTH);
|
||||||
|
|
||||||
uint32_t def_threads = def ? def->threads : 1;
|
uint32_t def_threads = def ? def->threads : 1;
|
||||||
this->threads = static_cast<uint32_t>(tag->getUInt("threads", def_threads, ARGON2_MIN_THREADS, ARGON2_MAX_THREADS));
|
this->threads = tag->getNum<uint32_t>("threads", def_threads, ARGON2_MIN_THREADS, ARGON2_MAX_THREADS);
|
||||||
|
|
||||||
uint32_t def_version = def ? def->version : 13;
|
Argon2_version def_version = def ? def->version : ARGON2_VERSION_13;
|
||||||
this->version = SanitizeArgon2Version(tag->getUInt("version", def_version));
|
this->version = tag->getEnum("version", def_version, {
|
||||||
|
{ "10", ARGON2_VERSION_10 },
|
||||||
|
{ "13", ARGON2_VERSION_13 },
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ public:
|
|||||||
fulltarget, tag->source.str(), strerror(errno)));
|
fulltarget, tag->source.str(), strerror(errno)));
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned long flush = tag->getUInt("flush", 20, 1);
|
const unsigned long flush = tag->getNum<unsigned long>("flush", 20, 1);
|
||||||
return std::make_shared<JSONMethod>(fulltarget, fh, flush, true);
|
return std::make_shared<JSONMethod>(fulltarget, fh, flush, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -335,7 +335,7 @@ public:
|
|||||||
const std::string user = config->getString("user");
|
const std::string user = config->getString("user");
|
||||||
const std::string pass = config->getString("pass");
|
const std::string pass = config->getString("pass");
|
||||||
const std::string dbname = config->getString("name");
|
const std::string dbname = config->getString("name");
|
||||||
unsigned int port = static_cast<unsigned int>(config->getUInt("port", 3306, 1, 65535));
|
unsigned int port = config->getNum<unsigned int>("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))
|
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: {}",
|
ServerInstance->Logs.Error(MODNAME, "Unable to connect to the {} MySQL server: {}",
|
||||||
|
@ -541,7 +541,7 @@ namespace GnuTLS
|
|||||||
, dh(DHParams::Import(ReadFile(tag->getString("dhfile", "dhparams.pem", 1))))
|
, dh(DHParams::Import(ReadFile(tag->getString("dhfile", "dhparams.pem", 1))))
|
||||||
#endif
|
#endif
|
||||||
, priostr(GetPrioStr(profilename, tag))
|
, priostr(GetPrioStr(profilename, tag))
|
||||||
, mindh(static_cast<unsigned int>(tag->getUInt("mindhbits", 1024, 0, UINT32_MAX)))
|
, mindh(tag->getNum<unsigned int>("mindhbits", 1024))
|
||||||
, hashstr(tag->getString("hash", "sha256", 1))
|
, hashstr(tag->getString("hash", "sha256", 1))
|
||||||
, requestclientcert(tag->getBool("requestclientcert", true))
|
, requestclientcert(tag->getBool("requestclientcert", true))
|
||||||
{
|
{
|
||||||
@ -556,7 +556,7 @@ namespace GnuTLS
|
|||||||
crl.reset(new X509CRL(ReadFile(filename)));
|
crl.reset(new X509CRL(ReadFile(filename)));
|
||||||
}
|
}
|
||||||
|
|
||||||
outrecsize = static_cast<unsigned int>(tag->getUInt("outrecsize", 2048, 512, UINT32_MAX));
|
outrecsize = tag->getNum<unsigned int>("outrecsize", 2048, 512);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -451,12 +451,12 @@ namespace mbedTLS
|
|||||||
, dhstr(ReadFile(tag->getString("dhfile", "dhparams.pem", 1)))
|
, dhstr(ReadFile(tag->getString("dhfile", "dhparams.pem", 1)))
|
||||||
, ciphersuitestr(tag->getString("ciphersuites"))
|
, ciphersuitestr(tag->getString("ciphersuites"))
|
||||||
, curvestr(tag->getString("curves"))
|
, curvestr(tag->getString("curves"))
|
||||||
, mindh(static_cast<unsigned int>(tag->getUInt("mindhbits", 2048, 0, UINT32_MAX)))
|
, mindh(tag->getNum<unsigned int>("mindhbits", 2048))
|
||||||
, hashstr(tag->getString("hash", "sha256", 1))
|
, hashstr(tag->getString("hash", "sha256", 1))
|
||||||
, castr(tag->getString("cafile"))
|
, castr(tag->getString("cafile"))
|
||||||
, minver(static_cast<int>(tag->getUInt("minver", 0, 0, INT32_MAX)))
|
, minver(tag->getNum<int>("minver", 0))
|
||||||
, maxver(static_cast<int>(tag->getUInt("maxver", 0, 0, INT32_MAX)))
|
, maxver(tag->getNum<int>("maxver", 0))
|
||||||
, outrecsize(static_cast<unsigned int>(tag->getUInt("outrecsize", 2048, 512, 16384)))
|
, outrecsize(tag->getNum<unsigned int>("outrecsize", 2048, 512, 16384))
|
||||||
, requestclientcert(tag->getBool("requestclientcert", true))
|
, requestclientcert(tag->getBool("requestclientcert", true))
|
||||||
{
|
{
|
||||||
if (!castr.empty())
|
if (!castr.empty())
|
||||||
|
@ -326,8 +326,8 @@ namespace OpenSSL
|
|||||||
*/
|
*/
|
||||||
void SetContextOptions(const std::string& ctxname, const std::shared_ptr<ConfigTag>& tag, Context& context)
|
void SetContextOptions(const std::string& ctxname, const std::shared_ptr<ConfigTag>& tag, Context& context)
|
||||||
{
|
{
|
||||||
long setoptions = tag->getInt(ctxname + "setoptions", 0);
|
long setoptions = tag->getNum<long>(ctxname + "setoptions", 0);
|
||||||
long clearoptions = tag->getInt(ctxname + "clearoptions", 0);
|
long clearoptions = tag->getNum<long>(ctxname + "clearoptions", 0);
|
||||||
|
|
||||||
#ifdef SSL_OP_NO_COMPRESSION
|
#ifdef SSL_OP_NO_COMPRESSION
|
||||||
// Disable compression by default
|
// Disable compression by default
|
||||||
@ -370,7 +370,7 @@ namespace OpenSSL
|
|||||||
, ctx(SSL_CTX_new(TLS_server_method()))
|
, ctx(SSL_CTX_new(TLS_server_method()))
|
||||||
, clientctx(SSL_CTX_new(TLS_client_method()))
|
, clientctx(SSL_CTX_new(TLS_client_method()))
|
||||||
, allowrenego(tag->getBool("renegotiation")) // Disallow by default
|
, allowrenego(tag->getBool("renegotiation")) // Disallow by default
|
||||||
, outrecsize(static_cast<unsigned int>(tag->getUInt("outrecsize", 2048, 512, 16384)))
|
, outrecsize(tag->getNum<unsigned int>("outrecsize", 2048, 512, 16384))
|
||||||
{
|
{
|
||||||
#ifndef INSPIRCD_OPENSSL_AUTO_DH
|
#ifndef INSPIRCD_OPENSSL_AUTO_DH
|
||||||
if ((!ctx.SetDH(dh)) || (!clientctx.SetDH(dh)))
|
if ((!ctx.SetDH(dh)) || (!clientctx.SetDH(dh)))
|
||||||
|
@ -87,7 +87,7 @@ public:
|
|||||||
void ReadConfig(ConfigStatus& status) override
|
void ReadConfig(ConfigStatus& status) override
|
||||||
{
|
{
|
||||||
const auto& conf = ServerInstance->Config->ConfValue("bcrypt");
|
const auto& conf = ServerInstance->Config->ConfValue("bcrypt");
|
||||||
bcrypt.rounds = conf->getUInt("rounds", 10, 1);
|
bcrypt.rounds = conf->getNum<unsigned long>("rounds", 10, 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -460,7 +460,7 @@ public:
|
|||||||
void ReadConfig(ConfigStatus& status) override
|
void ReadConfig(ConfigStatus& status) override
|
||||||
{
|
{
|
||||||
const auto& tag = ServerInstance->Config->ConfValue("callerid");
|
const auto& tag = ServerInstance->Config->ConfValue("callerid");
|
||||||
cmd.maxaccepts = tag->getUInt("maxaccepts", 30);
|
cmd.maxaccepts = tag->getNum<unsigned long>("maxaccepts", 30, 1);
|
||||||
tracknick = tag->getBool("tracknick");
|
tracknick = tag->getBool("tracknick");
|
||||||
notify_cooldown = tag->getDuration("cooldown", 60);
|
notify_cooldown = tag->getDuration("cooldown", 60);
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ public:
|
|||||||
{
|
{
|
||||||
const auto& tag = ServerInstance->Config->ConfValue("chanfilter");
|
const auto& tag = ServerInstance->Config->ConfValue("chanfilter");
|
||||||
hidemask = tag->getBool("hidemask");
|
hidemask = tag->getBool("hidemask");
|
||||||
cf.maxlen = tag->getUInt("maxlen", 35, 10, ModeParser::MODE_PARAM_MAX);
|
cf.maxlen = tag->getNum<unsigned long>("maxlen", 35, 10, ModeParser::MODE_PARAM_MAX);
|
||||||
notifyuser = tag->getBool("notifyuser", true);
|
notifyuser = tag->getBool("notifyuser", true);
|
||||||
cf.DoRehash();
|
cf.DoRehash();
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ public:
|
|||||||
void ReadConfig(ConfigStatus& status) override
|
void ReadConfig(ConfigStatus& status) override
|
||||||
{
|
{
|
||||||
const auto& tag = ServerInstance->Config->ConfValue("chanhistory");
|
const auto& tag = ServerInstance->Config->ConfValue("chanhistory");
|
||||||
historymode.maxlines = tag->getUInt("maxlines", 50, 1);
|
historymode.maxlines = tag->getNum<unsigned long>("maxlines", 50, 1);
|
||||||
prefixmsg = tag->getBool("prefixmsg", true);
|
prefixmsg = tag->getBool("prefixmsg", true);
|
||||||
dobots = tag->getBool("bots", true);
|
dobots = tag->getBool("bots", true);
|
||||||
}
|
}
|
||||||
|
@ -306,7 +306,7 @@ public:
|
|||||||
|
|
||||||
if (halfcloak)
|
if (halfcloak)
|
||||||
{
|
{
|
||||||
unsigned int domainparts = static_cast<unsigned int>(tag->getUInt("domainparts", 3, 1, 10));
|
unsigned int domainparts = tag->getNum<unsigned int>("domainparts", 3, 1, 10);
|
||||||
return std::make_shared<CloakInfo>(this, MODE_HALF_CLOAK, key, prefix, suffix, ignorecase, domainparts);
|
return std::make_shared<CloakInfo>(this, MODE_HALF_CLOAK, key, prefix, suffix, ignorecase, domainparts);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -188,9 +188,9 @@ public:
|
|||||||
SHA256Method(const Cloak::Engine* engine, const std::shared_ptr<ConfigTag>& tag, const std::string& k, psl_ctx_t* p, bool ch) ATTR_NOT_NULL(2)
|
SHA256Method(const Cloak::Engine* engine, const std::shared_ptr<ConfigTag>& tag, const std::string& k, psl_ctx_t* p, bool ch) ATTR_NOT_NULL(2)
|
||||||
: Cloak::Method(engine)
|
: Cloak::Method(engine)
|
||||||
, cloakhost(ch)
|
, cloakhost(ch)
|
||||||
, hostparts(tag->getUInt("hostparts", 3, 0, ServerInstance->Config->Limits.MaxHost / 2))
|
, hostparts(tag->getNum<unsigned long>("hostparts", 3, 0, ServerInstance->Config->Limits.MaxHost / 2))
|
||||||
, key(k)
|
, key(k)
|
||||||
, pathparts(tag->getUInt("pathparts", 1, 0, ServerInstance->Config->Limits.MaxHost / 2))
|
, pathparts(tag->getNum<unsigned long>("pathparts", 1, 0, ServerInstance->Config->Limits.MaxHost / 2))
|
||||||
, prefix(tag->getString("prefix"))
|
, prefix(tag->getString("prefix"))
|
||||||
#ifdef HAS_LIBPSL
|
#ifdef HAS_LIBPSL
|
||||||
, psl(p)
|
, psl(p)
|
||||||
|
@ -264,11 +264,11 @@ public:
|
|||||||
std::unique_ptr<Codepage> newcodepage = std::make_unique<SingleByteCodepage>();
|
std::unique_ptr<Codepage> newcodepage = std::make_unique<SingleByteCodepage>();
|
||||||
for (const auto& [_, tag] : ServerInstance->Config->ConfTags("cpchars"))
|
for (const auto& [_, tag] : ServerInstance->Config->ConfTags("cpchars"))
|
||||||
{
|
{
|
||||||
unsigned long begin = tag->getUInt("begin", tag->getUInt("index", 0));
|
unsigned long begin = tag->getNum<unsigned long>("begin", tag->getNum<unsigned long>("index", 0));
|
||||||
if (!begin)
|
if (!begin)
|
||||||
throw ModuleException(this, "<cpchars> tag without index or begin specified at " + tag->source.str());
|
throw ModuleException(this, "<cpchars> tag without index or begin specified at " + tag->source.str());
|
||||||
|
|
||||||
unsigned long end = tag->getUInt("end", begin);
|
unsigned long end = tag->getNum<unsigned long>("end", begin);
|
||||||
if (begin > end)
|
if (begin > end)
|
||||||
throw ModuleException(this, "<cpchars:begin> must be lower than <cpchars:end> at " + tag->source.str());
|
throw ModuleException(this, "<cpchars:begin> must be lower than <cpchars:end> at " + tag->source.str());
|
||||||
|
|
||||||
@ -296,11 +296,11 @@ public:
|
|||||||
|
|
||||||
for (const auto& [_, tag] : ServerInstance->Config->ConfTags("cpcase"))
|
for (const auto& [_, tag] : ServerInstance->Config->ConfTags("cpcase"))
|
||||||
{
|
{
|
||||||
unsigned long lower = tag->getUInt("lower", 0);
|
unsigned long lower = tag->getNum<unsigned long>("lower", 0);
|
||||||
if (!lower)
|
if (!lower)
|
||||||
throw ModuleException(this, "<cpcase:lower> is required at " + tag->source.str());
|
throw ModuleException(this, "<cpcase:lower> is required at " + tag->source.str());
|
||||||
|
|
||||||
unsigned long upper = tag->getUInt("upper", 0);
|
unsigned long upper = tag->getNum<unsigned long>("upper", 0);
|
||||||
if (!upper)
|
if (!upper)
|
||||||
throw ModuleException(this, "<cpcase:upper> is required at " + tag->source.str());
|
throw ModuleException(this, "<cpcase:upper> is required at " + tag->source.str());
|
||||||
|
|
||||||
|
@ -100,9 +100,9 @@ public:
|
|||||||
{
|
{
|
||||||
const auto& tag = ServerInstance->Config->ConfValue("connectban");
|
const auto& tag = ServerInstance->Config->ConfValue("connectban");
|
||||||
|
|
||||||
ipv4_cidr = static_cast<unsigned int>(tag->getUInt("ipv4cidr", ServerInstance->Config->c_ipv4_range, 1, 32));
|
ipv4_cidr = tag->getNum<unsigned int>("ipv4cidr", ServerInstance->Config->c_ipv4_range, 1, 32);
|
||||||
ipv6_cidr = static_cast<unsigned int>(tag->getUInt("ipv6cidr", ServerInstance->Config->c_ipv6_range, 1, 128));
|
ipv6_cidr = tag->getNum<unsigned int>("ipv6cidr", ServerInstance->Config->c_ipv6_range, 1, 128);
|
||||||
threshold = tag->getUInt("threshold", 10, 1);
|
threshold = tag->getNum<unsigned long>("threshold", 10, 1);
|
||||||
bootwait = tag->getDuration("bootwait", 60*2);
|
bootwait = tag->getDuration("bootwait", 60*2);
|
||||||
splitwait = tag->getDuration("splitwait", 60*2);
|
splitwait = tag->getDuration("splitwait", 60*2);
|
||||||
banduration = tag->getDuration("banduration", 6*60*60, 1);
|
banduration = tag->getDuration("banduration", 6*60*60, 1);
|
||||||
|
@ -60,7 +60,7 @@ public:
|
|||||||
const auto& tag = ServerInstance->Config->ConfValue("connflood");
|
const auto& tag = ServerInstance->Config->ConfValue("connflood");
|
||||||
/* throttle configuration */
|
/* throttle configuration */
|
||||||
seconds = tag->getDuration("period", 30);
|
seconds = tag->getDuration("period", 30);
|
||||||
maxconns = tag->getUInt("maxconns", 3);
|
maxconns = tag->getNum<unsigned long>("maxconns", 3);
|
||||||
timeout = tag->getDuration("timeout", 30);
|
timeout = tag->getDuration("timeout", 30);
|
||||||
quitmsg = tag->getString("quitmsg");
|
quitmsg = tag->getString("quitmsg");
|
||||||
|
|
||||||
|
@ -32,9 +32,9 @@ public:
|
|||||||
: PrefixMode(parent, Name, Letter, 0, Prefix)
|
: PrefixMode(parent, Name, Letter, 0, Prefix)
|
||||||
, tag(Tag)
|
, tag(Tag)
|
||||||
{
|
{
|
||||||
ModeHandler::Rank rank = static_cast<ModeHandler::Rank>(tag->getUInt("rank", 1, 1, std::numeric_limits<ModeHandler::Rank>::max()));
|
ModeHandler::Rank rank = tag->getNum<ModeHandler::Rank>("rank", 1, 1);
|
||||||
ModeHandler::Rank setrank = static_cast<ModeHandler::Rank>(tag->getUInt("ranktoset", prefixrank, rank, std::numeric_limits<ModeHandler::Rank>::max()));
|
ModeHandler::Rank setrank = tag->getNum<ModeHandler::Rank>("ranktoset", prefixrank, rank);
|
||||||
ModeHandler::Rank unsetrank = static_cast<ModeHandler::Rank>(tag->getUInt("ranktounset", setrank, setrank, std::numeric_limits<ModeHandler::Rank>::max()));
|
ModeHandler::Rank unsetrank = tag->getNum<ModeHandler::Rank>("ranktounset", setrank, setrank);
|
||||||
bool depriv = tag->getBool("depriv", true);
|
bool depriv = tag->getBool("depriv", true);
|
||||||
this->Update(rank, setrank, unsetrank, depriv);
|
this->Update(rank, setrank, unsetrank, depriv);
|
||||||
|
|
||||||
@ -77,9 +77,9 @@ public:
|
|||||||
if (!pm)
|
if (!pm)
|
||||||
throw ModuleException(this, "<customprefix:change> specified for a non-prefix mode at " + tag->source.str());
|
throw ModuleException(this, "<customprefix:change> specified for a non-prefix mode at " + tag->source.str());
|
||||||
|
|
||||||
ModeHandler::Rank rank = static_cast<ModeHandler::Rank>(tag->getUInt("rank", pm->GetPrefixRank(), 1, std::numeric_limits<ModeHandler::Rank>::max()));
|
ModeHandler::Rank rank = tag->getNum<ModeHandler::Rank>("rank", pm->GetPrefixRank(), 1);
|
||||||
ModeHandler::Rank setrank = static_cast<ModeHandler::Rank>(tag->getUInt("ranktoset", pm->GetLevelRequired(true), rank, std::numeric_limits<ModeHandler::Rank>::max()));
|
ModeHandler::Rank setrank = tag->getNum<ModeHandler::Rank>("ranktoset", pm->GetLevelRequired(true), rank);
|
||||||
ModeHandler::Rank unsetrank = static_cast<ModeHandler::Rank>(tag->getUInt("ranktounset", pm->GetLevelRequired(false), setrank, std::numeric_limits<ModeHandler::Rank>::max()));
|
ModeHandler::Rank unsetrank = tag->getNum<ModeHandler::Rank>("ranktounset", pm->GetLevelRequired(false), setrank);
|
||||||
bool depriv = tag->getBool("depriv", pm->CanSelfRemove());
|
bool depriv = tag->getBool("depriv", pm->CanSelfRemove());
|
||||||
pm->Update(rank, setrank, unsetrank, depriv);
|
pm->Update(rank, setrank, unsetrank, depriv);
|
||||||
|
|
||||||
|
@ -617,7 +617,7 @@ public:
|
|||||||
bfl.swap(newbfl);
|
bfl.swap(newbfl);
|
||||||
|
|
||||||
const auto& tag = ServerInstance->Config->ConfValue("dccallow");
|
const auto& tag = ServerInstance->Config->ConfValue("dccallow");
|
||||||
cmd.ext.maxentries = tag->getUInt("maxentries", 20, 1);
|
cmd.ext.maxentries = tag->getNum<unsigned long>("maxentries", 20, 1);
|
||||||
cmd.defaultlength = tag->getDuration("length", 0);
|
cmd.defaultlength = tag->getDuration("length", 0);
|
||||||
blockchat = tag->getBool("blockchat");
|
blockchat = tag->getBool("blockchat");
|
||||||
defaultaction = tag->getString("action");
|
defaultaction = tag->getString("action");
|
||||||
|
@ -134,7 +134,7 @@ public:
|
|||||||
{
|
{
|
||||||
type = Type::BITMASK;
|
type = Type::BITMASK;
|
||||||
|
|
||||||
bitmask = static_cast<unsigned int>(tag->getUInt("bitmask", 0, 0, UINT_MAX));
|
bitmask = tag->getNum<unsigned int>("bitmask", 0);
|
||||||
records = 0;
|
records = 0;
|
||||||
}
|
}
|
||||||
else if (stdalgo::string::equalsci(typestr, "record"))
|
else if (stdalgo::string::equalsci(typestr, "record"))
|
||||||
|
@ -71,7 +71,7 @@ public:
|
|||||||
throw ModuleException(this, "Empty <hidelist:mode> at " + tag->source.str());
|
throw ModuleException(this, "Empty <hidelist:mode> at " + tag->source.str());
|
||||||
// If rank is set to 0 everyone inside the channel can view the list,
|
// If rank is set to 0 everyone inside the channel can view the list,
|
||||||
// but non-members may not
|
// but non-members may not
|
||||||
ModeHandler::Rank rank = tag->getUInt("rank", HALFOP_VALUE);
|
ModeHandler::Rank rank = tag->getNum<ModeHandler::Rank>("rank", HALFOP_VALUE);
|
||||||
newconfigs.emplace_back(modename, rank);
|
newconfigs.emplace_back(modename, rank);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,11 +27,11 @@ namespace
|
|||||||
{
|
{
|
||||||
class Settings final
|
class Settings final
|
||||||
{
|
{
|
||||||
typedef insp::flat_map<std::string, unsigned int> RanksToSeeMap;
|
typedef insp::flat_map<std::string, ModeHandler::Rank> RanksToSeeMap;
|
||||||
RanksToSeeMap rankstosee;
|
RanksToSeeMap rankstosee;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
unsigned int GetRequiredRank(const ModeHandler& mh) const
|
ModeHandler::Rank GetRequiredRank(const ModeHandler& mh) const
|
||||||
{
|
{
|
||||||
RanksToSeeMap::const_iterator it = rankstosee.find(mh.name);
|
RanksToSeeMap::const_iterator it = rankstosee.find(mh.name);
|
||||||
if (it != rankstosee.end())
|
if (it != rankstosee.end())
|
||||||
@ -49,7 +49,7 @@ public:
|
|||||||
if (modename.empty())
|
if (modename.empty())
|
||||||
throw ModuleException(mod, "<hidemode:mode> is empty at " + tag->source.str());
|
throw ModuleException(mod, "<hidemode:mode> is empty at " + tag->source.str());
|
||||||
|
|
||||||
unsigned long rank = tag->getUInt("rank", 0);
|
ModeHandler::Rank rank = tag->getNum<ModeHandler::Rank>("rank", 0);
|
||||||
if (!rank)
|
if (!rank)
|
||||||
throw ModuleException(mod, "<hidemode:rank> must be greater than 0 at " + tag->source.str());
|
throw ModuleException(mod, "<hidemode:rank> must be greater than 0 at " + tag->source.str());
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ public:
|
|||||||
if (host.empty())
|
if (host.empty())
|
||||||
throw ModuleException(this, "<sts:host> must contain a hostname, at " + tag->source.str());
|
throw ModuleException(this, "<sts:host> must contain a hostname, at " + tag->source.str());
|
||||||
|
|
||||||
in_port_t port = static_cast<in_port_t>(tag->getUInt("port", 6697, 1, 65535));
|
in_port_t port = tag->getNum<in_port_t>("port", 6697, 1);
|
||||||
if (!HasValidSSLPort(port))
|
if (!HasValidSSLPort(port))
|
||||||
throw ModuleException(this, "<sts:port> must be a TLS port, at " + tag->source.str());
|
throw ModuleException(this, "<sts:port> must be a TLS port, at " + tag->source.str());
|
||||||
|
|
||||||
|
@ -138,9 +138,9 @@ public:
|
|||||||
void ReadConfig(ConfigStatus&) override
|
void ReadConfig(ConfigStatus&) override
|
||||||
{
|
{
|
||||||
const auto& tag = ServerInstance->Config->ConfValue("messageflood");
|
const auto& tag = ServerInstance->Config->ConfValue("messageflood");
|
||||||
notice = tag->getFloat("notice", 1.0);
|
notice = tag->getNum<float>("notice", 1.0);
|
||||||
privmsg = tag->getFloat("privmsg", 1.0);
|
privmsg = tag->getNum<float>("privmsg", 1.0);
|
||||||
tagmsg = tag->getFloat("tagmsg", 0.2);
|
tagmsg = tag->getNum<float>("tagmsg", 0.2);
|
||||||
kickmessage = tag->getString("kickmessage", "Message flood (trigger is %lines% messages in %duration%)", 1);
|
kickmessage = tag->getString("kickmessage", "Message flood (trigger is %lines% messages in %duration%)", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,7 +393,7 @@ public:
|
|||||||
void ReadConfig(ConfigStatus& status) override
|
void ReadConfig(ConfigStatus& status) override
|
||||||
{
|
{
|
||||||
const auto& tag = ServerInstance->Config->ConfValue("monitor");
|
const auto& tag = ServerInstance->Config->ConfValue("monitor");
|
||||||
cmd.maxmonitor = tag->getUInt("maxentries", 30, 1);
|
cmd.maxmonitor = tag->getNum<unsigned long>("maxentries", 30, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnPostConnect(User* user) override
|
void OnPostConnect(User* user) override
|
||||||
|
@ -40,8 +40,8 @@ public:
|
|||||||
// oper killing an oper?
|
// oper killing an oper?
|
||||||
if (dest->IsOper() && source->IsOper())
|
if (dest->IsOper() && source->IsOper())
|
||||||
{
|
{
|
||||||
unsigned long dest_level = dest->oper->GetConfig()->getUInt("level", 0);
|
unsigned long dest_level = dest->oper->GetConfig()->getNum<unsigned long>("level", 0);
|
||||||
unsigned long source_level = source->oper->GetConfig()->getUInt("level", 0);
|
unsigned long source_level = source->oper->GetConfig()->getNum<unsigned long>("level", 0);
|
||||||
|
|
||||||
if (dest_level > source_level)
|
if (dest_level > source_level)
|
||||||
{
|
{
|
||||||
|
@ -185,8 +185,8 @@ class ModulePBKDF2 final
|
|||||||
// First set the common values
|
// First set the common values
|
||||||
const auto& tag = ServerInstance->Config->ConfValue("pbkdf2");
|
const auto& tag = ServerInstance->Config->ConfValue("pbkdf2");
|
||||||
ProviderConfig newglobal;
|
ProviderConfig newglobal;
|
||||||
newglobal.iterations = tag->getUInt("iterations", 12288, 1);
|
newglobal.iterations = tag->getNum<unsigned long>("iterations", 12288, 1);
|
||||||
newglobal.dkey_length = tag->getUInt("length", 32, 1, 1024);
|
newglobal.dkey_length = tag->getNum<size_t>("length", 32, 1, 1024);
|
||||||
|
|
||||||
// Then the specific values
|
// Then the specific values
|
||||||
ProviderConfigMap newconfigs;
|
ProviderConfigMap newconfigs;
|
||||||
@ -195,8 +195,8 @@ class ModulePBKDF2 final
|
|||||||
std::string hash_name = "hash/" + ptag->getString("hash");
|
std::string hash_name = "hash/" + ptag->getString("hash");
|
||||||
ProviderConfig& config = newconfigs[hash_name];
|
ProviderConfig& config = newconfigs[hash_name];
|
||||||
|
|
||||||
config.iterations = ptag->getUInt("iterations", newglobal.iterations, 1);
|
config.iterations = ptag->getNum<unsigned long>("iterations", newglobal.iterations, 1);
|
||||||
config.dkey_length = ptag->getUInt("length", newglobal.dkey_length, 1, 1024);
|
config.dkey_length = ptag->getNum<size_t>("length", newglobal.dkey_length, 1, 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config is valid, apply it
|
// Config is valid, apply it
|
||||||
|
@ -218,10 +218,10 @@ public:
|
|||||||
auto* c = ServerInstance->Channels.Find(channel);
|
auto* c = ServerInstance->Channels.Find(channel);
|
||||||
if (!c)
|
if (!c)
|
||||||
{
|
{
|
||||||
time_t TS = tag->getInt("ts", ServerInstance->Time(), 1);
|
time_t TS = tag->getNum<time_t>("ts", ServerInstance->Time(), 1);
|
||||||
c = new Channel(channel, TS);
|
c = new Channel(channel, TS);
|
||||||
|
|
||||||
time_t topicset = tag->getInt("topicts", 0);
|
time_t topicset = tag->getNum<time_t>("topicts", 0);
|
||||||
std::string topic = tag->getString("topic");
|
std::string topic = tag->getString("topic");
|
||||||
|
|
||||||
if ((topicset != 0) || (!topic.empty()))
|
if ((topicset != 0) || (!topic.empty()))
|
||||||
|
@ -175,7 +175,7 @@ public:
|
|||||||
{
|
{
|
||||||
const auto& tag = ServerInstance->Config->ConfValue("remove");
|
const auto& tag = ServerInstance->Config->ConfValue("remove");
|
||||||
cmd.supportnokicks = tag->getBool("supportnokicks");
|
cmd.supportnokicks = tag->getBool("supportnokicks");
|
||||||
cmd.protectedrank = tag->getUInt("protectedrank", 50000);
|
cmd.protectedrank = tag->getNum<ModeHandler::Rank>("protectedrank", 50000, 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -248,13 +248,13 @@ public:
|
|||||||
void ReadConfig()
|
void ReadConfig()
|
||||||
{
|
{
|
||||||
const auto& conf = ServerInstance->Config->ConfValue("repeat");
|
const auto& conf = ServerInstance->Config->ConfValue("repeat");
|
||||||
ms.MaxLines = conf->getUInt("maxlines", 20);
|
ms.MaxLines = conf->getNum<unsigned long>("maxlines", 20);
|
||||||
ms.MaxBacklog = conf->getUInt("maxbacklog", 20);
|
ms.MaxBacklog = conf->getNum<unsigned long>("maxbacklog", 20);
|
||||||
ms.MaxSecs = conf->getDuration("maxtime", 0);
|
ms.MaxSecs = conf->getDuration("maxtime", 0);
|
||||||
|
|
||||||
ms.MaxDiff = static_cast<unsigned int>(conf->getUInt("maxdistance", 50, 0, 100));
|
ms.MaxDiff = conf->getNum<unsigned int>("maxdistance", 50, 0, 100);
|
||||||
|
|
||||||
unsigned long newsize = conf->getUInt("size", 512);
|
size_t newsize = conf->getNum<size_t>("size", 512);
|
||||||
if (newsize > ServerInstance->Config->Limits.MaxLine)
|
if (newsize > ServerInstance->Config->Limits.MaxLine)
|
||||||
newsize = ServerInstance->Config->Limits.MaxLine;
|
newsize = ServerInstance->Config->Limits.MaxLine;
|
||||||
Resize(newsize);
|
Resize(newsize);
|
||||||
|
@ -67,7 +67,7 @@ public:
|
|||||||
|
|
||||||
const auto& tag = ServerInstance->Config->ConfValue("securelist");
|
const auto& tag = ServerInstance->Config->ConfValue("securelist");
|
||||||
exemptregistered = tag->getBool("exemptregistered", true);
|
exemptregistered = tag->getBool("exemptregistered", true);
|
||||||
fakechans = tag->getUInt("fakechans", 5, 0);
|
fakechans = tag->getNum<unsigned long>("fakechans", 5, 0);
|
||||||
fakechanprefix = tag->getString("fakechanprefix", "#", 1, ServerInstance->Config->Limits.MaxChannel - 1);
|
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);
|
fakechantopic = tag->getString("fakechantopic", "Fake channel for confusing spambots", 1, ServerInstance->Config->Limits.MaxTopic - 1);
|
||||||
showmsg = tag->getBool("showmsg", true);
|
showmsg = tag->getBool("showmsg", true);
|
||||||
|
@ -84,9 +84,9 @@ public:
|
|||||||
{
|
{
|
||||||
introtext = tag->getString("introtext", "Showing " + name);
|
introtext = tag->getString("introtext", "Showing " + name);
|
||||||
endtext = tag->getString("endtext", "End of " + name);
|
endtext = tag->getString("endtext", "End of " + name);
|
||||||
intronumeric = static_cast<unsigned int>(tag->getUInt("intronumeric", RPL_RULESTART, 0, 999));
|
intronumeric = tag->getNum<unsigned int>("intronumeric", RPL_RULESTART, 0, 999);
|
||||||
textnumeric = static_cast<unsigned int>(tag->getUInt("numeric", RPL_RULES, 0, 999));
|
textnumeric = tag->getNum<unsigned int>("numeric", RPL_RULES, 0, 999);
|
||||||
endnumeric = static_cast<unsigned int>(tag->getUInt("endnumeric", RPL_RULESEND, 0, 999));
|
endnumeric = tag->getNum<unsigned int>("endnumeric", RPL_RULESEND, 0, 999);
|
||||||
std::string smethod = tag->getString("method");
|
std::string smethod = tag->getString("method");
|
||||||
|
|
||||||
method = SF_NUMERIC;
|
method = SF_NUMERIC;
|
||||||
|
@ -459,7 +459,7 @@ public:
|
|||||||
{
|
{
|
||||||
const auto& tag = ServerInstance->Config->ConfValue("silence");
|
const auto& tag = ServerInstance->Config->ConfValue("silence");
|
||||||
exemptservice = tag->getBool("exemptservice", tag->getBool("exemptuline", true));
|
exemptservice = tag->getBool("exemptservice", tag->getBool("exemptuline", true));
|
||||||
cmd.ext.maxsilence = tag->getUInt("maxentries", 32, 1);
|
cmd.ext.maxsilence = tag->getNum<unsigned long>("maxentries", 32, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnBuildISupport(ISupport::TokenMap& tokens) override
|
void OnBuildISupport(ISupport::TokenMap& tokens) override
|
||||||
|
@ -262,7 +262,7 @@ void SpanningTreeUtilities::ReadConfiguration()
|
|||||||
if (path.empty())
|
if (path.empty())
|
||||||
{
|
{
|
||||||
L->IPAddr = tag->getString("ipaddr");
|
L->IPAddr = tag->getString("ipaddr");
|
||||||
L->Port = static_cast<in_port_t>(tag->getUInt("port", 0, 0, 65535));
|
L->Port = tag->getNum<in_port_t>("port", 0);
|
||||||
if (tag->getBool("sctp"))
|
if (tag->getBool("sctp"))
|
||||||
{
|
{
|
||||||
#ifdef IPPROTO_SCTP
|
#ifdef IPPROTO_SCTP
|
||||||
|
@ -219,7 +219,7 @@ public:
|
|||||||
void ReadConfig(ConfigStatus& status) override
|
void ReadConfig(ConfigStatus& status) override
|
||||||
{
|
{
|
||||||
const auto& tag = ServerInstance->Config->ConfValue("watch");
|
const auto& tag = ServerInstance->Config->ConfValue("watch");
|
||||||
cmd.maxwatch = tag->getUInt("maxwatch", 30, 1);
|
cmd.maxwatch = tag->getNum<unsigned long>("maxwatch", 30, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnPostConnect(User* user) override
|
void OnPostConnect(User* user) override
|
||||||
|
@ -1091,20 +1091,20 @@ void ConnectClass::Configure(const std::string& classname, const std::shared_ptr
|
|||||||
ports.insert(static_cast<in_port_t>(port));
|
ports.insert(static_cast<in_port_t>(port));
|
||||||
}
|
}
|
||||||
|
|
||||||
commandrate = tag->getUInt("commandrate", commandrate, 1);
|
commandrate = tag->getNum<unsigned long>("commandrate", commandrate, 1);
|
||||||
fakelag = tag->getBool("fakelag", fakelag);
|
fakelag = tag->getBool("fakelag", fakelag);
|
||||||
hardsendqmax = tag->getUInt("hardsendq", hardsendqmax, ServerInstance->Config->Limits.MaxLine);
|
hardsendqmax = tag->getNum<unsigned long>("hardsendq", hardsendqmax, ServerInstance->Config->Limits.MaxLine);
|
||||||
limit = tag->getUInt("limit", limit, 1);
|
limit = tag->getNum<unsigned long>("limit", limit, 1);
|
||||||
maxchans = tag->getUInt("maxchans", maxchans);
|
maxchans = tag->getNum<unsigned long>("maxchans", maxchans);
|
||||||
maxconnwarn = tag->getBool("maxconnwarn", maxconnwarn);
|
maxconnwarn = tag->getBool("maxconnwarn", maxconnwarn);
|
||||||
maxlocal = tag->getUInt("localmax", maxlocal);
|
maxlocal = tag->getNum<unsigned long>("localmax", maxlocal);
|
||||||
maxglobal = tag->getUInt("globalmax", maxglobal, maxlocal);
|
maxglobal = tag->getNum<unsigned long>("globalmax", maxglobal, maxlocal);
|
||||||
penaltythreshold = tag->getUInt("threshold", penaltythreshold, 1);
|
penaltythreshold = tag->getNum<unsigned long>("threshold", penaltythreshold, 1);
|
||||||
pingtime = tag->getDuration("pingfreq", pingtime);
|
pingtime = tag->getDuration("pingfreq", pingtime);
|
||||||
recvqmax = tag->getUInt("recvq", recvqmax, ServerInstance->Config->Limits.MaxLine);
|
recvqmax = tag->getNum<unsigned long>("recvq", recvqmax, ServerInstance->Config->Limits.MaxLine);
|
||||||
connection_timeout = tag->getDuration("timeout", connection_timeout);
|
connection_timeout = tag->getDuration("timeout", connection_timeout);
|
||||||
resolvehostnames = tag->getBool("resolvehostnames", resolvehostnames);
|
resolvehostnames = tag->getBool("resolvehostnames", resolvehostnames);
|
||||||
softsendqmax = tag->getUInt("softsendq", softsendqmax, ServerInstance->Config->Limits.MaxLine);
|
softsendqmax = tag->getNum<unsigned long>("softsendq", softsendqmax, ServerInstance->Config->Limits.MaxLine);
|
||||||
uniqueusername = tag->getBool("uniqueusername", uniqueusername);
|
uniqueusername = tag->getBool("uniqueusername", uniqueusername);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user