]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Convert ConfigTag::getDuration to return an unsigned long.
authorPeter Powell <petpow@saberuk.com>
Sat, 14 Apr 2018 13:59:35 +0000 (14:59 +0100)
committerPeter Powell <petpow@saberuk.com>
Mon, 16 Apr 2018 14:24:49 +0000 (15:24 +0100)
include/configreader.h
src/configparser.cpp
src/modules/m_blockamsg.cpp
src/modules/m_connflood.cpp
src/modules/m_dnsbl.cpp
src/modules/m_ircv3_sts.cpp
src/modules/m_repeat.cpp
src/modules/m_securelist.cpp

index d55c1830ff8e2ebccb6ffa2900fc4fdf4adffb0f..85ce21f141a748f8be965765d0fa0e5bd1933704 100644 (file)
@@ -59,7 +59,7 @@ class CoreExport ConfigTag : public refcountbase
         * @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
index 5feff013f44ee217a896a3f01ca377b966949315..624f3aea64689cf14c9f4529ec85925bf2b64132 100644 (file)
@@ -496,13 +496,13 @@ long ConfigTag::getInt(const std::string &key, long def, long min, long max)
        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;
 }
index 7d97069f540f9ad2b07d7980a97fa3158c492d03..ed0e486e95d616dc306cbaeb0c78be6cb9018627 100644 (file)
@@ -48,7 +48,7 @@ class BlockedMessage
 
 class ModuleBlockAmsg : public Module
 {
-       int ForgetDelay;
+       unsigned int ForgetDelay;
        BlockAction action;
        SimpleExtItem<BlockedMessage> blockamsg;
 
@@ -66,7 +66,7 @@ class ModuleBlockAmsg : public Module
        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")
@@ -116,7 +116,7 @@ class ModuleBlockAmsg : public Module
                        // 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)
index 29d4d9d3ad6c8a195171a3bd15ff3e2cc32e99e9..32d36188b3ec26abe63f85c949288812d83301f4 100644 (file)
@@ -23,7 +23,9 @@
 
 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;
@@ -46,13 +48,13 @@ public:
                /* 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();
        }
index ed31cc54a6e61e13ecf294fd2406a696b3bce684..377cad9ddb01e4fc30ba6e986b0437e791e42bbd 100644 (file)
@@ -35,7 +35,7 @@ class DNSBLConfEntry : public refcountbase
                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;
index f3b936b4189e43e29cfca5de19ed39c2449d0981..9dc36df606cdda65228bd64fffb3124a9179b94e 100644 (file)
@@ -167,7 +167,7 @@ class ModuleIRCv3STS : public Module
                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);
        }
index 7ecdf21dc5dbb4b2f8c1ec7ab1bbd3e32b5f94b1..18732d705de52952fe1d0021928a3c149f31a07b 100644 (file)
@@ -235,7 +235,7 @@ class RepeatMode : public ParamMode<RepeatMode, SimpleExtItem<ChannelSettings> >
                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)
index e36b9e403b8f487f47ebac69aff60a0cd901b027..71788a835c2bbb9f1f6b3c4eac555aba046ab75b 100644 (file)
@@ -24,7 +24,7 @@
 class ModuleSecureList : public Module
 {
        std::vector<std::string> allowlist;
-       time_t WaitTime;
+       unsigned int WaitTime;
 
  public:
        Version GetVersion() CXX11_OVERRIDE
@@ -40,7 +40,7 @@ class ModuleSecureList : public Module
                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);
        }