]>
jfr.im git - irc/quakenet/newserv.git/blob - proxyscan/proxyscanhandlers.c
3 #include "../irc/irc.h"
4 #include "../lib/irc_string.h"
5 #include "../core/error.h"
6 #include "../glines/glines.h"
8 void proxyscan_newnick(int hooknum
, void *arg
) {
11 foundproxy
*fpp
, *nfpp
;
12 extrascan
*esp
, *espp
;
17 /* Skip 127.* and 0.* hosts */
18 if (irc_in_addr_is_loopback(&np
->p_ipaddr
))
21 /* slug: why is this here? why isn't it with the other queuing stuff? */
22 /* we're given a list of ip/subnets and port pairs which someone else has
23 seen a proxy on in the past, so we scan these very aggressively
24 (even ignoring the cache)
26 /* disabled as the list is hopelessly out of date */
27 if ((esp
=findextrascan(np
->ipnode
))) {
28 Error("proxyextra", ERR_ERROR
, "connection from possible proxy %s", IPtostr(np
->p_ipaddr
));
29 for (espp
=esp
;espp
;espp
=espp
->nextbynode
) {
30 /* we force a scan on any hosts that may be an open proxy, even if they are:
31 * a) already in the queue, b) we've been running < 120 seconds */
32 queuescan(np
->ipnode
, espp
->type
, espp
->port
, SCLASS_NORMAL
, time(NULL
));
36 /* slug: this BREAKS all of P's design assumptions, do NOT REENABLE THIS UNDER ANY CIRCUMSTANCES */
37 /* ignore newnick until initial burst complete */
43 * Logic for connecting hosts:
45 * If they're in the cache and clean, return.
46 * If they're in the cache, dirty, and last scanned < 30
47 * mins ago, return (they will probably go away in a minute)
48 * If they're in the cache and dirty:
50 * - trigger the "check" scans on the known proxies
51 * - trigger normal scans as for the case below..
53 * If they're not in the cache, we queue up their scans
55 if ((chp
=findcachehost(np
->ipnode
))) {
59 if (time(NULL
) < (chp
->lastscan
+ 1800))
62 /* Queue up all the normal scans - on the normal queue */
63 for (i
=0;i
<numscans
;i
++) {
64 /* If this port is open DON'T queue the scan - we'll start it later in the CHECK class */
65 for (fpp
=chp
->proxies
;fpp
;fpp
=fpp
->next
) {
66 if (fpp
->type
== thescans
[i
].type
&& fpp
->port
== thescans
[i
].port
)
70 queuescan(np
->ipnode
, thescans
[i
].type
, thescans
[i
].port
, SCLASS_NORMAL
, 0);
74 /* We want these scans to start around now, so we put them at the front of the priority queue */
75 for (fpp
=chp
->proxies
;fpp
;fpp
=nfpp
) {
77 queuescan(np
->ipnode
, fpp
->type
, fpp
->port
, SCLASS_CHECK
, time(NULL
));
81 /* set a SHORT gline - if they really have an open proxy the gline will be re-set, with a new ID */
82 snprintf(reason
, sizeof(reason
), "Open Proxy, see http://www.quakenet.org/openproxies.html - ID: %d", chp
->glineid
);
83 glinebynick(np
, 600, reason
, GLINE_IGNORE_TRUST
, "proxyscan");
85 chp
->lastscan
=time(NULL
);
89 chp
=addcleanhost(time(NULL
));
90 np
->ipnode
->exts
[ps_cache_ext
] = chp
;
91 patricia_ref_prefix(np
->ipnode
->prefix
);
93 /* Queue up all the normal scans - on the normal queue */
94 for (i
=0;i
<numscans
;i
++)
95 queuescan(np
->ipnode
, thescans
[i
].type
, thescans
[i
].port
, SCLASS_NORMAL
, 0);