]> jfr.im git - irc/quakenet/newserv.git/commitdiff
glines: update gline set function constructors
authorPaul <redacted>
Wed, 19 Jun 2013 21:50:47 +0000 (22:50 +0100)
committerPaul <redacted>
Wed, 19 Jun 2013 21:50:47 +0000 (22:50 +0100)
chanserv/chanservschedule.c
glines/glines.c
glines/glines.h
proxyscan/proxyscan.c
proxyscan/proxyscanhandlers.c
versionscan/versionscan.c

index fc44308e2387f6c1948b561aa666c2835ca9799e..5b6816b68a9c769cd0a31ab3d1fabc14aab82494 100644 (file)
@@ -29,8 +29,7 @@ void chanservdgline(void* arg) {
       if(rup->suspendreason)
         reason = rup->suspendreason->content;
 
-      irc_send("%s GL * +*!%s@%s 3600 :%s\r\n", mynumeric->content, nl->ident, 
-        IPtostr(nl->p_ipaddr), reason);
+      glinesetbynick(nl, 3600, reason, "chanserv", 0);
       chanservwallmessage("Delayed GLINE \"*!%s@%s\" (authed as %s) expires in 60 minute/s (hit %d user%s) (reason: %s)", 
         nl->ident, IPtostr(nl->p_ipaddr), rup->username, ucount, ucount==1?"":"s", reason);
     }
index 794e612f1a091e6e4cab5912b1f070155373886c..d6d6ffea51bd0333840fed381f0c6214de0d234f 100644 (file)
@@ -1,20 +1,23 @@
 #include "../irc/irc.h"
-
 #include "../trusts/trusts.h"
 #include "glines.h"
 
