]>
jfr.im git - irc/quakenet/newserv.git/blob - proxyscan/proxyscanhandlers.c
2 #include "../irc/irc.h"
3 #include "../lib/irc_string.h"
5 void proxyscan_newnick(int hooknum
, void *arg
) {
8 foundproxy
*fpp
, *nfpp
;
11 /* Skip 127.* and 0.* hosts */
12 if (irc_in_addr_is_loopback(&np
->p_ipaddr
) || !irc_in_addr_is_ipv4(&np
->p_ipaddr
))
15 unsigned int ip
= irc_in_addr_v4_to_int(&np
->p_ipaddr
);
18 * Logic for connecting hosts:
20 * If they're in the cache and clean, return.
21 * If they're in the cache, dirty, and last scanned < 30
22 * mins ago, return (they will probably go away in a minute)
23 * If they're in the cache and dirty:
25 * - trigger the "check" scans on the known proxies
26 * - trigger normal scans as for the case below..
28 * If they're not in the cache, we queue up their scans
31 if ((chp
=findcachehost(ip
))) {
35 if (time(NULL
) < (chp
->lastscan
+ 1800))
38 /* Queue up all the normal scans - on the normal queue */
39 for (i
=0;i
<numscans
;i
++) {
40 /* If this port is open DON'T queue the scan - we'll start it later in the CHECK class */
41 for (fpp
=chp
->proxies
;fpp
;fpp
=fpp
->next
) {
42 if (fpp
->type
== thescans
[i
].type
&& fpp
->port
== thescans
[i
].port
)
46 queuescan(ip
, thescans
[i
].type
, thescans
[i
].port
, SCLASS_NORMAL
, 0);
50 /* We want these scans to start around now, so we put them at the front of the priority queue */
51 for (fpp
=chp
->proxies
;fpp
;fpp
=nfpp
) {
53 queuescan(ip
, fpp
->type
, fpp
->port
, SCLASS_CHECK
, time(NULL
));
57 /* set a SHORT gline - if they really have an open proxy the gline will be re-set, with a new ID */
58 irc_send("%s GL * +*@%s 600 :Open Proxy, see http://www.quakenet.org/openproxies.html - ID: %d",
59 mynumeric
->content
,IPtostr(np
->p_ipaddr
),chp
->glineid
);
61 chp
->lastscan
=time(NULL
);
65 chp
=addcleanhost(ip
, time(NULL
));
67 /* Queue up all the normal scans - on the normal queue */
68 for (i
=0;i
<numscans
;i
++)
69 queuescan(ip
, thescans
[i
].type
, thescans
[i
].port
, SCLASS_NORMAL
, 0);