]>
Commit | Line | Data |
---|---|---|
905c2ba2 | 1 | #include "proxyscan.h" |
2 | #include "../irc/irc.h" | |
3 | #include "../lib/irc_string.h" | |
557c8cb2 | 4 | #include "../core/error.h" |
905c2ba2 | 5 | |
6 | void proxyscan_newnick(int hooknum, void *arg) { | |
7 | nick *np=(nick *)arg; | |
8 | cachehost *chp; | |
9 | foundproxy *fpp, *nfpp; | |
557c8cb2 P |
10 | extrascan *esp, *espp; |
11 | ||
905c2ba2 | 12 | int i; |
13 | ||
14 | /* Skip 127.* and 0.* hosts */ | |
c9db668b | 15 | if (irc_in_addr_is_loopback(&np->p_ipaddr) || !irc_in_addr_is_ipv4(&np->p_ipaddr)) |
905c2ba2 | 16 | return; |
17 | ||
d410047e | 18 | /* slug: why is this here? why isn't it with the other queuing stuff? */ |
557c8cb2 P |
19 | /* before we look at a normal host, see if we think we have an open proxy */ |
20 | if ((esp=findextrascan(np->ipnode))) { | |
21 | Error("proxyextra", ERR_ERROR, "connection from possible proxy %s", IPtostr(np->p_ipaddr)); | |
22 | for (espp=esp;espp;espp=espp->nextbynode) { | |
7ab80d0c P |
23 | /* we force a scan on any hosts that may be an open proxy, even if they are: |
24 | * a) already in the queue, b) we've been running < 120 seconds */ | |
557c8cb2 P |
25 | queuescan(np->ipnode, espp->type, espp->port, SCLASS_NORMAL, time(NULL)); |
26 | } | |
27 | } | |
bc78ddf6 | 28 | |
d410047e CP |
29 | /* slug: this BREAKS all of P's design assumptions, do NOT REENABLE THIS UNDER ANY CIRCUMSTANCES */ |
30 | /* ignore newnick until initial burst complete */ | |
31 | /* if (!ps_ready) | |
bc78ddf6 | 32 | return; |
d410047e | 33 | */ |
bc78ddf6 | 34 | |
905c2ba2 | 35 | /* |
36 | * Logic for connecting hosts: | |
37 | * | |
38 | * If they're in the cache and clean, return. | |
39 | * If they're in the cache, dirty, and last scanned < 30 | |
40 | * mins ago, return (they will probably go away in a minute) | |
41 | * If they're in the cache and dirty: | |
42 | * - gline them | |
43 | * - trigger the "check" scans on the known proxies | |
44 | * - trigger normal scans as for the case below.. | |
45 | * | |
46 | * If they're not in the cache, we queue up their scans | |
47 | */ | |
557c8cb2 | 48 | if ((chp=findcachehost(np->ipnode))) { |
905c2ba2 | 49 | if (!chp->proxies) |
50 | return; | |
51 | ||
52 | if (time(NULL) < (chp->lastscan + 1800)) | |
53 | return; | |
54 | ||
55 | /* Queue up all the normal scans - on the normal queue */ | |
56 | for (i=0;i<numscans;i++) { | |
57 | /* If this port is open DON'T queue the scan - we'll start it later in the CHECK class */ | |
58 | for (fpp=chp->proxies;fpp;fpp=fpp->next) { | |
59 | if (fpp->type == thescans[i].type && fpp->port == thescans[i].port) | |
60 | break; | |
61 | ||
62 | if (!fpp) | |
557c8cb2 | 63 | queuescan(np->ipnode, thescans[i].type, thescans[i].port, SCLASS_NORMAL, 0); |
905c2ba2 | 64 | } |
65 | } | |
66 | ||
67 | /* We want these scans to start around now, so we put them at the front of the priority queue */ | |
68 | for (fpp=chp->proxies;fpp;fpp=nfpp) { | |
69 | nfpp=fpp->next; | |
557c8cb2 | 70 | queuescan(np->ipnode, fpp->type, fpp->port, SCLASS_CHECK, time(NULL)); |
905c2ba2 | 71 | freefoundproxy(fpp); |
72 | } | |
73 | ||
74 | /* set a SHORT gline - if they really have an open proxy the gline will be re-set, with a new ID */ | |
68e41288 P |
75 | irc_send("%s GL * +*@%s 600 %jd :Open Proxy, see http://www.quakenet.org/openproxies.html - ID: %d", |
76 | mynumeric->content,IPtostr(np->p_ipaddr),(intmax_t)getnettime(), chp->glineid); | |
905c2ba2 | 77 | |
78 | chp->lastscan=time(NULL); | |
79 | chp->proxies=NULL; | |
80 | chp->glineid=0; | |
81 | } else { | |
557c8cb2 | 82 | chp=addcleanhost(time(NULL)); |
a8ba1373 | 83 | np->ipnode->exts[ps_cache_ext] = chp; |
557c8cb2 | 84 | patricia_ref_prefix(np->ipnode->prefix); |
905c2ba2 | 85 | |
86 | /* Queue up all the normal scans - on the normal queue */ | |
87 | for (i=0;i<numscans;i++) | |
557c8cb2 | 88 | queuescan(np->ipnode, thescans[i].type, thescans[i].port, SCLASS_NORMAL, 0); |
905c2ba2 | 89 | } |
90 | } |