]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Add a cap on the limit of hellos per session.
authorChris Porter <redacted>
Sun, 9 Mar 2008 01:45:56 +0000 (01:45 +0000)
committerChris Porter <redacted>
Sun, 9 Mar 2008 01:45:56 +0000 (01:45 +0000)
chanserv/authcmds/hello.c
chanserv/chanserv.h
chanserv/database/chanservdb_alloc.c
chanserv/database/chanservdb_messages.c

index 2d3bf8b46034f5600dce6584b3a8805b007f7e9d..1a2f26a35b1bd87677ac97da0685295663141aa6 100644 (file)
@@ -24,6 +24,7 @@ int csa_dohello(void *source, int cargc, char **cargv) {
   reguser *ruh;
   int found=0;
   char *dupemail;
+  activeuser *aup;
 
   if (getreguserfromnick(sender))
     return CMD_ERROR;
@@ -38,6 +39,14 @@ int csa_dohello(void *source, int cargc, char **cargv) {
     return CMD_ERROR;
   }
 
+  if (!(aup = getactiveuserfromnick(sender)))
+    return CMD_ERROR;
+
+  if (aup->helloattempts > MAXHELLOS) {
+    chanservstdmessage(sender, QM_MAXHELLOLIMIT);
+    return CMD_ERROR;
+  }
+
   if (strcmp(cargv[0],cargv[1])) {
     chanservstdmessage(sender, QM_EMAILDONTMATCH);
     cs_log(sender,"HELLO FAIL username %s email don't match (%s vs %s)",sender->nick,cargv[0],cargv[1]);
@@ -58,6 +67,8 @@ int csa_dohello(void *source, int cargc, char **cargv) {
     }
   }
 
+  aup->helloattempts++;
+  
   dupemail = strdup(cargv[0]);
   local=strchr(dupemail, '@');
   *(local++)='\0';
index 94325c5b60d947827f1c5a3c22002a2f53e895ef..f16031a7bb615786593a267b599e55e26c41012f 100644 (file)
@@ -47,6 +47,9 @@
 /* Maximum number of times a user may attempt to auth */
 #define   MAXAUTHATTEMPT      3
 
+/* Maximum number of hellos in a session */
+#define   MAXHELLOS           3
+
 /* Maximum number of times a user may actually be authed */
 #define   MAXAUTHCOUNT        2
 
 #define QM_TOOMANYCHANLEVS         154
 #define QM_TOOMANYBANS             155
 #define QM_WARNNOTREMOVEDPERMBAN   156
+#define QM_MAXHELLOLIMIT           157
 
 /* List of privileged operations */
 
@@ -693,8 +697,8 @@ typedef struct activeuser {
 #ifdef CS_PARANOID
   unsigned int       activeuser_magic;
 #endif
-  int                authattempts; /* number of times user has attempted to auth */
-
+  unsigned short                authattempts; /* number of times user has attempted to auth */
+  unsigned short                helloattempts; /* number of times user has attempted to hello... */
   unsigned char      entropy[ENTROPYLEN]; /* entropy used for challengeauth */
   time_t             entropyttl;
   struct activeuser *next;         /* purely for keeping track of free, but not free'd structures */
index db02fcf85720a8e978bb6ddbb498d2a6f99dff86..bb6522029a0d9dddc50d21a26fa5dcd5686bdc02 100644 (file)
@@ -149,6 +149,7 @@ activeuser *getactiveuser() {
   tagactiveuser(aup);
   
   aup->authattempts=0;
+  aup->helloattempts=0;
   aup->entropyttl=0;
   
   return aup;
index 9af15f2eb80e7e4a0212bff664302b1c6b8a9979..7e37b8fd2d57e144c33acaba6eb1267de36e13d0 100644 (file)
@@ -165,6 +165,7 @@ char *defaultmessages[MAXMESSAGES] = {
   /* 154*/ "Channel has too many user entries, aborting.",
   /* 155*/ "Channel has too many bans set, aborting.",
   /* 156*/ "Warning: not removing registered ban %s from %s.",
+  /* 157*/ "Sorry, the registration service is unavailable to you at this time. Please try again later.", /* a deliberately vague message */
 };
 
 void initmessages() {