]> jfr.im git - irc/quakenet/newserv.git/commitdiff
Merge.
authorsplidge <redacted>
Mon, 8 Mar 2010 14:38:48 +0000 (14:38 +0000)
committersplidge <redacted>
Mon, 8 Mar 2010 14:38:48 +0000 (14:38 +0000)
28 files changed:
channel/channelbans.c
chanserv/authcmds/authhistory.c
chanserv/authtracker/authtracker.c
chanserv/authtracker/authtracker.h
chanserv/authtracker/authtracker_db.c
chanserv/chancmds/invite.c
chanserv/chanservuser.c
control/control.c
helpmod2/helpmod2.c
irc/irc_config.h
localuser/localuser.c
localuser/localuserchannel.c
localuser/localuserchannel.h
lua/luacommands.c
newsearch/Makefile.in
newsearch/newsearch.c
newsearch/newsearch.h
newsearch/ns-away.c [new file with mode: 0644]
nick/nick.c
nick/nick.h
nick/nickhandlers.c
proxyscan/Makefile.in
proxyscan/pns-scan.c [new file with mode: 0644]
proxyscan/proxyscan.c
proxyscan/proxyscan.h
proxyscan/proxyscan_newsearch.c [new file with mode: 0644]
proxyscan/proxyscancache.c
proxyscan/proxyscanhandlers.c

