]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Merge.
authorChris Porter <redacted>
Sat, 12 Jul 2008 12:15:25 +0000 (13:15 +0100)
committerChris Porter <redacted>
Sat, 12 Jul 2008 12:15:25 +0000 (13:15 +0100)
nick/nickhandlers.c
proxyscan/proxyscanext.c [new file with mode: 0644]

index fd6a1fd4c1b6e1733e94aa92e2f68766e159051b..56529726b460e2bb0c5e34731d52621ea8a7776f 100644 (file)
@@ -139,8 +139,7 @@ int handlenickmsg(void *source, int cargc, char **cargv) {
     np->timestamp=timestamp;
 
     base64toip(cargv[cargc-3], &ipaddress);
-    /* todo: use a single node for /64 prefixes */
-    np->ipnode = refnode(iptree, &ipaddress, irc_in_addr_is_ipv4(&ipaddress) ? PATRICIA_MAXBITS : 64);
+    np->ipnode = refnode(iptree, &ipaddress, PATRICIA_MAXBITS);
     node_increment_usercount(np->ipnode);
 
     np->shident=NULL;
diff --git a/proxyscan/proxyscanext.c b/proxyscan/proxyscanext.c
new file mode 100644 (file)
index 0000000..52e5fbd
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * proxyscanext.c:
+ *  This file deals with extended ports to scan.
+ */
+
+#include "proxyscan.h"
+#include <time.h>
+#include <stdio.h>
+#include "../core/error.h"
+#include <string.h>
+
+extrascan *addextrascan(unsigned short port, unsigned char type) {
+  extrascan *esp;
+
+  esp=getextrascan();
+  esp->port=port;
+  esp->type=type;
+  
+  return esp;
+}
+
+void delextrascan(extrascan *esp) {
+  freeextrascan(esp);
+}
+
+/*
+ * Returns a cachehost * for the named IP
+ */
+
+extrascan *findextrascan(patricia_node_t *node) {
+  extrascan *esp;
+
+  if( (extrascan *)node->exts[ps_extscan_ext] ) {
+    esp = (extrascan *)node->exts[ps_extscan_ext];
+    if (esp) {
+      /* valid: return it */
+      return esp;
+    }
+  }
+
+  /* Not found: return NULL */
+  return NULL;
+}
+
+void loadextrascans() {
+  FILE *fp;
+  unsigned short port;
+  char buf[512];
+  extrascan *esp=NULL;
+  char ip[512];
+  int res;
+  struct irc_in_addr sin;
+  unsigned char bits;
+  patricia_node_t *node;
+
+  if ((fp=fopen("ports.txt","r"))==NULL) {
+    Error("proxyscan",ERR_ERROR,"Unable to open ports file for reading!");
+    return;
+  }
+
+
+  while (!feof(fp)) {
+    fgets(buf,512,fp);
+    if (feof(fp)) {
+      break;
+    }
+
+    res=sscanf(buf,"%s %hu",&ip,&port);
+
+    if (res<2)
+      continue;
+
+    if (0 == ipmask_parse(ip,&sin, &bits)) {
+      /* invalid mask */
+    } else {
+      node = refnode(iptree, &sin, bits);
+      if( node ) {
+        esp=addextrascan(port, STYPE_SOCKS4);
+       esp->nextbynode = (extrascan *)node->exts[ps_extscan_ext];
+        node->exts[ps_extscan_ext] = esp;
+
+        esp=addextrascan(port, STYPE_SOCKS5);
+        esp->nextbynode = (extrascan *)node->exts[ps_extscan_ext];
+        node->exts[ps_extscan_ext] = esp;
+
+        esp=addextrascan(port, STYPE_HTTP);
+        esp->nextbynode = (extrascan *)node->exts[ps_extscan_ext];
+        node->exts[ps_extscan_ext] = esp;
+      }
+    }
+  }
+}
+
+
+unsigned int extrascancount() {
+  int i;
+  unsigned int total=0;
+  extrascan *esp;
+  patricia_node_t *node;
+
+  PATRICIA_WALK (iptree->head, node) {
+    if ( node->exts[ps_extscan_ext] ) {
+      esp = (extrascan *) node->exts[ps_extscan_ext];
+      if (esp) 
+        total++;
+    }
+  } PATRICIA_WALK_END;
+
+  return total;
+}
+