]> jfr.im git - irc/quakenet/newserv.git/blobdiff - regexgline/regexgline.c
CHANSERV: better batcher error handling for expired accounts/accounts with no email.
[irc/quakenet/newserv.git] / regexgline / regexgline.c
index 1274f4ca285fd08c3623233c3279f3d2ba57cc4f..565e33eb11e460fac6b157b2489a471e9efd9cc0 100644 (file)
@@ -15,6 +15,7 @@
 #include "../core/hooks.h"
 #include "../server/server.h"
 #include "../lib/strlfunc.h"
+#include "../glines/glines.h"
 #include <stdint.h>
 
 #define INSTANT_IDENT_GLINE  1
@@ -76,7 +77,6 @@ static const char *classes[] = { "drone", "proxy", "spam", "other", RESERVED_NIC
 
 void rg_initglinelist(struct rg_glinelist *gll);
 void rg_flushglines(struct rg_glinelist *gll);
-static void rg_rename(int hooknum, void *arg);
 
 void _init(void) {
   sstring *max_casualties, *max_spew, *expiry_time, *max_per_gline;
@@ -170,7 +170,7 @@ int rg_rescan(void *source, int cargc, char **cargv) {
 }
 
 void _fini(void) {
-  struct rg_struct *gp = rg_list, *oldgp;
+  struct rg_struct *gp, *oldgp;
   rg_delay *delay, *delaynext;
   
   if(started) {
@@ -294,6 +294,8 @@ void rg_dodelay(void *arg) {
   rg_delay *delay = (rg_delay *)arg;
   char hostname[RG_MASKLEN];
   int hostlen, usercount = 0;
+  char reason[200];
+  int glineflags = 0;
   
   /* User or regex gline no longer exists */
   if((!delay->np) || (!delay->reason)) {
@@ -311,7 +313,6 @@ void rg_dodelay(void *arg) {
   
   if (delay->reason->type == DELAYED_HOST_GLINE) {
     usercount = delay->np->host->clonecount;
-    snprintf(hostname, sizeof(hostname), "*@%s", IPtostr(delay->np->p_ipaddr));
   }
   
   if((delay->reason->type == DELAYED_IDENT_GLINE) || (usercount > rg_max_per_gline)) {
@@ -321,7 +322,7 @@ void rg_dodelay(void *arg) {
       if(!ircd_strcmp(delay->np->ident, tnp->ident))
         usercount++;
 
-    snprintf(hostname, sizeof(hostname), "%s@%s", delay->np->ident, IPtostr(delay->np->p_ipaddr));
+    glineflags = GLINE_ALWAYS_USER;
   }
   
   if ((delay->reason->type == DELAYED_KILL) || (usercount > rg_max_per_gline)) {
@@ -341,7 +342,8 @@ void rg_dodelay(void *arg) {
   }
   
   rg_shadowserver(delay->np, delay->reason, delay->reason->type);
-  irc_send("%s GL * +%s %d %jd :AUTO: %s (ID: %08lx)\r\n", mynumeric->content, hostname, rg_expiry_time, (intmax_t)time(NULL), delay->reason->reason->content, delay->reason->glineid);
+  snprintf(reason, sizeof(reason), "AUTO: %s (ID: %08lx)", delay->reason->reason->content, delay->reason->glineid);
+  glinebynick(delay->np, rg_expiry_time, reason, glineflags, "regexgline");
   rg_deletedelay(delay);
 }
 
@@ -814,7 +816,7 @@ char *displaytype(int type) {
       ctype = "??";
   }
 
-  snprintf(ctypebuf, sizeof(ctype), "%1d:%s", type, ctype);
+  snprintf(ctypebuf, sizeof(ctypebuf), "%1d:%s", type, ctype);
   return ctypebuf;
 }
 
@@ -1076,7 +1078,7 @@ struct rg_struct *rg_newsstruct(unsigned long id, char *mask, char *setby, char
       newrow->type = 0; /* just in case */
 
     snprintf(glineiddata, sizeof(glineiddata), "%s regexgline %s %s %s %d %d", mynumeric->content, mask, setby, reason, (int)iexpires, newrow->type);
-    newrow->glineid = crc32(glineiddata);
+    newrow->glineid = irc_crc32(glineiddata);
   }
   
   return newrow;
@@ -1108,15 +1110,15 @@ struct rg_struct *rg_newsstruct(unsigned long id, char *mask, char *setby, char
 }
 
 int __rg_dogline(struct rg_glinelist *gll, nick *np, struct rg_struct *rp, char *matched) { /* PPA: if multiple users match the same user@host or *@host it'll send multiple glines?! */
-  char hostname[RG_MASKLEN];
   int usercount = 0;
   int validdelay;
+  char reason[200];
+  int glineflags = 0;
 
   rg_loggline(rp, np);
 
   if (rp->type == INSTANT_HOST_GLINE) {
     usercount = np->host->clonecount;
-    snprintf(hostname, sizeof(hostname), "*@%s", IPtostr(np->p_ipaddr));
   }
   
   if ((rp->type == INSTANT_IDENT_GLINE) || (usercount > rg_max_per_gline)) {
@@ -1126,11 +1128,14 @@ int __rg_dogline(struct rg_glinelist *gll, nick *np, struct rg_struct *rp, char
       if(!ircd_strcmp(np->ident, tnp->ident))
         usercount++;
 
-    snprintf(hostname, sizeof(hostname), "%s@%s", np->ident, IPtostr(np->p_ipaddr));
+    glineflags = GLINE_ALWAYS_USER;
   }
 
-  if(!strcmp(rp->class, RESERVED_NICK_CLASS))
-    irc_send("%s GL * +%s!*@* %d %jd :AUTO: %s (ID: %08lx)\r\n", mynumeric->content, np->nick, RESERVED_NICK_GLINE_DURATION, (intmax_t)time(NULL), rp->reason->content, rp->glineid);
+  if(!strcmp(rp->class, RESERVED_NICK_CLASS)) {
+    char reason[512];
+    snprintf(reason, sizeof(reason), "AUTO %s (ID: %08lx)", rp->reason->content, rp->glineid);
+    glinebynick(np, RESERVED_NICK_GLINE_DURATION, reason, GLINE_ALWAYS_NICK, "regexgline");
+  }
 
   validdelay = (rp->type == INSTANT_KILL) || (rp->type == DELAYED_IDENT_GLINE) || (rp->type == DELAYED_HOST_GLINE) || (rp->type == DELAYED_KILL);
   if (validdelay || (usercount > rg_max_per_gline)) {
@@ -1165,7 +1170,8 @@ int __rg_dogline(struct rg_glinelist *gll, nick *np, struct rg_struct *rp, char
   }
   
   rg_shadowserver(np, rp, rp->type);
-  irc_send("%s GL * +%s %d %jd :AUTO: %s (ID: %08lx)\r\n", mynumeric->content, hostname, rg_expiry_time, (intmax_t)time(NULL), rp->reason->content, rp->glineid);
+  snprintf(reason, sizeof(reason), "AUTO: %s (ID: %08lx)", rp->reason->content, rp->glineid);
+  glinebynick(np, rg_expiry_time, reason, glineflags, "regexgline");
   return usercount;
 }
 
@@ -1248,15 +1254,15 @@ void rg_loggline(struct rg_struct *rg, nick *np) {
   rg->lastseen = time(NULL);
   rg->dirty = 1;
 
-  /* @paul: disabled */
+  /* @paul: disabled
 
-  return;
   dbescapestring(eenick, np->nick, strlen(np->nick));
   dbescapestring(eeuser, np->ident, strlen(np->ident));
   dbescapestring(eehost, np->host->name->content, strlen(np->host->name->content));
   dbescapestring(eereal, np->realname->name->content, strlen(np->realname->name->content));
 
   dbquery("INSERT INTO regexgline.glog (glineid, nickname, username, hostname, realname, ts) VALUES (%d, '%s', '%s', '%s', '%s', NOW())", rg->id, eenick, eeuser, eehost, eereal);
+  */
 }
 
 static unsigned int getrgmarker(void) {