mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-10 17:23:13 +02:00
Code cleanup: move flood control to generic system
This commit is contained in:
+6
-14
@@ -89,21 +89,13 @@ CMD_FUNC(cmd_away)
|
||||
if (MyUser(client) && match_spamfilter(client, new_reason, SPAMF_AWAY, "AWAY", NULL, 0, NULL))
|
||||
return;
|
||||
|
||||
/* Check set::anti-flood::away-flood */
|
||||
if (MyUser(client) && AWAY_PERIOD && !ValidatePermissionsForPath("immune:away-flood",client,NULL,NULL,NULL))
|
||||
/* Check away-flood */
|
||||
if (MyUser(client) &&
|
||||
!ValidatePermissionsForPath("immune:away-flood",client,NULL,NULL,NULL) &&
|
||||
flood_limit_exceeded(client, FLD_AWAY))
|
||||
{
|
||||
if ((client->user->flood.away_t + AWAY_PERIOD) <= timeofday)
|
||||
{
|
||||
client->user->flood.away_c = 0;
|
||||
client->user->flood.away_t = timeofday;
|
||||
}
|
||||
if (client->user->flood.away_c <= AWAY_COUNT)
|
||||
client->user->flood.away_c++;
|
||||
if (client->user->flood.away_c > AWAY_COUNT)
|
||||
{
|
||||
sendnumeric(client, ERR_TOOMANYAWAY);
|
||||
return;
|
||||
}
|
||||
sendnumeric(client, ERR_TOOMANYAWAY);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Obey set::away-length */
|
||||
|
||||
+5
-14
@@ -166,25 +166,16 @@ CMD_FUNC(cmd_invite)
|
||||
return;
|
||||
}
|
||||
|
||||
if (MyConnect(client))
|
||||
if (MyUser(client))
|
||||
{
|
||||
if (target_limit_exceeded(client, target, target->name))
|
||||
return;
|
||||
|
||||
if (!ValidatePermissionsForPath("immune:invite-flood",client,NULL,NULL,NULL))
|
||||
if (!ValidatePermissionsForPath("immune:invite-flood",client,NULL,NULL,NULL) &&
|
||||
flood_limit_exceeded(client, FLD_INVITE))
|
||||
{
|
||||
if ((client->user->flood.invite_t + INVITE_PERIOD) <= timeofday)
|
||||
{
|
||||
client->user->flood.invite_c = 0;
|
||||
client->user->flood.invite_t = timeofday;
|
||||
}
|
||||
if (client->user->flood.invite_c <= INVITE_COUNT)
|
||||
client->user->flood.invite_c++;
|
||||
if (client->user->flood.invite_c > INVITE_COUNT)
|
||||
{
|
||||
sendnumeric(client, RPL_TRYAGAIN, "INVITE");
|
||||
return;
|
||||
}
|
||||
sendnumeric(client, RPL_TRYAGAIN, "INVITE");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!override)
|
||||
|
||||
+5
-14
@@ -132,21 +132,12 @@ CMD_FUNC(cmd_knock)
|
||||
if (i == HOOK_DENY)
|
||||
return;
|
||||
|
||||
if (MyUser(client) && !ValidatePermissionsForPath("immune:knock-flood",client,NULL,NULL,NULL))
|
||||
if (MyUser(client) &&
|
||||
!ValidatePermissionsForPath("immune:knock-flood",client,NULL,NULL,NULL) &&
|
||||
flood_limit_exceeded(client, FLD_KNOCK))
|
||||
{
|
||||
if ((client->user->flood.knock_t + KNOCK_PERIOD) <= timeofday)
|
||||
{
|
||||
client->user->flood.knock_c = 0;
|
||||
client->user->flood.knock_t = timeofday;
|
||||
}
|
||||
if (client->user->flood.knock_c <= KNOCK_COUNT)
|
||||
client->user->flood.knock_c++;
|
||||
if (client->user->flood.knock_c > KNOCK_COUNT)
|
||||
{
|
||||
sendnumeric(client, ERR_CANNOTKNOCK, parv[1],
|
||||
"You are KNOCK flooding");
|
||||
return;
|
||||
}
|
||||
sendnumeric(client, ERR_CANNOTKNOCK, parv[1], "You are KNOCK flooding");
|
||||
return;
|
||||
}
|
||||
|
||||
new_message(&me, NULL, &mtags);
|
||||
|
||||
+10
-20
@@ -274,19 +274,6 @@ CMD_FUNC(cmd_nick_local)
|
||||
return;
|
||||
}
|
||||
|
||||
/* set::anti-flood::nick-flood */
|
||||
if (client->user && !ValidatePermissionsForPath("immune:nick-flood",client,NULL,NULL,NULL))
|
||||
{
|
||||
if ((client->user->flood.nick_c >= NICK_COUNT) &&
|
||||
(TStime() - client->user->flood.nick_t < NICK_PERIOD))
|
||||
{
|
||||
/* Throttle... */
|
||||
sendnumeric(client, ERR_NCHANGETOOFAST, nick,
|
||||
(int)(NICK_PERIOD - (TStime() - client->user->flood.nick_t)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for collisions / in use */
|
||||
if (!strcasecmp("ircd", nick) || !strcasecmp("irc", nick))
|
||||
{
|
||||
@@ -321,6 +308,16 @@ CMD_FUNC(cmd_nick_local)
|
||||
/* fallthrough for ircops that have sufficient privileges */
|
||||
}
|
||||
|
||||
/* set::anti-flood::nick-flood */
|
||||
if (client->user &&
|
||||
!ValidatePermissionsForPath("immune:nick-flood",client,NULL,NULL,NULL) &&
|
||||
flood_limit_exceeded(client, FLD_NICK))
|
||||
{
|
||||
/* Throttle... */
|
||||
sendnumeric(client, ERR_NCHANGETOOFAST, nick);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ValidatePermissionsForPath("immune:nick-flood",client,NULL,NULL,NULL))
|
||||
cptr->local->since += 3; /* Nick-flood prot. -Donwulff */
|
||||
|
||||
@@ -439,13 +436,6 @@ CMD_FUNC(cmd_nick_local)
|
||||
}
|
||||
}
|
||||
|
||||
if (TStime() - client->user->flood.nick_t >= NICK_PERIOD)
|
||||
{
|
||||
client->user->flood.nick_t = TStime();
|
||||
client->user->flood.nick_c = 1;
|
||||
} else
|
||||
client->user->flood.nick_c++;
|
||||
|
||||
sendto_snomask(SNO_NICKCHANGE, "*** %s (%s@%s) has changed their nickname to %s",
|
||||
client->name, client->user->username, client->user->realhost, nick);
|
||||
|
||||
|
||||
+3
-3
@@ -875,9 +875,9 @@ int stats_set(Client *client, char *para)
|
||||
sendtxtnumeric(client, "anti-flood::handshake-data-flood::amount: %ld bytes", iConf.handshake_data_flood_amount);
|
||||
sendtxtnumeric(client, "anti-flood::handshake-data-flood::ban-action: %s", banact_valtostring(iConf.handshake_data_flood_ban_action));
|
||||
sendtxtnumeric(client, "anti-flood::handshake-data-flood::ban-time: %s", pretty_time_val(iConf.handshake_data_flood_ban_time));
|
||||
if (AWAY_PERIOD)
|
||||
sendtxtnumeric(client, "anti-flood::away-flood: %d per %s", AWAY_COUNT, pretty_time_val(AWAY_PERIOD));
|
||||
sendtxtnumeric(client, "anti-flood::nick-flood: %d per %s", NICK_COUNT, pretty_time_val(NICK_PERIOD));
|
||||
//if (AWAY_PERIOD)
|
||||
// sendtxtnumeric(client, "anti-flood::away-flood: %d per %s", AWAY_COUNT, pretty_time_val(AWAY_PERIOD));
|
||||
//sendtxtnumeric(client, "anti-flood::nick-flood: %d per %s", NICK_COUNT, pretty_time_val(NICK_PERIOD));
|
||||
sendtxtnumeric(client, "handshake-timeout: %s", pretty_time_val(iConf.handshake_timeout));
|
||||
sendtxtnumeric(client, "sasl-timeout: %s", pretty_time_val(iConf.sasl_timeout));
|
||||
sendtxtnumeric(client, "ident::connect-timeout: %s", pretty_time_val(IDENT_CONNECT_TIMEOUT));
|
||||
|
||||
Reference in New Issue
Block a user