]> jfr.im git - solanum.git/commitdiff
Pace aways.
authorJilles Tjoelker <redacted>
Sat, 18 Feb 2012 15:32:57 +0000 (16:32 +0100)
committerJilles Tjoelker <redacted>
Sat, 18 Feb 2012 15:32:57 +0000 (16:32 +0100)
This becomes important because of away-notify sending aways to common
channels much like nick changes (which are also paced).

Marking as unaway is not limited (but obviously only does something if the
user was away before). To allow users to fix typos in away messages, two
aways are allowed in sequence if away has not been used recently.

doc/example.conf
doc/reference.conf
include/client.h
include/s_conf.h
modules/m_away.c
modules/m_info.c
src/newconf.c
src/s_conf.c

index b67cb7d9290f651f5dfd8de6405ba6d44b80d17a..190bc4e472829ed0253e026621e136767295f645 100755 (executable)
@@ -515,6 +515,7 @@ general {
        throttle_duration = 60;
        throttle_count = 4;
        max_ratelimit_tokens = 30;
+       away_interval = 30;
 };
 
 modules {
index bce1ea33fc0ff8d2a41cf5604600926c8f09baf4..bf15bcf592e8eff91721aa8637d1efd37614a100 100755 (executable)
@@ -1271,6 +1271,12 @@ general {
         * you're doing.
         */
        max_ratelimit_tokens = 30;
+
+       /* away_interval: the minimum interval between AWAY commands. One
+        * additional AWAY command is allowed, and only marking as away
+        * counts.
+        */
+       away_interval = 30;
 };
 
 modules {
index 62d3fa0fab17feb3594eda606b873dac5bb02b68..12cbb1f7ae4d315637abf9c2d887bb7a003cb4b4 100644 (file)
@@ -237,7 +237,7 @@ struct LocalUser
 
        struct DNSQuery *dnsquery; /* for outgoing server's name lookup */
 
-       time_t last_away;       /* Away since... */
+       time_t next_away;       /* Don't allow next away before... */
        time_t last;
 
        /* clients allowed to talk through +g */
index 8db55f24ac53e73354e74f33e9647edbad8c719f..722e9352ce50c27ec53b97a066f120754c175027 100644 (file)
@@ -225,6 +225,7 @@ struct config_file_entry
        int operspy_dont_care_user_info;
        int use_propagated_bans;
        int max_ratelimit_tokens;
+       int away_interval;
 
        int client_flood_max_lines;
        int client_flood_burst_rate;
index 9a84ba24143717fb28ba72c51cf1d09c50667244..d7ca8fc75f4919e2190c199864a7758ac35a48d0 100644 (file)
@@ -37,7 +37,6 @@
 #include "s_serv.h"
 #include "packet.h"
 
-
 static int m_away(struct Client *, struct Client *, int, const char **);
 
 struct Message away_msgtab = {
@@ -93,6 +92,21 @@ m_away(struct Client *client_p, struct Client *source_p, int parc, const char *p
                return 0;
        }
 
+       /* Rate limit this because it is sent to common channels. */
+       if(!IsOper(source_p) &&
+                       source_p->localClient->next_away > rb_current_time())
+       {
+               sendto_one(source_p, form_str(RPL_LOAD2HI),
+                               me.name, source_p->name, "AWAY");
+               return;
+       }
+       if(source_p->localClient->next_away < rb_current_time() -
+                       ConfigFileEntry.away_interval)
+               source_p->localClient->next_away = rb_current_time();
+       else
+               source_p->localClient->next_away = rb_current_time() +
+                       ConfigFileEntry.away_interval;
+
        if(source_p->user->away == NULL)
                allocate_away(source_p);
        if(strncmp(source_p->user->away, parv[1], AWAYLEN - 1))
index 4facb980dedaa3e953a4c324a7fb6064dd048e70..bd2171afb385598853bf4e900206d8056e55002d 100644 (file)
@@ -524,6 +524,12 @@ static struct InfoStruct info_table[] = {
                &ConfigFileEntry.max_ratelimit_tokens,
                "The maximum number of tokens that can be accumulated for executing rate-limited commands",
        },
+       {
+               "away_interval",
+               OUTPUT_DECIMAL,
+               &ConfigFileEntry.away_interval,
+               "The minimum time between aways",
+       },
        {
                "default_split_server_count",
                OUTPUT_DECIMAL,
index b1cc6a8626743b51e8d0fcb6d488bb7a55846807..ccb1c1510d431a4b4a38ad084eb58bbc166aa1e3 100644 (file)
@@ -2278,6 +2278,7 @@ static struct ConfEntry conf_general_table[] =
        { "client_flood_message_num",   CF_INT,   NULL, 0, &ConfigFileEntry.client_flood_message_num    },
        { "client_flood_message_time",  CF_INT,   NULL, 0, &ConfigFileEntry.client_flood_message_time   },
        { "max_ratelimit_tokens",       CF_INT,   NULL, 0, &ConfigFileEntry.max_ratelimit_tokens        },
+       { "away_interval",              CF_INT,   NULL, 0, &ConfigFileEntry.away_interval               },
        { "\0",                 0,        NULL, 0, NULL }
 };
 
index 399351a4c883f65bd1bb1652b4095bb94d9a3786..93849e028e7536dce8fa971c9189b7f010689419 100644 (file)
@@ -746,6 +746,7 @@ set_default_conf(void)
        ConfigFileEntry.operspy_dont_care_user_info = NO;
        ConfigFileEntry.use_propagated_bans = YES;
        ConfigFileEntry.max_ratelimit_tokens = 30;
+       ConfigFileEntry.away_interval = 30;
 
 #ifdef HAVE_LIBZ
        ConfigFileEntry.compression_level = 4;