* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA.
- * $Id: clients.c,v 1.11 2001/11/22 04:18:25 wcampbel Exp $
+ * $Id: clients.c,v 1.12 2001/12/02 03:27:12 a1kmm Exp $
*/
#include <stdlib.h>
#include <string.h>
if (parc < 2)
return;
if ((usr = find_user(sender)) == NULL)
- return;
+ return;
remove_from_hash(HASH_USER, usr->nick);
strncpy(usr->nick, parv[1], NICKLEN-1)[NICKLEN-1] = 0;
add_to_hash(HASH_USER, usr->nick, usr);
+ add_nickchange(usr->user, usr->host);
}
}
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA.
- * $Id: clones.c,v 1.7 2001/11/11 22:13:52 wcampbel Exp $
+ * $Id: clones.c,v 1.8 2001/12/02 03:27:12 a1kmm Exp $
*/
#include <stdlib.h>
#include <string.h>
struct Host *h;
FORLISTDEL(node,nnode,Hosts,struct Host*,h)
{
- h->last_recalc -= (timenow-h->last_recalc)/10*10;
- h->rate -= (timenow-h->last_recalc)/10;
+ int rtime = h->full ? UHOST_NICKCHANGE_RATE : HOST_NICKCHANGE_RATE;
+ h->rate -= (timenow-h->last_recalc)/rtime;
+ h->last_recalc = timenow - (timenow-h->last_recalc)%rtime;
if (h->rate < 0)
h->rate = 0;
if (h->count == 0 && h->rate == 0)
add_to_hash(HASH_HOST, h2->host, h2);
add_to_list(&Hosts, h2);
}
+ h1->rate -= (timenow-h1->last_recalc)/UHOST_NICKCHANGE_RATE;
+ h1->last_recalc = timenow -
+ (timenow-h1->last_recalc)%UHOST_NICKCHANGE_RATE;
+ if (h1->rate < 0)
+ h1->rate = 0;
+ h2->rate -= (timenow-h2->last_recalc)/HOST_NICKCHANGE_RATE;
+ h2->last_recalc = timenow -
+ (timenow-h2->last_recalc)%HOST_NICKCHANGE_RATE;
+ if (h2->rate < 0)
+ h2->rate = 0;
h1->count++;
h1->rate++;
h2->count++;
report_cloner(h1, "CLONES");
return;
}
- if (h2->rate > MAXCLONES_HOST)
+ if (h2->rate > MAXNICKRATE_HOST)
{
report_cloner(h2, "NICKFLOODER");
return;
}
- if (h1->rate > MAXCLONES_UHOST)
+ if (h1->rate > MAXNICKRATE_UHOST)
+ {
+ report_cloner(h1, "NICKFLOODER");
+ return;
+ }
+}
+
+void
+add_nickchange(char *user, char *host)
+{
+ struct Host *h1, *h2;
+ char uah[HOSTLEN+USERLEN+1];
+
+ strncpy(uah, user, USERLEN-1)
+ [USERLEN-1] = '\0';
+
+ strcat(uah, "@");
+ strncat(uah, host, HOSTLEN-1);
+
+ if ((h1 = find_host(uah)) == NULL)
+ return;
+ if ((h2 = find_host(host)) == NULL)
+ return;
+ h1->rate -= (timenow-h1->last_recalc)/UHOST_NICKCHANGE_RATE;
+ h1->last_recalc = timenow -
+ (timenow-h1->last_recalc)%UHOST_NICKCHANGE_RATE;
+ if (h1->rate < 0)
+ h1->rate = 0;
+ h2->rate -= (timenow-h2->last_recalc)/HOST_NICKCHANGE_RATE;
+ h2->last_recalc = timenow -
+ (timenow-h2->last_recalc)%HOST_NICKCHANGE_RATE;
+ if (h2->rate < 0)
+ h2->rate = 0;
+ h1->rate++;
+ h2->rate++;
+ if (h2->rate > MAXNICKRATE_HOST)
+ {
+ report_cloner(h2, "NICKFLOODER");
+ return;
+ }
+ if (h1->rate > MAXNICKRATE_UHOST)
{
report_cloner(h1, "NICKFLOODER");
return;
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA.
- * $Id: define.h,v 1.7 2001/11/11 22:13:52 wcampbel Exp $
+ * $Id: define.h,v 1.8 2001/12/02 03:27:14 a1kmm Exp $
*/
+/* The maximum number of clients per user@host */
#define MAXCLONES_UHOST 4
+/* The maximum number of clients per host */
#define MAXCLONES_HOST 6
+
+/* The minimum average time(in seconds) between nick introductions
+ * or changes allowed. */
+#define UHOST_NICKCHANGE_RATE 10
+/* The maximum number of nick introductions/changes in excess of
+ * 1 per RATETIME_UHOST allowed. */
+#define MAXNICKRATE_UHOST 3
+
+/* Same but for hosts not user@hosts */
+#define HOST_NICKCHANGE_RATE 10
+#define MAXNICKRATE_HOST 6
+
#define MAX_SJOIN_DELAY 60
#define JUPE_EXPIRE_TIME 45 *60