Rework the penalty handling slightly

Increase the penalty for a command before checking its arguments.  This
makes the handling more consistent and allow us to move more penalties to
Handle_Request().
This commit is contained in:
Federico G. Schwindt 2013-11-07 16:53:29 +00:00
parent fcf61e9e02
commit 344185b1bd
3 changed files with 5 additions and 12 deletions

View File

@ -152,8 +152,6 @@ IRC_WHO_Channel(CLIENT *Client, CHANNEL *Chan, bool OnlyOps)
assert( Client != NULL );
assert( Chan != NULL );
IRC_SetPenalty(Client, 1);
is_member = Channel_IsMemberOf(Chan, Client);
/* Secret channel? */
@ -1152,7 +1150,6 @@ IRC_WHO(CLIENT *Client, REQUEST *Req)
}
/* No channel or (valid) mask given */
IRC_SetPenalty(Client, 2);
return IRC_WHO_Mask(Client, NULL, only_ops);
} /* IRC_WHO */
@ -1175,8 +1172,6 @@ IRC_WHOIS( CLIENT *Client, REQUEST *Req )
assert( Client != NULL );
assert( Req != NULL );
IRC_SetPenalty(Client, 1);
/* Wrong number of parameters? */
if (Req->argc < 1)
return IRC_WriteErrClient(Client, ERR_NONICKNAMEGIVEN_MSG,

View File

@ -357,7 +357,6 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
Client_Modes(Target));
}
IRC_SetPenalty(Client, 1);
return ok;
} /* Client_Mode */
@ -918,7 +917,6 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
}
}
IRC_SetPenalty(Client, 1);
return connected;
} /* Channel_Mode */

View File

@ -86,7 +86,7 @@ static COMMAND My_Commands[] =
_CMD("LIST", IRC_LIST, CLIENT_USER|CLIENT_SERVER, 0, 2, 2),
_CMD("LUSERS", IRC_LUSERS, CLIENT_USER|CLIENT_SERVER, 0, 2, 1),
_CMD("METADATA", IRC_METADATA, CLIENT_SERVER, 3, 3, 0),
_CMD("MODE", IRC_MODE, CLIENT_USER|CLIENT_SERVER, 1, -1, 0),
_CMD("MODE", IRC_MODE, CLIENT_USER|CLIENT_SERVER, 1, -1, 1),
_CMD("MOTD", IRC_MOTD, CLIENT_USER|CLIENT_SERVER, 0, 1, 3),
_CMD("NAMES", IRC_NAMES, CLIENT_USER|CLIENT_SERVER, 0, 2, 1),
_CMD("NICK", IRC_NICK, CLIENT_ANY, 0, -1, 0),
@ -119,7 +119,7 @@ static COMMAND My_Commands[] =
_CMD("WALLOPS", IRC_WALLOPS, CLIENT_USER|CLIENT_SERVER, 1, 1, 0),
_CMD("WEBIRC", IRC_WEBIRC, CLIENT_UNKNOWN, 4, 4, 0),
_CMD("WHO", IRC_WHO, CLIENT_USER, 0, 2, 1),
_CMD("WHOIS", IRC_WHOIS, CLIENT_USER|CLIENT_SERVER, 0, -1, 0),
_CMD("WHOIS", IRC_WHOIS, CLIENT_USER|CLIENT_SERVER, 0, -1, 1),
_CMD("WHOWAS", IRC_WHOWAS, CLIENT_USER|CLIENT_SERVER, 0, -1, 0),
#ifdef IRCPLUS
@ -533,14 +533,14 @@ Handle_Request( CONN_ID Idx, REQUEST *Req )
Client_ID(client));
}
if (cmd->penalty)
IRC_SetPenalty(client, cmd->penalty);
if (Req->argc < cmd->min_argc ||
(cmd->max_argc != -1 && Req->argc > cmd->max_argc))
return IRC_WriteErrClient(client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(client), Req->command);
if (cmd->penalty)
IRC_SetPenalty(client, cmd->penalty);
/* Command is allowed for this client: call it and count
* generated bytes in output */
Conn_ResetWCounter();