]>
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? */ |
c1136881 CP |
19 | /* we're given a list of ip/subnets and port pairs which someone else has |
20 | seen a proxy on in the past, so we scan these very aggressively | |
21 | (even ignoring the cache) | |
22 | */ | |
23 | /* disabled as the list is hopelessly out of date */ | |
24 | // if ((esp=findextrascan(np->ipnode))) { | |
25 | // Error("proxyextra", ERR_ERROR, "connection from possible proxy %s", IPtostr(np->p_ipaddr)); | |
26 | // for (espp=esp;espp;espp=espp->nextbynode) { | |
27 | // /* we force a scan on any hosts that may be an open proxy, even if they are: | |
28 | // * a) already in the queue, b) we've been running < 120 seconds */ | |
29 | // queuescan(np->ipnode, espp->type, espp->port, SCLASS_NORMAL, time(NULL)); | |
30 | // } | |
31 | // } | |
bc78ddf6 | 32 | |
d410047e CP |
33 | /* slug: this BREAKS all of P's design assumptions, do NOT REENABLE THIS UNDER ANY CIRCUMSTANCES */ |
34 | /* ignore newnick until initial burst complete */ | |
35 | /* if (!ps_ready) | |
bc78ddf6 | 36 | return; |
d410047e | 37 | */ |
bc78ddf6 | 38 | |
905c2ba2 | 39 | /* |
40 | * Logic for connecting hosts: | |
41 | * | |
42 | * If they're in the cache and clean, return. | |
43 | * If they're in the cache, dirty, and last scanned < 30 | |
44 | * mins ago, return (they will probably go away in a minute) | |
45 | * If they're in the cache and dirty: | |
46 | * - gline them | |
47 | * - trigger the "check" scans on the known proxies | |
48 | * - trigger normal scans as for the case below.. | |
49 | * | |
50 | * If they're not in the cache, we queue up their scans | |
51 | */ | |
557c8cb2 | 52 | if ((chp=findcachehost(np->ipnode))) { |
905c2ba2 | 53 | if (!chp->proxies) |
54 | return; | |
55 | ||
56 | if (time(NULL) < (chp->lastscan + 1800)) | |
57 | return; | |
58 | ||
59 | /* Queue up all the normal scans - on the normal queue */ | |
60 | for (i=0;i<numscans;i++) { | |
61 | /* If this port is open DON'T queue the scan - we'll start it later in the CHECK class */ | |
62 | for (fpp=chp->proxies;fpp;fpp=fpp->next) { | |
63 | if (fpp->type == thescans[i].type && fpp->port == thescans[i].port) | |
64 | break; | |
65 | ||
66 | if (!fpp) | |
557c8cb2 | 67 | queuescan(np->ipnode, thescans[i].type, thescans[i].port, SCLASS_NORMAL, 0); |
905c2ba2 | 68 | } |
69 | } | |
70 | ||
71 | /* We want these scans to start around now, so we put them at the front of the priority queue */ | |
72 | for (fpp=chp->proxies;fpp;fpp=nfpp) { | |
73 | nfpp=fpp->next; | |
557c8cb2 | 74 | queuescan(np->ipnode, fpp->type, fpp->port, SCLASS_CHECK, time(NULL)); |
905c2ba2 | 75 | freefoundproxy(fpp); |
76 | } | |
77 | ||
78 | /* set a SHORT gline - if they really have an open proxy the gline will be re-set, with a new ID */ | |
68e41288 P |
79 | irc_send("%s GL * +*@%s 600 %jd :Open Proxy, see http://www.quakenet.org/openproxies.html - ID: %d", |
80 | mynumeric->content,IPtostr(np->p_ipaddr),(intmax_t)getnettime(), chp->glineid); | |
905c2ba2 | 81 | |
82 | chp->lastscan=time(NULL); | |
83 | chp->proxies=NULL; | |
84 | chp->glineid=0; | |
85 | } else { | |
557c8cb2 | 86 | chp=addcleanhost(time(NULL)); |
a8ba1373 | 87 | np->ipnode->exts[ps_cache_ext] = chp; |
557c8cb2 | 88 | patricia_ref_prefix(np->ipnode->prefix); |
905c2ba2 | 89 | |
90 | /* Queue up all the normal scans - on the normal queue */ | |
91 | for (i=0;i<numscans;i++) | |
557c8cb2 | 92 | queuescan(np->ipnode, thescans[i].type, thescans[i].port, SCLASS_NORMAL, 0); |
905c2ba2 | 93 | } |
94 | } |