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