]>
jfr.im git - irc/quakenet/newserv.git/blob - proxyscan/proxyscanhandlers.c
2 #include "../irc/irc.h"
3 #include "../lib/irc_string.h"
4 #include "../core/error.h"
6 void proxyscan_newnick(int hooknum
, void *arg
) {
9 foundproxy
*fpp
, *nfpp
;
10 extrascan
*esp
, *espp
;
14 /* Skip 127.* and 0.* hosts */
15 if (irc_in_addr_is_loopback(&np
->p_ipaddr
) || !irc_in_addr_is_ipv4(&np
->p_ipaddr
))
18 /* before we look at a normal host, see if we think we have an open proxy */
19 if ((esp
=findextrascan(np
->ipnode
))) {
20 Error("proxyextra", ERR_ERROR
, "connection from possible proxy %s", IPtostr(np
->p_ipaddr
));
21 for (espp
=esp
;espp
;espp
=espp
->nextbynode
) {
22 queuescan(np
->ipnode
, espp
->type
, espp
->port
, SCLASS_NORMAL
, time(NULL
));
26 /* ignore newnick for first 120s */
27 if (ps_start_ts
+120 > time(NULL
))
31 * Logic for connecting hosts:
33 * If they're in the cache and clean, return.
34 * If they're in the cache, dirty, and last scanned < 30
35 * mins ago, return (they will probably go away in a minute)
36 * If they're in the cache and dirty:
38 * - trigger the "check" scans on the known proxies
39 * - trigger normal scans as for the case below..
41 * If they're not in the cache, we queue up their scans
44 if ((chp
=findcachehost(np
->ipnode
))) {
48 if (time(NULL
) < (chp
->lastscan
+ 1800))
51 /* Queue up all the normal scans - on the normal queue */
52 for (i
=0;i
<numscans
;i
++) {
53 /* If this port is open DON'T queue the scan - we'll start it later in the CHECK class */
54 for (fpp
=chp
->proxies
;fpp
;fpp
=fpp
->next
) {
55 if (fpp
->type
== thescans
[i
].type
&& fpp
->port
== thescans
[i
].port
)
59 queuescan(np
->ipnode
, thescans
[i
].type
, thescans
[i
].port
, SCLASS_NORMAL
, 0);
63 /* We want these scans to start around now, so we put them at the front of the priority queue */
64 for (fpp
=chp
->proxies
;fpp
;fpp
=nfpp
) {
66 queuescan(np
->ipnode
, fpp
->type
, fpp
->port
, SCLASS_CHECK
, time(NULL
));
70 /* set a SHORT gline - if they really have an open proxy the gline will be re-set, with a new ID */
71 irc_send("%s GL * +*@%s 600 :Open Proxy, see http://www.quakenet.org/openproxies.html - ID: %d",
72 mynumeric
->content
,IPtostr(np
->p_ipaddr
),chp
->glineid
);
74 chp
->lastscan
=time(NULL
);
78 chp
=addcleanhost(time(NULL
));
79 np
->ipnode
->exts
[ps_cache_ext
] = chp
;
80 patricia_ref_prefix(np
->ipnode
->prefix
);
82 /* Queue up all the normal scans - on the normal queue */
83 for (i
=0;i
<numscans
;i
++)
84 queuescan(np
->ipnode
, thescans
[i
].type
, thescans
[i
].port
, SCLASS_NORMAL
, 0);