-void glinebynick(nick *np, int duration, char *reason) {
+void glinesetbynick(nick *np, int duration, char *reason, char *creator, int flags) {
   irc_send("%s GL * +%s@%s %d %jd :%s", mynumeric->content, istrusted(np)?np->ident:"*", IPtostr(np->p_ipaddr), duration, (intmax_t)getnettime(), reason);
 }
 
-void glinebyhost(char *ident, char *hostname, int duration, char *reason) {
-  /* TODO: resolve trustgroup and trustgline */
+void glinesetbynode( patricia_node_t *node, int duration, char *reason, char *creator) {
+  irc_send("%s GL * +*@%s %d %jd :%s", mynumeric->content, IPtostr(node->prefix->sin), duration, (intmax_t)getnettime(), reason);
+}
+
 
+/**
+ * This should be avoided (where possible) and gline on Nick/IPs instead
+ */
+void glinesetbyhost(char *ident, char *hostname, int duration, char *reason, char *creator) {
   irc_send("%s GL * +%s@%s %d %jd :%s", mynumeric->content, ident, hostname, duration, (intmax_t)getnettime(), reason);
 }
 
 void unglinebyhost(char *ident, char *hostname, int duration, char *reason) {
-  /* TODO: trustungline */
-
   irc_send("%s GL * -%s@%s %d %jd :%s", mynumeric->content, ident, hostname, duration, (intmax_t)getnettime(), reason);
 }
index 29f554d4c16504b8251605169c2375ae75c9c024..2605921711260b0d1fd2c93648031cf3817c720e 100644 (file)
@@ -1,8 +1,12 @@
 #ifndef __GLINES_H
 #define __GLINES_H
 
-void glinebynick(nick *, int, char *);
-void glinebyhost(char *, char *, int, char *);
+void glinesetbynick(nick *, int, char *, char *, int);
+void glinesetbynode( patricia_node_t *, int, char *, char *);
+void glinesetbyhost(char *, char *, int, char *, char *);
+
 void unglinebyhost(char *, char *, int, char *);
 
+#define GLINE_FORCE_IDENT 1
+
 #endif
index 4f0ce921df4f474ee1e1cf1cd6f5cbc802369258..7abfae3a95b13d355a166814f053d9aad87b0e68 100644 (file)
@@ -27,6 +27,7 @@
 #include "../localuser/localuserchannel.h"
 #include "../core/nsmalloc.h"
 #include "../lib/irc_ipv6.h"
+#include "../glines/glines.h"
 
 MODULE_VERSION("")
 
@@ -574,6 +575,7 @@ void killsock(scan *sp, int outcome) {
     /* the purpose of this lastgline stuff is to stop gline spam from one scan */
     if (!chp->glineid || (now>=chp->lastgline+SCANTIMEOUT)) {
       char buf[512];
+      char reason[200];
       const char *ip;
 
       chp->lastgline=now;
@@ -581,8 +583,8 @@ void killsock(scan *sp, int outcome) {
 
       loggline(chp, sp->node);   
       ip = IPtostr(((patricia_node_t *)sp->node)->prefix->sin);
-      irc_send("%s GL * +*@%s 1800 %jd :Open Proxy, see http://www.quakenet.org/openproxies.html - ID: %d",
-              mynumeric->content,ip,(intmax_t)getnettime(), chp->glineid);
+      snprintf(reason, sizeof(reason), "Open Proxy, see http://www.quakenet.org/openproxies.html - ID: %d", chp->glineid);
+      glinesetbynode( (patricia_node_t *)sp->node, 1800, reason, "proxyscan" ); 
       Error("proxyscan",ERR_DEBUG,"Found open proxy on host %s",ip);
 
       snprintf(buf, sizeof(buf), "proxy-gline %lu %s %s %hu %s", time(NULL), ip, scantostr(sp->type), sp->port, "irc.quakenet.org");
index 28bdd0de905626d039d4ecbbd9f68c8440e49661..873af41a188687b0232f2f60ca45fe18020c8346 100644 (file)
@@ -1,13 +1,16 @@
+#include <stdio.h>
 #include "proxyscan.h"
 #include "../irc/irc.h"
 #include "../lib/irc_string.h"
 #include "../core/error.h"
+#include "../glines/glines.h"
 
 void proxyscan_newnick(int hooknum, void *arg) {
   nick *np=(nick *)arg;
   cachehost *chp;
   foundproxy *fpp, *nfpp;
   extrascan *esp, *espp;
+  char reason[200];
 
   int i;
 
@@ -76,8 +79,8 @@ void proxyscan_newnick(int hooknum, void *arg) {
     }
 
     /* set a SHORT gline - if they really have an open proxy the gline will be re-set, with a new ID */
-    irc_send("%s GL * +*@%s 600 %jd :Open Proxy, see http://www.quakenet.org/openproxies.html - ID: %d",
-            mynumeric->content,IPtostr(np->p_ipaddr),(intmax_t)getnettime(), chp->glineid);
+    snprintf(reason, sizeof(reason), "Open Proxy, see http://www.quakenet.org/openproxies.html - ID: %d", chp->glineid);
+    glinesetbynode(np->ipnode, 600, reason, "proxyscan");
 
     chp->lastscan=time(NULL);
     chp->proxies=NULL;
index b930966331e2ca5f4c6005b5bbfefc231d225130..6006cd6ff5dd23e887e0bc0d71930b17c6512265 100644 (file)
@@ -1,5 +1,6 @@
 #include "versionscan.h"
 #include "../lib/version.h"
+#include "../glines/glines.h"
 
 MODULE_VERSION("")
 
@@ -772,11 +773,11 @@ void versionscan_handler(nick* me, int type, void** args) {
             kcount++;
             break;
           case VS_GLUSER:
-            irc_send("%s GL * +*!%s@%s 3600 :%s\r\n", mynumeric->content, sender->ident, sender->host->name->content, v->data);
+            glinesetbynick(sender, 3600, v->data, versionscan_nick->nick, GLINE_FORCE_IDENT);
             gcount++;
             break;
           case VS_GLHOST:
-            irc_send("%s GL * +*!*@%s 3600 :%s\r\n", mynumeric->content, sender->host->name->content, v->data);
+            glinesetbynick(sender, 3600, v->data, versionscan_nick->nick, 0);
             gcount++;
             break;
           default: