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