index fe772c67e605113e50daccf8ebde9558d1d20e76..fc86bc760fafe50a2b7e210c1717a53a9419bf48 100644 (file)
@@ -23,10 +23,12 @@ int nickmatchban(nick *np, chanban *bp, int visibleonly) {
   char fakehost[HOSTLEN+1];
   char *ident;
 
-  /* nick/ident section: return 0 (no match) if they don't match */
+  /* If it's not valid, don't bother */
   if (bp->flags & CHANBAN_INVALID)
     return 0;
 
+  /* nick/ident section: return 0 (no match) if they don't match */
+
   /* Pick up the visible username.  If a sethost username is set, the real 
    * username is not checked. */
   ident=np->ident;
@@ -53,15 +55,24 @@ int nickmatchban(nick *np, chanban *bp, int visibleonly) {
 
   if (bp->flags & CHANBAN_HOSTANY)
     return 1;
+    
+  /* "visibleonly" means don't check IP/realhost if they are sethosted/+x. 
+   * We change this to mean "Don't check IP/realhost unconditionally" - by
+   * clearing it to 0 if the user isn't sethosted or +x.  Simplifies logic
+   * later.  */
+  
+  if (!(IsSetHost(np) || (IsAccount(np) && IsHideHost(np))))
+    visibleonly=0;
 
-  if ((bp->flags & CHANBAN_IP) && !(visibleonly && (IsSetHost(np) || (IsAccount(np) && IsHideHost(np))))) {
+  if ((bp->flags & CHANBAN_IP) && !visibleonly) {
     if (ipmask_check(&(np->ipnode->prefix->sin), &(bp->ipaddr), bp->prefixlen))
       return 1;
   }
   
   /* Hostname bans need to be checked against +x host, +h host (if set) 
    * and actual host.  Note that the +x host is only generated (and checked) if it's
-   * possible for the ban to match a hidden host.. */
+   * possible for the ban to match a hidden host.  And it's checked regardless
+   * of whether the user is actually +x. */
 
   if ((bp->flags & CHANBAN_HIDDENHOST) && IsAccount(np)) {
     sprintf(fakehost,"%s.%s",np->authname, HIS_HIDDENHOST);
@@ -87,7 +98,7 @@ int nickmatchban(nick *np, chanban *bp, int visibleonly) {
   
   /* If we are only checking visible host and the host is somehow masked, don't check
    * against the real one. */
-  if (visibleonly && (IsSetHost(np) || (IsAccount(np) && IsHideHost(np))))
+  if (visibleonly)
     return 0;
   
   if (bp->flags & CHANBAN_HOSTEXACT && !ircd_strcmp(np->host->name->content,bp->host->content))
index 1816a0376acbf455cea15c987a21dfdd08821a39..44f32a278a105cfb68edd88462ba789744828697 100644 (file)
@@ -132,15 +132,28 @@ int csa_doauthhistory(void *source, int cargc, char **cargv) {
     if (!(trup=findreguser(sender, cargv[arg])))
       return CMD_ERROR;
 
-    /* don't allow non-opers to view oper auth history, but allow helpers to view non-oper history */
-    if ((trup != rup) && ((UHasOperPriv(trup) && !UHasOperPriv(rup)) || !UHasHelperPriv(rup))) {
-      chanservstdmessage(sender, QM_NOACCESSONUSER, "authhistory", cargv[arg]);
-      return CMD_ERROR;
+    /* if target != command issuer */
+    if (trup != rup) {
+      /* only opers and helpers can view authhistory of other users */
+      if (!UHasHelperPriv(rup)) {
+        chanservstdmessage(sender, QM_NOACCESSONUSER, "authhistory", cargv[arg]);
+        return CMD_ERROR;
+      }
+
+      /* and only opers can view opers history */
+      if (UHasOperPriv(trup) && !UHasOperPriv(rup)) {
+        chanservwallmessage("%s (%s) just FAILED using AUTHHISTORY on %s", sender->nick, rup->username, trup->username);
+        chanservstdmessage(sender, QM_NOACCESSONUSER, "authhistory", cargv[arg]);
+        return CMD_ERROR;
+      }
+
+      /* checks passed */
+      chanservwallmessage("%s (%s) used AUTHHISTORY on %s", sender->nick, rup->username, trup->username);
     }
   } else {
     trup=rup;
   }
-  
+
   csdb_retreiveauthhistory(sender, trup, limit);
 
   return CMD_OK;
index 4a5a5a2cfcbf9e4e5bd63c56ff50a56c41dc65cd..e79914a837dfc74276b3b6afcbf0c268ff28cd3b 100644 (file)
@@ -11,12 +11,15 @@ DBModuleIdentifier authtrackerdb;
 void _init() {
   authtrackerdb = dbgetid();
 
+  chanservaddcommand("dumpauthtracker",QCMD_DEV,1,at_dumpdb,"Shows servers with dangling authtracker entries.\n","");
   at_finddanglingsessions();
 }
 
 void _fini() {
   at_hookfini();
   nsfreeall(POOL_AUTHTRACKER);
+  
+  chanservremovecommand("dumpauthtracker",at_dumpdb);
 
   dbfreeid(authtrackerdb);
 }
index 1e26d69fa3536b53d334d0473f828a309f3c6a6d..0947dccd948947ff8e48efe33b7c83c74eb1c2f5 100644 (file)
@@ -21,6 +21,7 @@ void at_lostnick(unsigned int numeric, unsigned long userid, time_t accountts, t
 int at_foundnick(unsigned int numeric, unsigned long userid, time_t accountts);
 void at_serverback(unsigned int server);
 void at_flushghosts();
+int at_dumpdb(void *source, int argc, char **argv);
 
 /* authtracker_hooks.c */
 unsigned long at_getuserid(nick *np);
index 127417f557a8bb1a007ef8587e76ae1423c50763..c6c760dde311fe49ae5bacc0b309879ee17ed972 100644 (file)
@@ -11,6 +11,7 @@
  */ 
 
 #include "authtracker.h"
+#include "../chanserv.h"
 #include "../../core/nsmalloc.h"
 #include "../../server/server.h"
 #include "../../irc/irc_config.h"
@@ -138,3 +139,25 @@ void at_flushghosts() {
       at_serverback(i);
   }
 }
+
+int at_dumpdb(void *source, int argc, char **argv) {
+  nick *np=source;
+  struct dangling_entry *dep;
+  unsigned int i,j,k;
+  
+  for(i=0;i<MAXSERVERS;i++) {
+    if (ds[i]) {
+      k=0;
+      for(j=0;j<DANGLING_HASHSIZE;j++) {
+        for (dep=ds[i]->de[j];dep;dep=dep->next) {
+          k++;
+        }
+      }
+      chanservsendmessage(np, "Server %d (%s) has %d entries.",i,longtonumeric(i,2),k);
+    }
+  }
+
+  chanservstdmessage(np,QM_ENDOFLIST);
+  
+  return CMD_OK;
+}
\ No newline at end of file
index 3b9f71982fc1365edd2362609f5ce6df6c6bf12c..69ee2eb0221e7066b27a31cf63e124733adf364e 100644 (file)
@@ -55,7 +55,7 @@ int csc_doinvite(void *source, int cargc, char **cargv) {
         continue;
       }
       
-      localinvite(chanservnick, rcup->chan->index->channel, sender);
+      localinvite(chanservnick, rcup->chan->index, sender);
     }
     
     chanservstdmessage(sender, QM_DONE);
@@ -67,7 +67,7 @@ int csc_doinvite(void *source, int cargc, char **cargv) {
     return CMD_ERROR;
 
   if (cip->channel) {
-    localinvite(chanservnick, cip->channel, sender);
+    localinvite(chanservnick, cip, sender);
   }
   chanservstdmessage(sender, QM_DONE);
  
index 8e6a2ef59e14f593267b40a665a03bbdd21dca75..7bbcd692cba9db674825e34a35c6591349837bbc 100644 (file)
@@ -787,7 +787,6 @@ void cs_doallautomodes(nick *np) {
           }
         }
 
-
        localsetmodeinit(&changes, rcup->chan->index->channel, chanservnick);
        if (*lp & CUMODE_OP) {
          if (!IsService(np) && (CUIsDeny(rcup) || (CIsBitch(rcup->chan) && !CUHasOpPriv(rcup))))
@@ -812,11 +811,16 @@ void cs_doallautomodes(nick *np) {
       } else {
        /* Channel exists but user is not joined: invite if they are +j-b */
        if (CUIsAutoInvite(rcup) && CUKnown(rcup) && !CUIsBanned(rcup)) {
-         localinvite(chanservnick, rcup->chan->index->channel, np);
+         localinvite(chanservnick, rcup->chan->index, np);
        }
       }
-    }
-  }
+    } /* if (rcup->chan->index->channel) */ else {
+      /* Channel doesn't currently exist - send invite anyway for +j */
+      if (CUIsAutoInvite(rcup) && CUKnown(rcup) && !CUIsBanned(rcup)) {
+        localinvite(chanservnick, rcup->chan->index, np);
+      }
+    } 
+  } /* for */
 }
 
 void cs_checknickbans(nick *np) {
index d29f93876f6cf46f134ea9d3827257be6a0f64fd..43e584be4bc88211fe88539b02dd20c6c69973e1 100644 (file)
@@ -267,6 +267,10 @@ int controlwhois(void *sender, int cargc, char **cargv) {
     }
   }
 
+  if (target->away) {
+    controlreply((nick *)sender, "Away      : %s",target->away->content);
+  }
+
   hooknick=(nick *)sender;
   registerhook(HOOK_CONTROL_WHOISREPLY,&handlewhois);
   triggerhook(HOOK_CONTROL_WHOISREQUEST,target);
index d625833942766e4d181507e1e1400f4ace75cbbe..c36af709104ba23bce6778598098b4c43e1dd634 100644 (file)
@@ -185,7 +185,7 @@ void helpmod_invite(hchannel *hchan, huser *husr)
     if (hchan->flags & H_PASSIVE)
         return;
 
-    localinvite(helpmodnick, hchan->real_channel, husr->real_user);
+    localinvite(helpmodnick, hchan->real_channel->index, husr->real_user);
 }
 
 static void hmode_set_channel(hchannel  *hchan)
