Module: ngircd.git Branch: master Commit: 344185b1bd6254ac4a198b3caeaf08db285016c8 URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=34418...
Author: Federico G. Schwindt fgsch@lodoss.net Date: Thu Nov 7 16:53:29 2013 +0000
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().
---
src/ngircd/irc-info.c | 5 ----- src/ngircd/irc-mode.c | 2 -- src/ngircd/parse.c | 10 +++++----- 3 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c index 202f427..f1d0271 100644 --- a/src/ngircd/irc-info.c +++ b/src/ngircd/irc-info.c @@ -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, diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c index 8e76db1..a29ed23 100644 --- a/src/ngircd/irc-mode.c +++ b/src/ngircd/irc-mode.c @@ -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 */
diff --git a/src/ngircd/parse.c b/src/ngircd/parse.c index 4235497..fdb957c 100644 --- a/src/ngircd/parse.c +++ b/src/ngircd/parse.c @@ -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();