]> jfr.im git - irc/quakenet/newserv.git/blobdiff - regexgline/regexgline.c
Use includes in all makefiles.
[irc/quakenet/newserv.git] / regexgline / regexgline.c
index 0b3cbfa01f1d0dd5118ae34cdc7b93ed03378bf5..8fe98f9d0c0bf79183abbee20e9d082ed6caed4e 100644 (file)
@@ -9,6 +9,9 @@
 */
 
 #include "regexgline.h"
+#include "../lib/version.h"
+
+MODULE_VERSION("");
 
 typedef struct rg_glinenode {
   nick *np;
@@ -201,7 +204,7 @@ void rg_dodelay(void *arg) {
   
   if (delay->reason->type == 5) {
     usercount = delay->np->host->clonecount;
-    snprintf(hostname, sizeof(hostname), "*@%s", IPtostr(delay->np->ipaddress));
+    snprintf(hostname, sizeof(hostname), "*@%s", IPtostr(delay->np->p_ipaddr));
   }
   
   if((delay->reason->type == 4) || (usercount > rg_max_per_gline)) {
@@ -211,7 +214,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->ipaddress));
+    snprintf(hostname, sizeof(hostname), "%s@%s", delay->np->ident, IPtostr(delay->np->p_ipaddr));
   }
   
   if ((delay->reason->type == 6) || (usercount > rg_max_per_gline)) {
@@ -241,7 +244,7 @@ void rg_dodelay(void *arg) {
     }
   }
   
-  irc_send("%s GL * +%s %d :%s (ID: %08lx)\r\n", mynumeric->content, hostname, rg_expiry_time, delay->reason->reason->content, delay->reason->glineid);
+  irc_send("%s GL * +%s %d :AUTO: %s (ID: %08lx)\r\n", mynumeric->content, hostname, rg_expiry_time, delay->reason->reason->content, delay->reason->glineid);
   rg_deletedelay(delay);
 }
 
@@ -896,7 +899,7 @@ struct rg_struct *rg_newsstruct(char *id, char *mask, char *setby, char *reason,
     return NULL;
 }
 
-void 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?! */
+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;
 
@@ -904,7 +907,7 @@ void rg_dogline(struct rg_glinelist *gll, nick *np, struct rg_struct *rp, char *
 
   if (rp->type == 2) {
     usercount = np->host->clonecount;
-    snprintf(hostname, sizeof(hostname), "*@%s", IPtostr(np->ipaddress));
+    snprintf(hostname, sizeof(hostname), "*@%s", IPtostr(np->p_ipaddr));
   }
   
   if ((rp->type == 1) || (usercount > rg_max_per_gline)) {
@@ -914,7 +917,7 @@ void 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->ipaddress));
+    snprintf(hostname, sizeof(hostname), "%s@%s", np->ident, IPtostr(np->p_ipaddr));
   }
 
   if ((rp->type >= 3) || (usercount > rg_max_per_gline)) {
@@ -937,11 +940,11 @@ void rg_dogline(struct rg_glinelist *gll, nick *np, struct rg_struct *rp, char *
         nn->punish = rp->type;
       }
     }
-    return;
+    return usercount;
   }
   
   if ((rp->type <= 0) || (rp->type >= 3))
-    return;
+    return 0;
   
   if (rp->type == 1) {
     if (IsAccount(np)) {
@@ -957,14 +960,34 @@ void rg_dogline(struct rg_glinelist *gll, nick *np, struct rg_struct *rp, char *
     }
   }
   
-  irc_send("%s GL * +%s %d :%s (ID: %08lx)\r\n", mynumeric->content, hostname, rg_expiry_time, rp->reason->content, rp->glineid);
+  irc_send("%s GL * +%s %d :AUTO: %s (ID: %08lx)\r\n", mynumeric->content, hostname, rg_expiry_time, rp->reason->content, rp->glineid);
+  return usercount;
+}
+
+int floodprotection = 0;
+
+void rg_dogline(struct rg_glinelist *gll, nick *np, struct rg_struct *rp, char *matched) {
+  int t = time(NULL);
+
+  if(t > floodprotection) {
+    floodprotection = t;
+  } else if((floodprotection - t) / 8 > RG_NETWORK_WIDE_MAX_GLINES_PER_8_SEC) {
+    channel *cp = findchannel("#twilightzone");
+    if(cp)
+      controlchanmsg(cp, "WARNING! REGEXGLINE DISABLED FOR AN HOUR DUE TO NETWORK WIDE LOOKING GLINE!");
+    controlwall(NO_OPER, NL_MANAGEMENT, "WARNING! REGEXGLINE DISABLED FOR AN HOUR DUE TO NETWORK WIDE LOOKING GLINE!");
+    floodprotection = t + RG_NETWORK_WIDE_MAX_GLINES_PER_8_SEC * 3600 * 8;
+  }
+
+  floodprotection+=__rg_dogline(gll, np, rp, matched);
 }
 
 void rg_logevent(nick *np, char *event, char *details, ...) {
   char eeevent[RG_QUERY_BUF_SIZE], eedetails[RG_QUERY_BUF_SIZE], eemask[RG_QUERY_BUF_SIZE], eeaccount[RG_QUERY_BUF_SIZE];
   char buf[513], account[ACCOUNTLEN + 1], mask[RG_MASKLEN];
   int masklen;
-  
+
+  return;
   va_list va;
     
   va_start(va, details);
@@ -995,6 +1018,7 @@ void rg_logevent(nick *np, char *event, char *details, ...) {
 void rg_loggline(struct rg_struct *rg, nick *np) {
   char eenick[RG_QUERY_BUF_SIZE], eeuser[RG_QUERY_BUF_SIZE], eehost[RG_QUERY_BUF_SIZE], eereal[RG_QUERY_BUF_SIZE];
 
+  return;
   rg_sqlescape_string(eenick, np->nick, strlen(np->nick));
   rg_sqlescape_string(eeuser, np->ident, strlen(np->ident));
   rg_sqlescape_string(eehost, np->host->name->content, strlen(np->host->name->content));