X-Git-Url: https://jfr.im/git/irc/quakenet/newserv.git/blobdiff_plain/7839f73a60770f2e3d8bc97ff1c3d709985a7203..cb5aa4cdd6af4114b18db464f022ef99a44304d7:/proxyscan/proxyscanhandlers.c diff --git a/proxyscan/proxyscanhandlers.c b/proxyscan/proxyscanhandlers.c index 92e28171..c1c70b45 100644 --- a/proxyscan/proxyscanhandlers.c +++ b/proxyscan/proxyscanhandlers.c @@ -1,24 +1,32 @@ #include "proxyscan.h" #include "../irc/irc.h" #include "../lib/irc_string.h" +#include "../core/error.h" void proxyscan_newnick(int hooknum, void *arg) { nick *np=(nick *)arg; cachehost *chp; foundproxy *fpp, *nfpp; + extrascan *esp, *espp; + int i; /* Skip 127.* and 0.* hosts */ 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) { + queuescan(np->ipnode, espp->type, espp->port, SCLASS_NORMAL, time(NULL)); + } + } /* ignore newnick for first 120s */ if (ps_start_ts+120 > time(NULL)) return; - unsigned int ip = irc_in_addr_v4_to_int(&np->p_ipaddr); - /* * Logic for connecting hosts: * @@ -33,7 +41,7 @@ void proxyscan_newnick(int hooknum, void *arg) { * If they're not in the cache, we queue up their scans */ - if ((chp=findcachehost(ip))) { + if ((chp=findcachehost(np->ipnode))) { if (!chp->proxies) return; @@ -48,14 +56,14 @@ void proxyscan_newnick(int hooknum, void *arg) { break; if (!fpp) - queuescan(ip, thescans[i].type, thescans[i].port, SCLASS_NORMAL, 0); + queuescan(np->ipnode, thescans[i].type, thescans[i].port, SCLASS_NORMAL, 0); } } /* We want these scans to start around now, so we put them at the front of the priority queue */ for (fpp=chp->proxies;fpp;fpp=nfpp) { nfpp=fpp->next; - queuescan(ip, fpp->type, fpp->port, SCLASS_CHECK, time(NULL)); + queuescan(np->ipnode, fpp->type, fpp->port, SCLASS_CHECK, time(NULL)); freefoundproxy(fpp); } @@ -67,11 +75,13 @@ void proxyscan_newnick(int hooknum, void *arg) { chp->proxies=NULL; chp->glineid=0; } else { - chp=addcleanhost(ip, time(NULL)); + chp=addcleanhost(time(NULL)); + np->ipnode->exts[ps_cache_ext] = chp; + patricia_ref_prefix(np->ipnode->prefix); /* Queue up all the normal scans - on the normal queue */ for (i=0;iipnode, thescans[i].type, thescans[i].port, SCLASS_NORMAL, 0); } }