/*
* Trojanscan version 2
*
- * Trojanscan copyright (C) Chris Porter 2002-2007
+ * Trojanscan copyright (C) Chris Porter 2002-2009
* Newserv bits copyright (C) David Mansell 2002-2003
*
* TODO: CHECK::
#include "../lib/strlfunc.h"
#include "../lib/version.h"
#include "../core/nsmalloc.h"
+#include <stdint.h>
#define tmalloc(x) nsmalloc(POOL_TROJANSCAN, x)
#define tfree(x) nsfree(POOL_TROJANSCAN, x)
trojanscan_database.glines = 0;
trojanscan_database.detections = 0;
- dbhost = getcopyconfigitem("trojanscan", "dbhost", "localhost", HOSTLEN);
- dbuser = getcopyconfigitem("trojanscan", "dbuser", "", NICKLEN);
- dbpass = getcopyconfigitem("trojanscan", "dbpass", "", REALLEN);
- db = getcopyconfigitem("trojanscan", "db", "", NICKLEN);
+ dbhost = getcopyconfigitem("trojanscan", "dbhost", "localhost", 100);
+ dbuser = getcopyconfigitem("trojanscan", "dbuser", "moo", 100);
+ dbpass = getcopyconfigitem("trojanscan", "dbpass", "changeme", 100);
+ db = getcopyconfigitem("trojanscan", "db", "moo", 100);
- dbport = getcopyconfigitem("trojanscan", "dbport", "3306", ACCOUNTLEN);
+ dbport = getcopyconfigitem("trojanscan", "dbport", "3306", 10);
length = snprintf(buf, sizeof(buf) - 1, "%d", TROJANSCAN_DEFAULT_MAXCHANS);
temp = getcopyconfigitem("trojanscan", "maxchans", buf, length);
nick *np = NULL; /* sigh at warnings */
if(hostmode)
- for (j=0;j<NICKHASHSIZE;j++)
- for (np=nicktable[j];np;np=np->next)
- if (np->ipnode==sender->ipnode)
- usercount++;
+ usercount = sender->ipnode->usercount;
if(usercount > TROJANSCAN_MAX_HOST_GLINE) {
hostmode = 0;
usercount = 0;
}
+ /* should really go through the ipnode I guess */
if(!hostmode)
for (j=0;j<NICKHASHSIZE;j++)
for (np=nicktable[j];np;np=np->next)
return NULL;
}
+static int specialuseronhost(host *hp) {
+ nick *np;
+
+ for(np=hp->nicks;np;np=np->nextbyhost)
+ if(IsOper(np) || IsService(np) || IsXOper(np) || NickOnServiceServer(np))
+ return 1;
+
+ return 0;
+}
+
void trojanscan_generatehost(char *buf, int maxsize, patricia_node_t **fakeip) {
struct irc_in_addr ipaddress;
do {
hp = trojanscan_selecthost();
- if(hp && (hp->clonecount <= TROJANSCAN_MAX_CLONE_COUNT) && !trojanscan_isip(hp->name->content)) {
+ if(hp && (hp->clonecount <= TROJANSCAN_MAX_CLONE_COUNT) && !trojanscan_isip(hp->name->content) && !specialuseronhost(hp)) {
strlcpy(buf, hp->name->content, maxsize + 1);
if(hp->nicks) {
*fakeip = hp->nicks->ipnode;