]> jfr.im git - irc/quakenet/newserv.git/blobdiff - proxyscan/proxyscan.c
merge
[irc/quakenet/newserv.git] / proxyscan / proxyscan.c
index 11e179841571e44b84aa77395af2674d5ad57651..8e2190a77480969db9d3cb91805b9962885a82cf 100644 (file)
@@ -285,6 +285,7 @@ void _init(void) {
   proxyscan_addscantype(STYPE_DIRECT_IRC, 6668);
   proxyscan_addscantype(STYPE_DIRECT_IRC, 6669);
   proxyscan_addscantype(STYPE_DIRECT_IRC, 6670);
+  proxyscan_addscantype(STYPE_ROUTER, 3128);
  
   /* Schedule saves */
   schedulerecurring(time(NULL)+3600,0,3600,&dumpcachehosts,NULL);
@@ -571,6 +572,8 @@ void killsock(scan *sp, int outcome) {
     }
   }
 
+  /* deref prefix (referenced in queuescan) */
+  derefnode(iptree,sp->node);
   freescan(sp);
 
   /* kick the queue.. */
@@ -712,6 +715,16 @@ void handlescansock(int fd, short events) {
         return;
       }
       
+      /* Do nothing */
+      break;    
+
+    case STYPE_ROUTER:
+      sprintf(buf,"GET /nonexistent HTTP/1.0\r\n\r\n");
+      if ((write(fd,buf,strlen(buf)))<strlen(buf)) {
+       killsock(sp, SOUTCOME_CLOSED);
+        return;
+      }
+      
       /* Do nothing */
       break;    
     }                
@@ -735,12 +748,15 @@ void handlescansock(int fd, short events) {
       char *magicstring;
       int magicstringlength;
 
-      if(sp->type != STYPE_DIRECT_IRC) {
-        magicstring = MAGICSTRING;
-        magicstringlength = MAGICSTRINGLENGTH;
-      } else {
+      if(sp->type == STYPE_DIRECT_IRC) {
         magicstring = MAGICIRCSTRING;
         magicstringlength = MAGICIRCSTRINGLENGTH;
+      } else if(sp->type == STYPE_ROUTER) {
+        magicstring = MAGICROUTERSTRING;
+        magicstringlength = MAGICROUTERSTRINGLENGTH;
+      } else {
+        magicstring = MAGICSTRING;
+        magicstringlength = MAGICSTRINGLENGTH;
       }
 
       for (i=0;i<sp->bytesread - magicstringlength;i++) {
@@ -967,6 +983,11 @@ int proxyscandoscan(void *sender, int cargc, char **cargv) {
   if (0 == ipmask_parse(cargv[0],&sin, &bits)) {
     sendnoticetouser(proxyscannick,np,"Usage: scan <ip>");
   } else {
+    if (bits != 128 || !irc_in_addr_is_ipv4(&sin) || irc_in_addr_is_loopback(&sin)) {
+      sendnoticetouser(proxyscannick,np,"You may only scan single IPv4 IP's");
+      return CMD_OK;
+    }
+
     time_t t;
     sendnoticetouser(proxyscannick,np,"Forcing scan of %s",IPtostr(sin));
     // * Just queue the scans directly here.. plonk them on the priority queue * /