]> jfr.im git - irc/quakenet/newserv.git/blame - proxyscan/proxyscanhandlers.c
Only allow staff/opers to see commands they have access to - iirc, used on Z for...
[irc/quakenet/newserv.git] / proxyscan / proxyscanhandlers.c
CommitLineData
905c2ba2 1#include "proxyscan.h"
2#include "../irc/irc.h"
3#include "../lib/irc_string.h"
4
5void proxyscan_newnick(int hooknum, void *arg) {
6 nick *np=(nick *)arg;
7 cachehost *chp;
8 foundproxy *fpp, *nfpp;
9 int i;
10
11 /* Skip 127.* and 0.* hosts */
12 if ((np->ipaddress>>24==0) || (np->ipaddress>>24==127))
13 return;
14
15 /*
16 * Logic for connecting hosts:
17 *
18 * If they're in the cache and clean, return.
19 * If they're in the cache, dirty, and last scanned < 30
20 * mins ago, return (they will probably go away in a minute)
21 * If they're in the cache and dirty:
22 * - gline them
23 * - trigger the "check" scans on the known proxies
24 * - trigger normal scans as for the case below..
25 *
26 * If they're not in the cache, we queue up their scans
27 */
28
29 if ((chp=findcachehost(np->ipaddress))) {
30 if (!chp->proxies)
31 return;
32
33 if (time(NULL) < (chp->lastscan + 1800))
34 return;
35
36 /* Queue up all the normal scans - on the normal queue */
37 for (i=0;i<numscans;i++) {
38 /* If this port is open DON'T queue the scan - we'll start it later in the CHECK class */
39 for (fpp=chp->proxies;fpp;fpp=fpp->next) {
40 if (fpp->type == thescans[i].type && fpp->port == thescans[i].port)
41 break;
42
43 if (!fpp)
44 queuescan(np->ipaddress, thescans[i].type, thescans[i].port, SCLASS_NORMAL, 0);
45 }
46 }
47
48 /* We want these scans to start around now, so we put them at the front of the priority queue */
49 for (fpp=chp->proxies;fpp;fpp=nfpp) {
50 nfpp=fpp->next;
51 queuescan(np->ipaddress, fpp->type, fpp->port, SCLASS_CHECK, time(NULL));
52 freefoundproxy(fpp);
53 }
54
55 /* set a SHORT gline - if they really have an open proxy the gline will be re-set, with a new ID */
56 irc_send("%s GL * +*@%s 600 :Open Proxy, see http://www.quakenet.org/openproxies.html - ID: %d",
57 mynumeric->content,IPtostr(np->ipaddress),chp->glineid);
58
59 chp->lastscan=time(NULL);
60 chp->proxies=NULL;
61 chp->glineid=0;
62 } else {
63 chp=addcleanhost(np->ipaddress, time(NULL));
64
65 /* Queue up all the normal scans - on the normal queue */
66 for (i=0;i<numscans;i++)
67 queuescan(np->ipaddress, thescans[i].type, thescans[i].port, SCLASS_NORMAL, 0);
68 }
69}
70