]>
Commit | Line | Data |
---|---|---|
c86edd1d Q |
1 | |
2 | #ifndef __PROXYSCAN_H | |
3 | #define __PROXYSCAN_H | |
4 | ||
5 | #include "../nick/nick.h" | |
7ab80d0c | 6 | #include "../lib/splitline.h" |
c86edd1d | 7 | #include <time.h> |
c7be40f8 | 8 | #include <stdint.h> |
c86edd1d | 9 | |
0a7647a3 P |
10 | #define MAGICSTRING "NOTICE AUTH :*** Looking up your hostname\r\n" |
11 | #define MAGICSTRINGLENGTH 42 | |
c86edd1d | 12 | |
c7be40f8 CP |
13 | #define MAGICIRCSTRING ".quakenet.org 451 * :Register first.\r\n" |
14 | #define MAGICIRCSTRINGLENGTH 38 | |
15 | ||
e95140be CP |
16 | #define MAGICROUTERSTRING "\r\nServer: Mikrotik HttpProxy\r\n" |
17 | #define MAGICROUTERSTRINGLENGTH 30 | |
18 | ||
6e5951ae | 19 | #define PSCAN_MAXSCANS 100 |
0a7647a3 | 20 | #define PSCAN_READBUFSIZE (MAGICSTRINGLENGTH * 2) |
c86edd1d Q |
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 | |
c7be40f8 CP |
31 | #define STYPE_DIRECT 5 /* not sure what this is so I'm leaving it alone */ |
32 | #define STYPE_DIRECT_IRC 6 | |
e95140be | 33 | #define STYPE_ROUTER 7 |
c86edd1d Q |
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 | ||
557c8cb2 P |
51 | typedef struct extrascan { |
52 | unsigned short port; | |
53 | unsigned char type; | |
54 | struct extrascan *next; | |
55 | struct extrascan *nextbynode; | |
56 | } extrascan; | |
57 | ||
c86edd1d | 58 | typedef struct pendingscan { |
557c8cb2 | 59 | patricia_node_t *node; |
c86edd1d Q |
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 { | |
c86edd1d Q |
74 | time_t lastscan; |
75 | foundproxy *proxies; | |
76 | int glineid; | |
bef1f120 | 77 | time_t lastgline; |
c86edd1d Q |
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 | |
557c8cb2 | 83 | struct cachehost *next; |
c86edd1d Q |
84 | } cachehost; |
85 | ||
86 | typedef struct scan { | |
87 | int fd; | |
557c8cb2 | 88 | patricia_node_t *node; |
c86edd1d Q |
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; | |
557c8cb2 P |
113 | extern int ps_cache_ext; |
114 | extern int ps_scan_ext; | |
115 | extern int ps_extscan_ext; | |
7ab80d0c P |
116 | extern int ps_ready; |
117 | extern int rescaninterval; | |
c86edd1d Q |
118 | |
119 | extern unsigned int normalqueuedscans; | |
120 | extern unsigned int prioqueuedscans; | |
121 | ||
761a4596 P |
122 | extern unsigned int ps_start_ts; |
123 | ||
92f1d9e3 D |
124 | extern unsigned long countpendingscan; |
125 | ||
126 | extern unsigned long scanspermin; | |
127 | ||
c86edd1d | 128 | /* proxyscancache.c */ |
557c8cb2 P |
129 | cachehost *addcleanhost(time_t timestamp); |
130 | cachehost *findcachehost(patricia_node_t *node); | |
c86edd1d Q |
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(); | |
557c8cb2 P |
149 | extrascan *getextrascan(); |
150 | void freeextrascan(extrascan *esp); | |
c86edd1d Q |
151 | |
152 | /* proxyscanlisten.c */ | |
153 | int openlistensocket(int portnum); | |
154 | void handlelistensocket(int fd, short events); | |
155 | ||
156 | /* proxyscanconnect.c */ | |
3e986f5e | 157 | int createconnectsocket(struct irc_in_addr *ip, int socknum); |
c86edd1d Q |
158 | |
159 | /* proxyscandb.c */ | |
557c8cb2 | 160 | void loggline(cachehost *chp, patricia_node_t *node); |
c86edd1d Q |
161 | void proxyscandbclose(); |
162 | int proxyscandbinit(); | |
7ab80d0c | 163 | int proxyscandolistopen(void *sender, int cargc, char **cargv); |
7d228b1d D |
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); | |
c86edd1d Q |
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 */ | |
557c8cb2 | 174 | void queuescan(patricia_node_t *node, short scantype, unsigned short port, char class, time_t when); |
c86edd1d Q |
175 | void startqueuedscans(); |
176 | ||
177 | /* proxyscan.c */ | |
557c8cb2 | 178 | void startscan(patricia_node_t *node, int type, int port, int class); |
883d13a2 | 179 | void startnickscan(nick *nick); |
557c8cb2 P |
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); | |
c86edd1d Q |
187 | |
188 | #endif |