diff --git a/doc/example.conf b/doc/example.conf index b67cb7d9..190bc4e4 100755 --- a/doc/example.conf +++ b/doc/example.conf @@ -515,6 +515,7 @@ general { throttle_duration = 60; throttle_count = 4; max_ratelimit_tokens = 30; + away_interval = 30; }; modules { diff --git a/doc/reference.conf b/doc/reference.conf index bce1ea33..bf15bcf5 100755 --- a/doc/reference.conf +++ b/doc/reference.conf @@ -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 { diff --git a/include/client.h b/include/client.h index 62d3fa0f..12cbb1f7 100644 --- a/include/client.h +++ b/include/client.h @@ -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 */ diff --git a/include/s_conf.h b/include/s_conf.h index 8db55f24..722e9352 100644 --- a/include/s_conf.h +++ b/include/s_conf.h @@ -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; diff --git a/modules/m_away.c b/modules/m_away.c index 9a84ba24..d7ca8fc7 100644 --- a/modules/m_away.c +++ b/modules/m_away.c @@ -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)) diff --git a/modules/m_info.c b/modules/m_info.c index 4facb980..bd2171af 100644 --- a/modules/m_info.c +++ b/modules/m_info.c @@ -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, diff --git a/src/newconf.c b/src/newconf.c index b1cc6a86..ccb1c151 100644 --- a/src/newconf.c +++ b/src/newconf.c @@ -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 } }; diff --git a/src/s_conf.c b/src/s_conf.c index 399351a4..93849e02 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -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;