]>
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 Q |
7 | #include <time.h> |
8 | ||
0a7647a3 P |
9 | #define MAGICSTRING "NOTICE AUTH :*** Looking up your hostname\r\n" |
10 | #define MAGICSTRINGLENGTH 42 | |
c86edd1d | 11 | |
0a7647a3 P |
12 | #define PSCAN_MAXSCANS 50 |
13 | #define PSCAN_READBUFSIZE (MAGICSTRINGLENGTH * 2) | |
c86edd1d Q |
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 | |
905c2ba2 | 24 | #define STYPE_DIRECT 5 |
c86edd1d Q |
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 | ||
557c8cb2 P |
42 | typedef struct extrascan { |
43 | unsigned short port; | |
44 | unsigned char type; | |
45 | struct extrascan *next; | |
46 | struct extrascan *nextbynode; | |
47 | } extrascan; | |
48 | ||
c86edd1d | 49 | typedef struct pendingscan { |
557c8cb2 | 50 | patricia_node_t *node; |
c86edd1d Q |
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 { | |
c86edd1d Q |
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 | |
557c8cb2 | 73 | struct cachehost *next; |
c86edd1d Q |
74 | } cachehost; |
75 | ||
76 | typedef struct scan { | |
77 | int fd; | |
557c8cb2 | 78 | patricia_node_t *node; |
c86edd1d Q |
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; | |
557c8cb2 P |
103 | extern int ps_cache_ext; |
104 | extern int ps_scan_ext; | |
105 | extern int ps_extscan_ext; | |
7ab80d0c P |
106 | extern int ps_ready; |
107 | extern int rescaninterval; | |
c86edd1d Q |
108 | |
109 | extern unsigned int normalqueuedscans; | |
110 | extern unsigned int prioqueuedscans; | |
111 | ||
761a4596 P |
112 | extern unsigned int ps_start_ts; |
113 | ||
92f1d9e3 D |
114 | extern unsigned long countpendingscan; |
115 | ||
116 | extern unsigned long scanspermin; | |
117 | ||
c86edd1d | 118 | /* proxyscancache.c */ |
557c8cb2 P |
119 | cachehost *addcleanhost(time_t timestamp); |
120 | cachehost *findcachehost(patricia_node_t *node); | |
c86edd1d Q |
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(); | |
557c8cb2 P |
139 | extrascan *getextrascan(); |
140 | void freeextrascan(extrascan *esp); | |
c86edd1d Q |
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 */ | |
557c8cb2 | 150 | void loggline(cachehost *chp, patricia_node_t *node); |
c86edd1d Q |
151 | void proxyscandbclose(); |
152 | int proxyscandbinit(); | |
7ab80d0c | 153 | int proxyscandolistopen(void *sender, int cargc, char **cargv); |
7d228b1d D |
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); | |
c86edd1d Q |
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 */ | |
557c8cb2 | 164 | void queuescan(patricia_node_t *node, short scantype, unsigned short port, char class, time_t when); |
c86edd1d Q |
165 | void startqueuedscans(); |
166 | ||
167 | /* proxyscan.c */ | |
557c8cb2 P |
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); | |
c86edd1d Q |
176 | |
177 | #endif |