index 4d8202d05b24436bdb9ee7f6af24fa8c79b3528d..4f7f254ba0a250ebd24cf7c11824287aef7a8337 100644 (file)
@@ -10,6 +10,7 @@
 #define TOPICLEN    250
 #define CHANNELLEN  200
 #define KEYLEN      23 
+#define AWAYLEN     160
 
 #define MAXSERVERS 4096
 
index c7db7cb1f90a66ac8dc3763ac5b74f320cd98912..dd11918b901a4eee813157d1a520c6a4bf193f8d 100644 (file)
@@ -114,6 +114,7 @@ nick *registerlocaluserflags(char *nickname, char *ident, char *host, char *real
   newuser->timestamp=getnettime();
   newuser->shident=NULL;
   newuser->sethost=NULL;
+  newuser->away=NULL;
   newuser->marker=0;
   memset(newuser->exts, 0, MAXNICKEXTS * sizeof(void *));
 
index 86f4ed11e2b388c1fca80f5bd2e30dd11169d988..67d0b1b629331d37790f7c073cd933a936481bed 100644 (file)
@@ -1066,7 +1066,7 @@ void sendopnoticetochannel(nick *source, channel *cp, char *format, ... ) {
   }
 }
 
-void localinvite(nick *source, channel *cp, nick *target) {
+void localinvite(nick *source, chanindex *cip, nick *target) {
 
   /* Servers can't send invites */
   if (!source) 
@@ -1078,7 +1078,7 @@ void localinvite(nick *source, channel *cp, nick *target) {
    * argument */
   if (connected) {
     irc_send("%s I %s :%s",longtonumeric(source->numeric,5),
-            target->nick, cp->index->name->content);
+            target->nick, cip->name->content);
   }
 }
   
index 5f450ee9975141d3c1a5081931478e7f365e9805..14d534373e1711a4981b35aeb553bf4d431084c7 100644 (file)
@@ -41,7 +41,7 @@ void localkickuser(nick *np, channel *cp, nick *target, const char *message);
 void localusermodechange(nick *np, channel *cp, char *modes);
 void sendmessagetochannel(nick *source, channel *cp, char *format, ... ) __attribute__ ((format (printf, 3, 4)));
 void sendopnoticetochannel(nick *source, channel *cp, char *format, ... ) __attribute__ ((format (printf, 3, 4)));
-void localinvite(nick *source, channel *cp, nick *target);
+void localinvite(nick *source, chanindex *cip, nick *target);
 
 void localsetmodeinit (modechanges *changes, channel *cp, nick *np);
 void localdosetmode_nick (modechanges *changes, nick *target, short modes);
index 84b6e960e14c33162338e6d3817108a8fca1ed8f..22b1b45756318ed301d40624748b1daf8b0b503b 100644 (file)
@@ -210,7 +210,7 @@ static int lua_invite(lua_State *ps) {
   if(!cp)
     LUA_RETURN(ps, LUA_FAIL);
 
-  localinvite(lua_nick, cp, np);
+  localinvite(lua_nick, cp->index, np);
 
   LUA_RETURN(ps, LUA_OK);
 }
index 2fdf3ff32b388a562af98eaa064cf2a071141f73..726323f076cf71c2fc0fa3603bec15081e735c7f 100644 (file)
@@ -6,7 +6,7 @@ LDFLAGS+=$(LIBPCRE)
 .PHONY: all clean distclean
 all: newsearch.so
 
-NSCOMMANDS=ns-not.o ns-and.o ns-or.o ns-eq.o ns-match.o ns-hostmask.o ns-realname.o ns-modes.o ns-nick.o ns-ident.o ns-regex.o ns-host.o ns-channel.o ns-lt.o ns-gt.o ns-timestamp.o ns-country.o ns-authname.o ns-ip.o ns-kill.o ns-gline.o ns-exists.o ns-services.o ns-size.o ns-name.o ns-topic.o ns-oppct.o ns-cumodecount.o ns-cumodepct.o ns-hostpct.o ns-authedpct.o ns-length.o ns-kick.o ns-authts.o ns-channels.o ns-server.o ns-authid.o ns-notice.o newsearch_ast.o ns-any.o ns-channeliter.o ns-var.o ns-all.o ns-cumodes.o ns-cidr.o ns-nickiter.o ns-ipv6.o
+NSCOMMANDS=ns-not.o ns-and.o ns-or.o ns-eq.o ns-match.o ns-hostmask.o ns-realname.o ns-away.o ns-modes.o ns-nick.o ns-ident.o ns-regex.o ns-host.o ns-channel.o ns-lt.o ns-gt.o ns-timestamp.o ns-country.o ns-authname.o ns-ip.o ns-kill.o ns-gline.o ns-exists.o ns-services.o ns-size.o ns-name.o ns-topic.o ns-oppct.o ns-cumodecount.o ns-cumodepct.o ns-hostpct.o ns-authedpct.o ns-length.o ns-kick.o ns-authts.o ns-channels.o ns-server.o ns-authid.o ns-notice.o newsearch_ast.o ns-any.o ns-channeliter.o ns-var.o ns-all.o ns-cumodes.o ns-cidr.o ns-nickiter.o ns-ipv6.o
 
 @ifeq@${NEWSEARCH_NEWPARSER}@ifeqsep@1@ifeqend@
 CFLAGS+=-DNEWSEARCH_NEWPARSER=1
index 100ddf94bd9dbaea7f2a874f5d9bed97571cdf31..d4531b4c12306f7561e761f324c3d6320c1d40a4 100644 (file)
@@ -178,6 +178,7 @@ void _init() {
   /* Nickname operations */
   registersearchterm(reg_nicksearch, "hostmask",hostmask_parse, 0, "The user's nick!user@host; \"hostmask real\" returns nick!user@host\rreal");     /* nick only */
   registersearchterm(reg_nicksearch, "realname",realname_parse, 0, "User's current realname");     /* nick only */
+  registersearchterm(reg_nicksearch, "away",away_parse, 0, "User's current away message");       /* nick only */
   registersearchterm(reg_nicksearch, "authname",authname_parse, 0, "User's current authname or false");     /* nick only */
   registersearchterm(reg_nicksearch, "authts",authts_parse, 0, "User's Auth timestamp");         /* nick only */
   registersearchterm(reg_nicksearch, "ident",ident_parse, 0, "User's current ident");           /* nick only */
index 9b4a26e90a542c38202f82eabda729649e43f854..727886a00fdebf70a128e739faa880022e3952d9 100644 (file)
@@ -126,6 +126,7 @@ struct searchNode *modes_parse(searchCtx *ctx, int argc, char **argv);
 /* Nick functions (various types) */
 struct searchNode *hostmask_parse(searchCtx *ctx, int argc, char **argv);
 struct searchNode *realname_parse(searchCtx *ctx, int argc, char **argv);
+struct searchNode *away_parse(searchCtx *ctx, int argc, char **argv);
 struct searchNode *authname_parse(searchCtx *ctx, int argc, char **argv);
 struct searchNode *authts_parse(searchCtx *ctx, int argc, char **argv);
 struct searchNode *ident_parse(searchCtx *ctx, int argc, char **argv);
diff --git a/newsearch/ns-away.c b/newsearch/ns-away.c
new file mode 100644 (file)
index 0000000..fb09e78
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * AWAY functionality 
+ */
+
+#include "newsearch.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+void *away_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void away_free(searchCtx *ctx, struct searchNode *thenode);
+
+struct searchNode *away_parse(searchCtx *ctx, int argc, char **argv) {
+  struct searchNode *thenode;
+
+  if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) {
+    parseError = "malloc: could not allocate memory for this search.";
+    return NULL;
+  }
+
+  thenode->returntype = RETURNTYPE_STRING;
+  thenode->localdata = NULL;
+  thenode->exe = away_exe;
+  thenode->free = away_free;
+
+  return thenode;
+}
+
+void *away_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
+  nick *np = (nick *)theinput;
+
+  return (np->away) ? np->away->content : "";
+}
+
+void away_free(searchCtx *ctx, struct searchNode *thenode) {
+  free(thenode);
+}
+
index c43a87e0294b75454edace7477b0d956544cafa6..3b9dead2bb69ae4e3cae2bd34edc4588792a2ac7 100644 (file)
@@ -91,6 +91,7 @@ void _init() {
   registerserverhandler("AC",&handleaccountmsg,4);
   registerserverhandler("R",&handlestatsmsg,2);
   registerserverhandler("P",&handleprivmsg,2);
+  registerserverhandler("A",&handleawaymsg,1);
   
   /* Fake the addition of our own server */
   handleserverchange(HOOK_SERVER_NEWSERVER,(void *)numerictolong(mynumeric->content,2));
@@ -128,6 +129,7 @@ void _fini() {
   deregisterserverhandler("AC",&handleaccountmsg);
   deregisterserverhandler("R",&handlestatsmsg);  
   deregisterserverhandler("P",&handleprivmsg);
+  deregisterserverhandler("A",&handleawaymsg);
 }
 
 /*
index 8fbe01e47279ce9902d2df3e97df06cb8d230c25..004aa4b1cdc6e8730b3521d35fc8c46a7b64533f 100644 (file)
@@ -140,6 +140,7 @@ typedef struct nick {
   authname *auth; /* This requires User ID numbers to work */
   time_t timestamp;
   time_t accountts;
+  sstring *away;
   patricia_node_t *ipnode;
   unsigned int marker;
   struct nick *next;
@@ -207,6 +208,7 @@ int handlewhoismsg(void *source, int cargc, char **cargv);
 int handleaccountmsg(void *source, int cargc, char **cargv);
 int handlestatsmsg(void *source, int cargc, char **cargv);
 int handleprivmsg(void *source, int cargc, char **cargv);
+int handleawaymsg(void *source, int cargc, char **cargv);
 
 /* These functions have been replaced by macros 
 nick **gethandlebynumeric(long numeric);
index 86c3590577d809dcb74637facfd6d660615430e8..282139f3070696df4583b82346e34c13b8a08265 100644 (file)
@@ -143,6 +143,7 @@ int handlenickmsg(void *source, int cargc, char **cargv) {
     np->ipnode = refnode(iptree, &ipaddress, PATRICIA_MAXBITS);
     node_increment_usercount(np->ipnode);
 
+    np->away=NULL;
     np->shident=NULL;
     np->sethost=NULL;
     np->opername=NULL;
@@ -527,3 +528,22 @@ int handleprivmsg(void *source, int cargc, char **cargv) {
   return CMD_OK;
 }
 
+int handleawaymsg(void *source, int cargc, char **cargv) {
+  nick *sender;
+    
+  /* Check source is a valid user */ 
+  if (!(sender=getnickbynumericstr(source))) {
+    return CMD_OK;
+  }
+
+  /* Done with the old away message either way */
+  freesstring(sender->away);
+  sender->away=NULL;
+  
+  /* If we have an arg and it isn't an empty string, this sets a new message */
+  if (cargc > 0 && *(cargv[0])) {
+    sender->away=getsstring(cargv[0], AWAYLEN);
+  }
+
+  return CMD_OK;
+}
index 57ebbfee148f253b8026aee006eb9540947f60b6..dc5522307cfd875d3eb462658bb40f1a77b9cd42 100644 (file)
@@ -4,6 +4,8 @@ CFLAGS+=$(INCDBAPI)
 LDFLAGS+=$(LIBDBAPI)
 
 .PHONY: all
