chp->lastscan=timestamp;
chp->proxies=NULL;
chp->glineid=0;
+ chp->lastgline=0;
return chp;
}
foundproxy *fpp;
patricia_node_t *node;
- if ((fp=fopen("cleanhosts","w"))==NULL) {
+ if ((fp=fopen("data/cleanhosts","w"))==NULL) {
Error("proxyscan",ERR_ERROR,"Unable to open cleanhosts file for writing!");
return;
}
- PATRICIA_WALK (iptree->head, node) {
+ PATRICIA_WALK_CLEAR (iptree->head, node) {
if (node->exts[ps_cache_ext] ) {
chp = (cachehost *) node->exts[ps_cache_ext];
if (chp) {
if (chp->proxies) {
if (chp->lastscan < (now-dirtyscaninterval)) {
- //derefnode(iptree,node);
- //delcachehost(chp);
- //node->exts[ps_cache_ext] = NULL;
- //continue;
+ derefnode(iptree,node);
+ delcachehost(chp);
+ node->exts[ps_cache_ext] = NULL;
} 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 */
- //derefnode(iptree,node);
- //delcachehost(chp);
- //node->exts[ps_cache_ext] = NULL;
- //continue;
+ derefnode(iptree,node);
+ delcachehost(chp);
+ node->exts[ps_cache_ext] = NULL;
} else
fprintf(fp,"%s %lu\n",IPtostr(node->prefix->sin),chp->lastscan);
}
}
}
- } PATRICIA_WALK_END;
-
+ } PATRICIA_WALK_CLEAR_END;
+
+// patricia_tidy_tree(iptree);
fclose(fp);
}
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;
struct irc_in_addr sin;
unsigned char bits;
patricia_node_t *node;
+ int i=0;
- if ((fp=fopen("cleanhosts","r"))==NULL) {
+ if ((fp=fopen("data/cleanhosts","r"))==NULL) {
Error("proxyscan",ERR_ERROR,"Unable to open cleanhosts file for reading!");
return;
}
break;
}
- res=sscanf(buf,"%s %lu %lu %lu %lu",ip,×tamp,&glineid,&ptype,&pport);
+ res=sscanf(buf,"%s %lu %lu %lu %lu %lu",ip,×tamp,&glineid,&ptype,&pport,&lastgline);
if (res<2)
continue;
} else {
node = refnode(iptree, &sin, bits);
if( node ) {
+ i++;
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;
}
}
}
-
+
+ Error("proxyscan",ERR_INFO, "Loaded %d entries from cache", i);
}
/*