]> jfr.im git - irc/quakenet/newserv.git/commitdiff
fix proxyscan for iptre
authorPaul <redacted>
Mon, 28 May 2007 13:32:20 +0000 (13:32 +0000)
committerPaul <redacted>
Mon, 28 May 2007 13:32:20 +0000 (13:32 +0000)
proxyscan/proxyscan.c
proxyscan/proxyscancache.c
proxyscan/proxyscandb.c
proxyscan/proxyscanhandlers.c

index 0d681d907110b7d817f567058d9390cd8384f0cc..0a9abfc79dd2ce1e2a086709d0cd56c45757cf71 100644 (file)
@@ -170,7 +170,7 @@ void _init(void) {
     freesstring(cfgstr);
     
     ps_mailname=getcopyconfigitem("proxyscan","mailname","some.mail.server",HOSTLEN);
-    Error("proxyscan",ERR_INFO,"Proxyscan mailer enabled; mailing to %s as %s.",IPtostr(ps_mailip),ps_mailname->content);
+    Error("proxyscan",ERR_INFO,"Proxyscan mailer enabled; mailing to %s as %s.",IPlongtostr(ps_mailip),ps_mailname->content);
   } else {
     ps_mailport=0;
     ps_mailname=NULL;
@@ -533,8 +533,8 @@ void killsock(scan *sp, int outcome) {
       glinedhosts++;
       loggline(chp);
       irc_send("%s GL * +*@%s 1800 :Open Proxy, see http://www.quakenet.org/openproxies.html - ID: %d",
-              mynumeric->content,IPtostr(sp->IP),chp->glineid);
-      Error("proxyscan",ERR_DEBUG,"Found open proxy on host %s",IPtostr(sp->IP));
+              mynumeric->content,IPlongtostr(sp->IP),chp->glineid);
+      Error("proxyscan",ERR_DEBUG,"Found open proxy on host %s",IPlongtostr(sp->IP));
     } else {
       loggline(chp);  /* Update log only */
     }
@@ -842,7 +842,7 @@ void proxyscandebug(nick *np) {
       }
       totalscansfound++;
       sendnoticetouser(proxyscannick,np,"fd: %d type: %d port: %d state: %d outcome: %d IP: %s",
-                      sp->fd,sp->type,sp->port,sp->state,sp->outcome,IPtostr(sp->IP));
+                      sp->fd,sp->type,sp->port,sp->state,sp->outcome,IPlongtostr(sp->IP));
     }
   }
 
index 168100293b7daeda1000cf6cb555fc654b53c1cc..c8748e5a15c196235ecaa299f189889b87b708a1 100644 (file)
@@ -232,10 +232,15 @@ void scanall(int type, int port) {
 
       np->host->marker=hostmarker;
 
-      if ((chp=findcachehost(np->ipaddress)))
+      if (!irc_in_addr_is_ipv4(&np->p_ipaddr))
+        continue;
+
+      unsigned int ip2 = irc_in_addr_v4_to_int(&np->p_ipaddr);
+
+      if ((chp=findcachehost(ip2)))
        chp->marker=1;
 
-      queuescan(np->ipaddress, type, port, SCLASS_NORMAL, 0);
+      queuescan(ip2, type, port, SCLASS_NORMAL, 0);
     }
   }
 
index 874d2b7242ad6d8cc56e2a5358c72d848ec7f7bf..d26f9f57f6fd25976bda7486bd35f5ca39942b68 100644 (file)
@@ -163,7 +163,7 @@ void loggline(cachehost *chp) {
 
     mysql_escape_string(reasonesc,reasonlist,strlen(reasonlist));
     sprintf(sqlquery,"INSERT INTO openproxies VALUES(%u,'%s',%d,NOW(),'%s')",chp->glineid,
-           IPtostr(chp->IP),reasonmask,reasonesc);
+           IPlongtostr(chp->IP),reasonmask,reasonesc);
     mysql_query(&proxyscansql,sqlquery);
   } else {
     mysql_escape_string(reasonesc,reasonlist,strlen(reasonlist));
index 4a9585f3af3b73bf8d6a967fee57202617fe16f2..6bde0a73e6037cbeb93fccc7e541412893329c37 100644 (file)
@@ -9,9 +9,11 @@ void proxyscan_newnick(int hooknum, void *arg) {
   int i;
 
   /* Skip 127.* and 0.* hosts */
-  if ((np->ipaddress>>24==0) || (np->ipaddress>>24==127))
+  if (irc_in_addr_is_loopback(&np->p_ipaddr) || !irc_in_addr_is_ipv4(&np->p_ipaddr)) 
     return;
 
+  unsigned int ip = irc_in_addr_v4_to_int(&np->p_ipaddr);
+
   /*
    * Logic for connecting hosts:
    *
@@ -26,7 +28,7 @@ void proxyscan_newnick(int hooknum, void *arg) {
    * If they're not in the cache, we queue up their scans
    */
 
-  if ((chp=findcachehost(np->ipaddress))) {
+  if ((chp=findcachehost(ip))) {
     if (!chp->proxies)
       return;
 
@@ -41,30 +43,30 @@ void proxyscan_newnick(int hooknum, void *arg) {
           break;
       
       if (!fpp)
-        queuescan(np->ipaddress, thescans[i].type, thescans[i].port, SCLASS_NORMAL, 0);
+        queuescan(ip, thescans[i].type, thescans[i].port, SCLASS_NORMAL, 0);
       }
     }
 
     /* We want these scans to start around now, so we put them at the front of the priority queue */
     for (fpp=chp->proxies;fpp;fpp=nfpp) {
       nfpp=fpp->next;
-      queuescan(np->ipaddress, fpp->type, fpp->port, SCLASS_CHECK, time(NULL));
+      queuescan(ip, fpp->type, fpp->port, SCLASS_CHECK, time(NULL));
       freefoundproxy(fpp);
     }
 
     /* 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 :Open Proxy, see http://www.quakenet.org/openproxies.html - ID: %d",
-            mynumeric->content,IPtostr(np->ipaddress),chp->glineid);
+            mynumeric->content,IPtostr(np->p_ipaddr),chp->glineid);
 
     chp->lastscan=time(NULL);
     chp->proxies=NULL;
     chp->glineid=0;
   } else {
-    chp=addcleanhost(np->ipaddress, time(NULL));
+    chp=addcleanhost(ip, time(NULL));
 
     /* Queue up all the normal scans - on the normal queue */
     for (i=0;i<numscans;i++)
-      queuescan(np->ipaddress, thescans[i].type, thescans[i].port, SCLASS_NORMAL, 0);
+      queuescan(ip, thescans[i].type, thescans[i].port, SCLASS_NORMAL, 0);
   }
 }