-all: proxyscan.so  
+all: proxyscan.so proxyscan_newsearch.so
 
 proxyscan.so: proxyscan.o proxyscanext.o proxyscanalloc.o proxyscanconnect.o proxyscancache.o proxyscanqueue.o proxyscanhandlers.o proxyscandb.o
+
+proxyscan_newsearch.so: proxyscan_newsearch.o pns-scan.o
diff --git a/proxyscan/pns-scan.c b/proxyscan/pns-scan.c
new file mode 100644 (file)
index 0000000..52bf174
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * pscan functionality 
+ */
+
+#include "../newsearch/newsearch.h"
+#include "proxyscan.h"
+
+#include <stdlib.h>
+
+void *pscan_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput);
+void pscan_free(searchCtx *ctx, struct searchNode *thenode);
+
+struct searchNode *pscan_parse(searchCtx *ctx, int argc, char **argv) {
+  struct searchNode *thenode;
+
+  if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) {
+    parseError = "malloc: could not allocate memory for this search.";
+    return NULL;
+  }
+
+  thenode->returntype = RETURNTYPE_BOOL;
+  thenode->exe = pscan_exe;
+  thenode->free = pscan_free;
+  thenode->localdata = (void *)0;
+
+  return thenode;
+}
+
+void *pscan_exe(searchCtx *ctx, struct searchNode *thenode, void *theinput) {
+  startnickscan((nick *)theinput);
+  thenode->localdata = (void *)((int)thenode->localdata + 1);
+  return (void *)1;
+}
+
+void pscan_free(searchCtx *ctx, struct searchNode *thenode) {
+  ctx->reply(senderNSExtern, "proxyscan now scanning: %d nick(s).", (int)thenode->localdata);
+  free(thenode);
+}
+
index 648e97ac56e72dcbe95f48527943d759d97f3cbb..11e179841571e44b84aa77395af2674d5ad57651 100644 (file)
@@ -247,6 +247,7 @@ void _init(void) {
 
   /* Default scan types */
   proxyscan_addscantype(STYPE_HTTP, 8080);
+  proxyscan_addscantype(STYPE_HTTP, 8118);
   proxyscan_addscantype(STYPE_HTTP, 80);
   proxyscan_addscantype(STYPE_HTTP, 6588);
   proxyscan_addscantype(STYPE_HTTP, 8000);
@@ -502,6 +503,7 @@ void killsock(scan *sp, int outcome) {
   int i;
   cachehost *chp;
   foundproxy *fpp;
+  time_t now;
 
   scansdone++;
   scansbyclass[sp->class]++;
@@ -546,10 +548,13 @@ void killsock(scan *sp, int outcome) {
       fpp->next=chp->proxies;
       chp->proxies=fpp;
     }
-    
-    if (!chp->glineid) {
+
+    now=time(NULL);    
+    /* the purpose of this lastgline stuff is to stop gline spam from one scan */
+    if (!chp->glineid || (now>=chp->lastgline+SCANTIMEOUT)) {
+      chp->lastgline=now;
       glinedhosts++;
-      loggline(chp, sp->node);
+      loggline(chp, sp->node);   
       irc_send("%s GL * +*@%s 1800 %jd :Open Proxy, see http://www.quakenet.org/openproxies.html - ID: %d",
               mynumeric->content,IPtostr(((patricia_node_t *)sp->node)->prefix->sin),(intmax_t)getnettime(), chp->glineid);
       Error("proxyscan",ERR_DEBUG,"Found open proxy on host %s",IPtostr(((patricia_node_t *)sp->node)->prefix->sin));
@@ -943,6 +948,15 @@ int proxyscandoshowkill(void *sender, int cargc, char **cargv) {
   return CMD_OK;
 }
 
+void startnickscan(nick *np) {
+  time_t t = time(NULL);
+  int i;
+  for(i=0;i<numscans;i++) {
+    /* @@@TODO: we allow a forced scan to scan the same IP multiple times atm */
+    queuescan(np->ipnode,thescans[i].type,thescans[i].port,SCLASS_NORMAL,t);
+  }
+}
+
 int proxyscandoscan(void *sender, int cargc, char **cargv) {
   nick *np = (nick *)sender;
   patricia_node_t *node;
@@ -953,12 +967,14 @@ int proxyscandoscan(void *sender, int cargc, char **cargv) {
   if (0 == ipmask_parse(cargv[0],&sin, &bits)) {
     sendnoticetouser(proxyscannick,np,"Usage: scan <ip>");
   } else {
+    time_t t;
     sendnoticetouser(proxyscannick,np,"Forcing scan of %s",IPtostr(sin));
     // * Just queue the scans directly here.. plonk them on the priority queue * /
     node = refnode(iptree, &sin, bits); /* node leaks node here - should only allow to scan a nick? */
+    t = time(NULL);
     for(i=0;i<numscans;i++) {
       /* @@@TODO: we allow a forced scan to scan the same IP multiple times atm */
-      queuescan(node,thescans[i].type,thescans[i].port,SCLASS_NORMAL,time(NULL));
+      queuescan(node,thescans[i].type,thescans[i].port,SCLASS_NORMAL,t);
     }
   }
   return CMD_OK;
index 110ba302fcfec1152bb216d4bf82ed60ea2676a7..6f649c674e10e3fc4d09b341bcf0efffd45e8489 100644 (file)
@@ -70,6 +70,7 @@ typedef struct cachehost {
   time_t lastscan;
   foundproxy *proxies;
   int glineid;
+  time_t lastgline;
   unsigned char marker;
 #if defined(PROXYSCAN_MAIL)
   sstring *lasthostmask; /* Not saved to disk */
@@ -171,6 +172,7 @@ void startqueuedscans();
 
 /* proxyscan.c */
 void startscan(patricia_node_t *node, int type, int port, int class);
+void startnickscan(nick *nick);
 
 /* proxyscanext.c */
 unsigned int extrascancount();
diff --git a/proxyscan/proxyscan_newsearch.c b/proxyscan/proxyscan_newsearch.c
new file mode 100644 (file)
index 0000000..6d844c3
--- /dev/null
@@ -0,0 +1,11 @@
+#include "../newsearch/newsearch.h"
+
+struct searchNode *pscan_parse(searchCtx *ctx, int argc, char **argv);
+
+void _init() {
+  registersearchterm(reg_nicksearch, "pscan", pscan_parse, 0, "");
+}
+
+void _fini() {
+  deregistersearchterm(reg_nicksearch, "pscan", pscan_parse);
+}
index 93f0c637d2878e0e9f4b24c3d51e742eb62942d7..f14fbd2b5090e4d97145c5491a8dedf7ae50b46f 100644 (file)
@@ -24,6 +24,7 @@ cachehost *addcleanhost(time_t timestamp) {
   chp->lastscan=timestamp;
   chp->proxies=NULL;
   chp->glineid=0;
+  chp->lastgline=0;  
   
   return chp;
 }
@@ -92,7 +93,7 @@ void dumpcachehosts(void *arg) {
           } else
         
           for (fpp=chp->proxies;fpp;fpp=fpp->next) 
-            fprintf(fp, "%s %lu %u %i %u\n",IPtostr(node->prefix->sin),chp->lastscan,chp->glineid,fpp->type,fpp->port);
+            fprintf(fp, "%s %lu %u %i %u %lu\n",IPtostr(node->prefix->sin),chp->lastscan,chp->glineid,fpp->type,fpp->port,chp->lastgline);
         } else {
           if (chp->lastscan < (now-cleanscaninterval)) {
             /* Needs rescan anyway, so delete it */
@@ -118,7 +119,7 @@ void dumpcachehosts(void *arg) {
 
 void loadcachehosts() {
   FILE *fp;
-  unsigned long timestamp,glineid,ptype,pport;
+  unsigned long timestamp,glineid,ptype,pport,lastgline;
   char buf[512];
   cachehost *chp=NULL;
   foundproxy *fpp;
@@ -141,7 +142,7 @@ void loadcachehosts() {
       break;
     }
 
-    res=sscanf(buf,"%s %lu %lu %lu %lu",ip,&timestamp,&glineid,&ptype,&pport);
+    res=sscanf(buf,"%s %lu %lu %lu %lu %lu",ip,&timestamp,&glineid,&ptype,&pport,&lastgline);
 
     if (res<2)
       continue;
@@ -155,8 +156,9 @@ void loadcachehosts() {
         chp=addcleanhost(timestamp);
         node->exts[ps_cache_ext] = chp;
       
-        if (res==5) {
+        if (res==6) {
           chp->glineid=glineid;
+          chp->lastgline=lastgline;
           fpp=getfoundproxy();
           fpp->type=ptype;
           fpp->port=pport;
index 23b32e8fde8480d592a08bc8b05dc53b87000d03..012ce4ad478984024086fa3165577bd5c3f4b28e 100644 (file)
@@ -15,19 +15,26 @@ void proxyscan_newnick(int hooknum, void *arg) {
   if (irc_in_addr_is_loopback(&np->p_ipaddr) || !irc_in_addr_is_ipv4(&np->p_ipaddr)) 
     return;
 
-  /* before we look at a normal host, see if we think we have an open proxy */
-  if ((esp=findextrascan(np->ipnode))) {
-    Error("proxyextra", ERR_ERROR, "connection from possible proxy %s", IPtostr(np->p_ipaddr)); 
-    for (espp=esp;espp;espp=espp->nextbynode) { 
-      /* we force a scan on any hosts that may be an open proxy, even if they are:
-       * a) already in the queue, b) we've been running < 120 seconds */
-      queuescan(np->ipnode, espp->type, espp->port, SCLASS_NORMAL, time(NULL));
-    }
-  }
+  /* slug: why is this here? why isn't it with the other queuing stuff? */
+  /* we're given a list of ip/subnets and port pairs which someone else has
+     seen a proxy on in the past, so we scan these very aggressively
+     (even ignoring the cache)
+   */
+  /* disabled as the list is hopelessly out of date */
+//  if ((esp=findextrascan(np->ipnode))) {
+//    Error("proxyextra", ERR_ERROR, "connection from possible proxy %s", IPtostr(np->p_ipaddr)); 
+//    for (espp=esp;espp;espp=espp->nextbynode) { 
+//      /* we force a scan on any hosts that may be an open proxy, even if they are:
+//       * a) already in the queue, b) we've been running < 120 seconds */
+//      queuescan(np->ipnode, espp->type, espp->port, SCLASS_NORMAL, time(NULL));
+//    }
+//  }
 
-  /* ignore newnick until initial burst complete */
-  if (!ps_ready)
+/* slug: this BREAKS all of P's design assumptions, do NOT REENABLE THIS UNDER ANY CIRCUMSTANCES */
+/* ignore newnick until initial burst complete */
+/*  if (!ps_ready)
     return;
+*/
 
   /*
    * Logic for connecting hosts: