away-notify and away rate limiting added

Referenced:

atheme/charybdis@c5bbc60375 : Add
away-notify client capability.
atheme/charybdis@d42e6915cf : Pace aways.
atheme/charybdis@725403fd7f : Don't end
the flood grace period with the first AWAY.
atheme/charybdis@dc0fd46236 : Ensure AWAY
pacing only affects local clients.
This commit is contained in:
Sam Dodrill 2013-10-04 21:32:00 -07:00
parent ef6e8564e0
commit 0814442111
10 changed files with 55 additions and 4 deletions

View File

@ -608,6 +608,7 @@ general {
throttle_duration = 60;
throttle_count = 4;
expire_override_time = 5 minutes;
away_interval = 30;
};
modules {

View File

@ -1479,6 +1479,12 @@ general {
* this long after it is set. 0 disables this. Default is 5 minutes.
*/
expire_override_time = 5 minutes;
/* away_interval: the minimum interval between AWAY commands. One
* additional AWAY command is allowed, and only marking as away
* counts.
*/
away_interval = 30;
};
modules {

View File

@ -238,7 +238,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 */
@ -453,6 +453,7 @@ struct ListClient
#define CLICAP_SASL 0x0002
#define CLICAP_ACCOUNT_NOTIFY 0x0004
#define CLICAP_EXTENDED_JOIN 0x0008
#define CLICAP_AWAY_NOTIFY 0x0010
/*
* flags macros.

View File

@ -233,6 +233,7 @@ struct config_file_entry
int use_propagated_bans;
int secret_channels_in_whois;
int expire_override_time;
int away_interval;
};
struct config_channel_entry

View File

@ -68,7 +68,8 @@ DECLARE_MODULE_AV1(away, NULL, NULL, away_clist, NULL, NULL, "$Revision: 3370 $"
static int
m_away(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
if(MyClient(source_p) && !IsFloodDone(source_p))
if(MyClient(source_p) && source_p->localClient->next_away &&
!IsFloodDone(source_p))
flood_endgrace(source_p);
if(!IsClient(source_p))
@ -83,12 +84,34 @@ m_away(struct Client *client_p, struct Client *source_p, int parc, const char *p
sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
":%s AWAY", use_id(source_p));
free_away(source_p);
sendto_common_channels_local_butone(source_p, CLICAP_AWAY_NOTIFY, ":%s!%s@%s AWAY",
source_p->name, source_p->username, source_p->host);
}
if(MyConnect(source_p))
sendto_one_numeric(source_p, RPL_UNAWAY, form_str(RPL_UNAWAY));
return 0;
}
/* Rate limit this because it is sent to common channels. */
if (MyClient(source_p))
{
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))
@ -97,9 +120,13 @@ m_away(struct Client *client_p, struct Client *source_p, int parc, const char *p
sendto_server(client_p, NULL, CAP_TS6, NOCAPS,
":%s AWAY :%s", use_id(source_p), source_p->user->away);
}
if(MyConnect(source_p))
sendto_one_numeric(source_p, RPL_NOWAWAY, form_str(RPL_NOWAWAY));
sendto_common_channels_local_butone(source_p, CLICAP_AWAY_NOTIFY, ":%s!%s@%s AWAY :%s",
source_p->name, source_p->username, source_p->host,
source_p->user->away);
return 0;
}

View File

@ -70,7 +70,8 @@ static struct clicap
_CLICAP("multi-prefix", CLICAP_MULTI_PREFIX, 0, 0),
_CLICAP("sasl", CLICAP_SASL, 0, 0),
_CLICAP("account-notify", CLICAP_ACCOUNT_NOTIFY, 0, 0),
_CLICAP("extended-join", CLICAP_EXTENDED_JOIN, 0, 0)
_CLICAP("extended-join", CLICAP_EXTENDED_JOIN, 0, 0),
_CLICAP("away-notify", CLICAP_AWAY_NOTIFY, 0, 0),
};
#define CLICAP_LIST_LEN (sizeof(clicap_list) / sizeof(struct clicap))

View File

@ -547,6 +547,12 @@ static struct InfoStruct info_table[] = {
&ConfigFileEntry.use_propagated_bans,
"KLINE sets fully propagated bans"
},
{
"away_interval",
OUTPUT_DECIMAL,
&ConfigFileEntry.away_interval,
"The minimum time between aways",
},
{
"default_split_server_count",
OUTPUT_DECIMAL,

View File

@ -2008,6 +2008,12 @@ void user_join(struct Client * client_p, struct Client * source_p, const char *
EmptyString(source_p->user->suser) ? "*" : source_p->user->suser,
source_p->tsinfo, source_p->info);
/* Send away message to away-notify enabled clients. */
if (client_p->user->away)
sendto_channel_local_with_capability_butone(client_p, ALL_MEMBERS, CLICAP_AWAY_NOTIFY, NOCAPS, chptr,
":%s!%s@%s AWAY :%s", client_p->name, client_p->username,
client_p->host, client_p->user->away);
/* its a new channel, set +nt and burst. */
if(flags & CHFL_CHANOP)
{

View File

@ -2282,6 +2282,7 @@ static struct ConfEntry conf_general_table[] =
{ "warn_no_nline", CF_YESNO, NULL, 0, &ConfigFileEntry.warn_no_nline },
{ "use_propagated_bans",CF_YESNO, NULL, 0, &ConfigFileEntry.use_propagated_bans },
{ "expire_override_time", CF_TIME, NULL, 0, &ConfigFileEntry.expire_override_time},
{ "away_interval", CF_INT, NULL, 0, &ConfigFileEntry.away_interval },
{ "\0", 0, NULL, 0, NULL }
};

View File

@ -755,6 +755,7 @@ set_default_conf(void)
ConfigFileEntry.operspy_dont_care_user_info = NO;
ConfigFileEntry.use_propagated_bans = YES;
ConfigFileEntry.secret_channels_in_whois = NO;
ConfigFileEntry.away_interval = 30;
#ifdef HAVE_LIBZ
ConfigFileEntry.compression_level = 4;