about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2013-07-30 22:05:00 +0200
committerAlexander Barton <alex@barton.de>2013-07-30 22:05:00 +0200
commit3bd973037a1664387161a465f801b78ff0180fa1 (patch)
tree1e250ca02ae634ed50277391e985a4e7e2dcdf6f /src
parentf494023b0d99be0e4b07701b983b71ecf4920465 (diff)
downloadngircd-3bd973037a1664387161a465f801b78ff0180fa1.tar.gz
ngircd-3bd973037a1664387161a465f801b78ff0180fa1.zip
Add more penalty times in error paths
This patch changes the handlers of the "PASS", "NICK", "USER",
and "SERVICE" commands to enforce a 2 second penalty when an error
like "need more/other parameters" occurs.

More functions should follow, I think ...
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/irc-login.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c
index 27e11c40..cfb94f60 100644
--- a/src/ngircd/irc-login.c
+++ b/src/ngircd/irc-login.c
@@ -81,10 +81,12 @@ IRC_PASS( CLIENT *Client, REQUEST *Req )
 	} else if (Client_Type(Client) == CLIENT_UNKNOWN ||
 		   Client_Type(Client) == CLIENT_UNKNOWNSERVER) {
 		/* Unregistered connection, but wrong number of arguments: */
+		IRC_SetPenalty(Client, 2);
 		return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
 					  Client_ID(Client), Req->command);
 	} else {
 		/* Registered connection, PASS command is not allowed! */
+		IRC_SetPenalty(Client, 2);
 		return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG,
 					  Client_ID(Client));
 	}
@@ -207,11 +209,12 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
 							   Req->argv[0] );
 		} else {
 			/* Is this a restricted client? */
-			if( Client_HasMode( Client, 'r' ))
+			if (Client_HasMode(Client, 'r')) {
+				IRC_SetPenalty(Client, 2);
 				return IRC_WriteStrClient( Client,
 							   ERR_RESTRICTED_MSG,
 							   Client_ID( Client ));
-
+			}
 			target = Client;
 		}
 
@@ -487,10 +490,12 @@ IRC_USER(CLIENT * Client, REQUEST * Req)
 		return CONNECTED;
 	} else if (Client_Type(Client) == CLIENT_USER) {
 		/* Already registered connection */
+		IRC_SetPenalty(Client, 2);
 		return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG,
 					  Client_ID(Client));
 	} else {
 		/* Unexpected/invalid connection state? */
+		IRC_SetPenalty(Client, 2);
 		return IRC_WriteStrClient(Client, ERR_NOTREGISTERED_MSG,
 					  Client_ID(Client));
 	}
@@ -518,9 +523,11 @@ IRC_SERVICE(CLIENT *Client, REQUEST *Req)
 	assert(Req != NULL);
 
 	if (Client_Type(Client) != CLIENT_GOTPASS &&
-	    Client_Type(Client) != CLIENT_SERVER)
+	    Client_Type(Client) != CLIENT_SERVER) {
+		IRC_SetPenalty(Client, 2);
 		return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG,
 					  Client_ID(Client));
+	}
 
 	_IRC_ARGC_EQ_OR_RETURN_(Client, Req, 6)