]> jfr.im git - irc/quakenet/newserv.git/blob - proxyscan/proxyscan.h
2b7441fa2298c12a2e9d087e6412b76e63510009
[irc/quakenet/newserv.git] / proxyscan / proxyscan.h
1
2 #ifndef __PROXYSCAN_H
3 #define __PROXYSCAN_H
4
5 #include "../nick/nick.h"
6 #include "../lib/splitline.h"
7 #include <time.h>
8
9 #define MAGICSTRING "NOTICE AUTH :*** Looking up your hostname\r\n"
10 #define MAGICSTRINGLENGTH 42
11
12 #define PSCAN_MAXSCANS 50
13 #define PSCAN_READBUFSIZE (MAGICSTRINGLENGTH * 2)
14
15 #define SSTATE_CONNECTING 0
16 #define SSTATE_SENTREQUEST 1
17 #define SSTATE_GOTRESPONSE 2
18
19 #define STYPE_SOCKS4 0
20 #define STYPE_SOCKS5 1
21 #define STYPE_HTTP 2
22 #define STYPE_WINGATE 3
23 #define STYPE_CISCO 4
24 #define STYPE_DIRECT 5
25
26 #define SOUTCOME_INPROGRESS 0
27 #define SOUTCOME_OPEN 1
28 #define SOUTCOME_CLOSED 2
29
30 #define SCLASS_NORMAL 0
31 #define SCLASS_CHECK 1
32 #define SCLASS_PASS2 2
33 #define SCLASS_PASS3 3
34 #define SCLASS_PASS4 4
35
36 typedef struct scantype {
37 int type;
38 int port;
39 int hits;
40 } scantype;
41
42 typedef struct extrascan {
43 unsigned short port;
44 unsigned char type;
45 struct extrascan *next;
46 struct extrascan *nextbynode;
47 } extrascan;
48
49 typedef struct pendingscan {
50 patricia_node_t *node;
51 unsigned short port;
52 unsigned char type;
53 unsigned char class;
54 time_t when;
55 struct pendingscan *next;
56 } pendingscan;
57
58 typedef struct foundproxy {
59 short type;
60 unsigned short port;
61 struct foundproxy *next;
62 } foundproxy;
63
64 typedef struct cachehost {
65 time_t lastscan;
66 foundproxy *proxies;
67 int glineid;
68 unsigned char marker;
69 #if defined(PROXYSCAN_MAIL)
70 sstring *lasthostmask; /* Not saved to disk */
71 time_t lastconnect; /* Not saved to disk */
72 #endif
73 struct cachehost *next;
74 } cachehost;
75
76 typedef struct scan {
77 int fd;
78 patricia_node_t *node;
79 short type;
80 unsigned short port;
81 unsigned short state;
82 unsigned short outcome;
83 unsigned short class;
84 struct scan *next;
85 void *sch;
86 char readbuf[PSCAN_READBUFSIZE];
87 int bytesread;
88 int totalbytesread;
89 } scan;
90
91 #if defined(PROXYSCAN_MAIL)
92 extern unsigned int ps_mailip;
93 extern unsigned int ps_mailport;
94 extern sstring *ps_mailname;
95 extern int psm_mailerfd;
96 #endif
97
98 extern int activescans;
99 extern int maxscans;
100 extern int numscans;
101 extern scantype thescans[];
102 extern int brokendb;
103 extern int ps_cache_ext;
104 extern int ps_scan_ext;
105 extern int ps_extscan_ext;
106 extern int ps_ready;
107 extern int rescaninterval;
108
109 extern unsigned int normalqueuedscans;
110 extern unsigned int prioqueuedscans;
111
112 extern unsigned int ps_start_ts;
113
114 extern unsigned long countpendingscan;
115
116 extern unsigned long scanspermin;
117
118 /* proxyscancache.c */
119 cachehost *addcleanhost(time_t timestamp);
120 cachehost *findcachehost(patricia_node_t *node);
121 void delcachehost(cachehost *);
122 void dumpcachehosts();
123 void loadcachehosts();
124 unsigned int cleancount();
125 unsigned int dirtycount();
126 void cachehostinit(time_t ri);
127 void scanall(int type, int port);
128
129 /* proxyscanalloc.c */
130 scan *getscan();
131 void freescan(scan *sp);
132 cachehost *getcachehost();
133 void freecachehost(cachehost *chp);
134 foundproxy *getfoundproxy();
135 void freefoundproxy(foundproxy *fpp);
136 pendingscan *getpendingscan();
137 void freependingscan(pendingscan *psp);
138 void sfreeall();
139 extrascan *getextrascan();
140 void freeextrascan(extrascan *esp);
141
142 /* proxyscanlisten.c */
143 int openlistensocket(int portnum);
144 void handlelistensocket(int fd, short events);
145
146 /* proxyscanconnect.c */
147 int createconnectsocket(long ip, int socknum);
148
149 /* proxyscandb.c */
150 void loggline(cachehost *chp, patricia_node_t *node);
151 void proxyscandbclose();
152 int proxyscandbinit();
153 int proxyscandolistopen(void *sender, int cargc, char **cargv);
154 void proxyscanspewip(nick *mynick, nick *usernick, unsigned long a, unsigned long b, unsigned long c, unsigned long d);
155 void proxyscanshowkill(nick *mynick, nick *usernick, unsigned long a);
156 const char *scantostr(int type);
157
158 #if defined(PROXYSCAN_MAIL)
159 /* proxyscanmail.c */
160 void ps_makereportmail(scanhost *shp);
161 #endif
162
163 /* proxyscanqueue.c */
164 void queuescan(patricia_node_t *node, short scantype, unsigned short port, char class, time_t when);
165 void startqueuedscans();
166
167 /* proxyscan.c */
168 void startscan(patricia_node_t *node, int type, int port, int class);
169
170 /* proxyscanext.c */
171 unsigned int extrascancount();
172 void loadextrascans();
173 extrascan *findextrascan(patricia_node_t *node);
174 void delextrascan(extrascan *esp);
175 extrascan *addextrascan(unsigned short port, unsigned char type);
176
177 #endif