* @param max Maximum acceptable value (optional)
* @return The duration in seconds
*/
- long getDuration(const std::string& key, long def, long min = LONG_MIN, long max = LONG_MAX);
+ unsigned long getDuration(const std::string& key, unsigned long def, unsigned long min = 0, unsigned long max = ULONG_MAX);
/** Get the value of an option
* @param key The option to get
return res;
}
-long ConfigTag::getDuration(const std::string& key, long def, long min, long max)
+unsigned long ConfigTag::getDuration(const std::string& key, unsigned long def, unsigned long min, unsigned long max)
{
std::string duration;
if (!readString(key, duration))
return def;
- long ret = InspIRCd::Duration(duration);
+ unsigned long ret = InspIRCd::Duration(duration);
CheckRange(tag, key, ret, def, min, max);
return ret;
}
class ModuleBlockAmsg : public Module
{
- int ForgetDelay;
+ unsigned int ForgetDelay;
BlockAction action;
SimpleExtItem<BlockedMessage> blockamsg;
void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
{
ConfigTag* tag = ServerInstance->Config->ConfValue("blockamsg");
- ForgetDelay = tag->getDuration("delay", -1);
+ ForgetDelay = tag->getDuration("delay", 3);
std::string act = tag->getString("action");
if (act == "notice")
// OR
// The number of target channels is equal to the number of channels the sender is on..a little suspicious.
// Check it's more than 1 too, or else users on one channel would have fun.
- if ((m && (m->message == parameters[1]) && (!irc::equals(m->target, parameters[0])) && (ForgetDelay != -1) && (m->sent >= ServerInstance->Time()-ForgetDelay)) || ((targets > 1) && (targets == user->chans.size())))
+ if ((m && (m->message == parameters[1]) && (!irc::equals(m->target, parameters[0])) && ForgetDelay && (m->sent >= ServerInstance->Time()-ForgetDelay)) || ((targets > 1) && (targets == user->chans.size())))
{
// Block it...
if (action == IBLOCK_KILLOPERS || action == IBLOCK_NOTICEOPERS)
class ModuleConnFlood : public Module
{
- int seconds, timeout, boot_wait;
+ unsigned int seconds;
+ unsigned int timeout;
+ unsigned int boot_wait;
unsigned int conns;
unsigned int maxconns;
bool throttled;
/* read configuration variables */
ConfigTag* tag = ServerInstance->Config->ConfValue("connflood");
/* throttle configuration */
- seconds = tag->getDuration("period", tag->getInt("seconds", 30));
+ seconds = tag->getDuration("period", tag->getDuration("seconds", 30));
maxconns = tag->getInt("maxconns", 3);
timeout = tag->getDuration("timeout", 30);
quitmsg = tag->getString("quitmsg");
/* seconds to wait when the server just booted */
- boot_wait = tag->getInt("bootwait", 10);
+ boot_wait = tag->getDuration("bootwait", 10);
first = ServerInstance->Time();
}
std::string name, ident, host, domain, reason;
EnumBanaction banaction;
EnumType type;
- long duration;
+ unsigned long duration;
unsigned int bitmask;
unsigned char records[256];
unsigned long stats_hits, stats_misses;
if (!HasValidSSLPort(port))
throw ModuleException("<sts:port> must be a TLS port, at " + tag->getTagLocation());
- unsigned long duration = tag->getDuration("duration", 60*60*24*30*2, 0, LONG_MAX);
+ unsigned long duration = tag->getDuration("duration", 60*60*24*30*2);
bool preload = tag->getBool("preload");
cap.SetPolicy(host, duration, port, preload);
}
ConfigTag* conf = ServerInstance->Config->ConfValue("repeat");
ms.MaxLines = conf->getInt("maxlines", 20);
ms.MaxBacklog = conf->getInt("maxbacklog", 20);
- ms.MaxSecs = conf->getDuration("maxtime", conf->getInt("maxsecs", 0));
+ ms.MaxSecs = conf->getDuration("maxtime", conf->getDuration("maxsecs", 0));
ms.MaxDiff = conf->getInt("maxdistance", 50);
if (ms.MaxDiff > 100)
class ModuleSecureList : public Module
{
std::vector<std::string> allowlist;
- time_t WaitTime;
+ unsigned int WaitTime;
public:
Version GetVersion() CXX11_OVERRIDE
for (ConfigIter i = tags.first; i != tags.second; ++i)
allowlist.push_back(i->second->getString("exception"));
- WaitTime = ServerInstance->Config->ConfValue("securelist")->getDuration("waittime", 60);
+ WaitTime = ServerInstance->Config->ConfValue("securelist")->getDuration("waittime", 60, 1);
}