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