]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Merge.
authorChris Porter <redacted>
Thu, 10 Nov 2011 18:33:11 +0000 (18:33 +0000)
committerChris Porter <redacted>
Thu, 10 Nov 2011 18:33:11 +0000 (18:33 +0000)
proxyscan/proxyscan.c
proxyscan/proxyscan.h
proxyscan/proxyscancache.c
proxyscan/proxyscanconnect.c
proxyscan/proxyscanhandlers.c

index 0f2a4ebc59e5f7ba44ad936b5559f1af7eac6315..1052a4ede017b01fb2bd2da65e880a76a95d7f94 100644 (file)
@@ -173,7 +173,7 @@ void _init(void) {
   freesstring(cfgstr);
   
   /* Max concurrent scans */
-  cfgstr=getcopyconfigitem("proxyscan","maxscans","200",5);
+  cfgstr=getcopyconfigitem("proxyscan","maxscans","200",10);
   maxscans=strtol(cfgstr->content,NULL,10);
   freesstring(cfgstr);
 
@@ -239,11 +239,11 @@ void _init(void) {
   addcommandtotree(ps_commands, "status", 0, 0, &proxyscandostatus);
   addcommandtotree(ps_commands, "listopen", 0, 0, &proxyscandolistopen);
   addcommandtotree(ps_commands, "save", 0, 0, &proxyscandosave);
-  addcommandtotree(ps_commands, "spew", 0, 0, &proxyscandospew);
-  addcommandtotree(ps_commands, "showkill", 0, 0, &proxyscandoshowkill);
-  addcommandtotree(ps_commands, "scan", 0, 0, &proxyscandoscan);
-  addcommandtotree(ps_commands, "addscan", 0, 0, &proxyscandoaddscan);
-  addcommandtotree(ps_commands, "delscan", 0, 0, &proxyscandodelscan);
+  addcommandtotree(ps_commands, "spew", 0, 1, &proxyscandospew);
+  addcommandtotree(ps_commands, "showkill", 0, 1, &proxyscandoshowkill);
+  addcommandtotree(ps_commands, "scan", 0, 1, &proxyscandoscan);
+  addcommandtotree(ps_commands, "addscan", 0, 1, &proxyscandoaddscan);
+  addcommandtotree(ps_commands, "delscan", 0, 1, &proxyscandodelscan);
 
   /* Default scan types */
   proxyscan_addscantype(STYPE_HTTP, 8080);
@@ -480,7 +480,7 @@ void startscan(patricia_node_t *node, int type, int port, int class) {
   sp->totalbytesread=0;
   memset(sp->readbuf, '\0', PSCAN_READBUFSIZE);
 
-  sp->fd=createconnectsocket(irc_in_addr_v4_to_int(&((patricia_node_t *)sp->node)->prefix->sin),sp->port);
+  sp->fd=createconnectsocket(&((patricia_node_t *)sp->node)->prefix->sin,sp->port);
   sp->state=SSTATE_CONNECTING;
   if (sp->fd<0) {
     /* Couldn't set up the socket? */
@@ -948,6 +948,9 @@ int proxyscandosave(void *sender, int cargc, char **cargv) {
 int proxyscandospew(void *sender, int cargc, char **cargv) {
   nick *np = (nick *)sender;
 
+  if(cargc < 1)
+    return CMD_USAGE;
+
   /* check our database for the ip supplied */
   unsigned long a,b,c,d;
   if (4 != sscanf(cargv[0],"%lu.%lu.%lu.%lu",&a,&b,&c,&d)) {
@@ -962,6 +965,9 @@ int proxyscandospew(void *sender, int cargc, char **cargv) {
 int proxyscandoshowkill(void *sender, int cargc, char **cargv) {
   nick *np = (nick *)sender;
 
+  if(cargc < 1)
+    return CMD_USAGE;
+
   /* check our database for the id supplied */
   unsigned long a;
   if (1 != sscanf(cargv[0],"%lu",&a)) {
@@ -989,11 +995,14 @@ int proxyscandoscan(void *sender, int cargc, char **cargv) {
   unsigned char bits;
   int i;
 
+  if(cargc < 1)
+    return CMD_USAGE;
+
   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");
+    if (bits != 128 || irc_in_addr_is_loopback(&sin)) {
+      sendnoticetouser(proxyscannick,np,"You may only scan single IP's");
       return CMD_OK;
     }
 
@@ -1013,6 +1022,9 @@ int proxyscandoscan(void *sender, int cargc, char **cargv) {
 int proxyscandoaddscan(void *sender, int cargc, char **cargv) {
   nick *np = (nick *)sender;
 
+  if(cargc < 1)
+    return CMD_USAGE;
+
   unsigned int a,b;
   if (sscanf(cargv[0],"%u %u",&a,&b) != 2) {
     sendnoticetouser(proxyscannick,np,"Usage: addscan <type> <port>");
@@ -1027,6 +1039,9 @@ int proxyscandoaddscan(void *sender, int cargc, char **cargv) {
 int proxyscandodelscan(void *sender, int cargc, char **cargv) {
   nick *np = (nick *)sender;
 
+  if(cargc < 1)
+    return CMD_USAGE;
+
   unsigned int a,b;
   if (sscanf(cargv[0],"%u %u",&a,&b) != 2) {
     sendnoticetouser(proxyscannick,np,"Usage: delscan <type> <port>");
index e4a638917ae82aa082f43913c3dbac54f340fce0..7770bb69e1c971efe7fb9f7468c3a12278807fc1 100644 (file)
@@ -154,7 +154,7 @@ int openlistensocket(int portnum);
 void handlelistensocket(int fd, short events);
 
 /* proxyscanconnect.c */
-int createconnectsocket(long ip, int socknum);
+int createconnectsocket(struct irc_in_addr *ip, int socknum);
 
 /* proxyscandb.c */
 void loggline(cachehost *chp, patricia_node_t *node);
index f14fbd2b5090e4d97145c5491a8dedf7ae50b46f..df2a432ec5ef6569dda3b1ba40d3e8e4a50bb00a 100644 (file)
@@ -238,9 +238,6 @@ void scanall(int type, int port) {
 
       np->host->marker=hostmarker;
 
-      if (!irc_in_addr_is_ipv4(&np->p_ipaddr))
-        continue;
-
       if ((chp=findcachehost(np->ipnode)))
        chp->marker=1;
 
index 10a43dcf4a04cb36a1d31b7e1b4d9cc947d475ba..6e1440bafadfee80f030d5003701b2b43be3ba3e 100644 (file)
 #include <sys/ioctl.h>
 #include <string.h>
 
-int createconnectsocket(long ip, int socknum) {
-  int fd;
-  struct sockaddr_in sin;
+int createconnectsocket(struct irc_in_addr *ip, int socknum) {
+  union {
+    struct sockaddr_in sin;
+    struct sockaddr_in6 sin6;
+  } u;
+
+  int proto;
+  int s;
   int res=1;
   unsigned int opt=1;
-  
-  memset(&sin,0,sizeof(sin));
-  
-  sin.sin_family=AF_INET;
-  sin.sin_port=htons(socknum);
-  sin.sin_addr.s_addr=htonl(ip);
-  
-  if ((fd=socket(AF_INET,SOCK_STREAM,0))<0) {
+  int fd;
+
+  if(irc_in_addr_is_ipv4(ip)) {
+    s = sizeof(u.sin);
+    proto=u.sin.sin_family=AF_INET;
+    u.sin.sin_port=htons(socknum);
+    u.sin.sin_addr.s_addr=htonl(irc_in_addr_v4_to_int(ip));
+  } else {
+    s = sizeof(u.sin6);
+    proto=u.sin6.sin6_family=AF_INET6;
+    u.sin6.sin6_port=htons(socknum);
+    memcpy(&u.sin6.sin6_addr.s6_addr, ip->in6_16, sizeof(ip->in6_16));
+  }
+
+  if ((fd=socket(proto,SOCK_STREAM,0))<0) {
     Error("proxyscan",ERR_ERROR,"Unable to create socket (%d)",errno);
     return -1;
   }
@@ -40,12 +52,13 @@ int createconnectsocket(long ip, int socknum) {
     Error("proxyscan",ERR_WARNING,"Error selecting high port range.");
   }
 #endif
-  if (connect(fd,(const struct sockaddr *) &sin, sizeof(sin))) {
+
+  if (connect(fd,(const struct sockaddr *) &u, s)) {
     if (errno != EINPROGRESS) {
       Error("proxyscan",ERR_ERROR,"Unable to connect socket (%d)",errno);
       return -1;
     }
-  }  
+  }
+
   return fd;
 }
-
index 012ce4ad478984024086fa3165577bd5c3f4b28e..3b6311ca354a96bf0a14e701b8498e9575bc71b1 100644 (file)
@@ -12,7 +12,7 @@ void proxyscan_newnick(int hooknum, void *arg) {
   int i;
 
   /* Skip 127.* and 0.* hosts */
-  if (irc_in_addr_is_loopback(&np->p_ipaddr) || !irc_in_addr_is_ipv4(&np->p_ipaddr)) 
+  if (irc_in_addr_is_loopback(&np->p_ipaddr))
     return;
 
   /* slug: why is this here? why isn't it with the other queuing stuff? */