]>
jfr.im git - irc/quakenet/newserv.git/blob - proxyscan/proxyscan.h
5 #include "../nick/nick.h"
6 #include "../lib/splitline.h"
11 * - a HTTP/SOCKS/... proxy connects directly to our listener (because we told it to)
12 * - it's a proxy that forwards directly to a QuakeNet ircd (we get this because we sent PRIVMSG)
14 #define MAGICSTRING ".quakenet.org 451 * :Register first.\r\n"
15 #define MAGICSTRINGLENGTH (sizeof(MAGICSTRING)-1)
17 /* string seen after a fake GET request */
18 #define MAGICROUTERSTRING "\r\nServer: Mikrotik HttpProxy\r\n"
19 #define MAGICROUTERSTRINGLENGTH (sizeof(MAGICROUTERSTRING)-1)
21 /* string seen if the external program decided it is a proxy */
22 #define MAGICEXTSTRING "DETECTED\n"
23 #define MAGICEXTTRINGLENGTH (sizeof(MAGICEXTSTRING)-1)
25 #define PSCAN_MAXSCANS 100
27 #define P_MAX(a,b) (((a)>(b))?(a):(b))
28 #define PSCAN_READBUFSIZE (P_MAX(MAGICSTRINGLENGTH, P_MAX(MAGICROUTERSTRINGLENGTH, MAGICEXTTRINGLENGTH)))*2
30 #define SSTATE_CONNECTING 0
31 #define SSTATE_SENTREQUEST 1
32 #define SSTATE_GOTRESPONSE 2
34 #define STYPE_SOCKS4 0
35 #define STYPE_SOCKS5_V4 1
36 #define STYPE_SOCKS5_V6 2
37 #define STYPE_HTTP_V4 3
38 #define STYPE_HTTP_V6 4
39 #define STYPE_WINGATE 5
40 #define STYPE_CISCO_V4 6
41 #define STYPE_CISCO_V6 7
42 #define STYPE_DIRECT 8
43 #define STYPE_ROUTER 9
48 #define SOUTCOME_INPROGRESS 0
49 #define SOUTCOME_OPEN 1
50 #define SOUTCOME_CLOSED 2
52 #define SCLASS_NORMAL 0
53 #define SCLASS_CHECK 1
54 #define SCLASS_PASS2 2
55 #define SCLASS_PASS3 3
56 #define SCLASS_PASS4 4
58 typedef struct scantype
{
64 typedef struct extrascan
{
67 struct extrascan
*next
;
68 struct extrascan
*nextbynode
;
71 typedef struct pendingscan
{
72 patricia_node_t
*node
;
77 struct pendingscan
*next
;
80 typedef struct foundproxy
{
83 struct foundproxy
*next
;
86 typedef struct cachehost
{
92 #if defined(PROXYSCAN_MAIL)
93 sstring
*lasthostmask
; /* Not saved to disk */
94 time_t lastconnect
; /* Not saved to disk */
96 struct cachehost
*next
;
101 patricia_node_t
*node
;
104 unsigned short state
;
105 unsigned short outcome
;
106 unsigned short class;
109 char readbuf
[PSCAN_READBUFSIZE
];
114 #if defined(PROXYSCAN_MAIL)
115 extern unsigned int ps_mailip
;
116 extern unsigned int ps_mailport
;
117 extern sstring
*ps_mailname
;
118 extern int psm_mailerfd
;
121 extern int activescans
;
124 extern scantype thescans
[];
126 extern int ps_cache_ext
;
127 extern int ps_scan_ext
;
128 extern int ps_extscan_ext
;
130 extern int rescaninterval
;
132 extern sstring
*exthost
;
135 extern unsigned int normalqueuedscans
;
136 extern unsigned int prioqueuedscans
;
138 extern unsigned int ps_start_ts
;
140 extern unsigned long countpendingscan
;
142 extern unsigned long scanspermin
;
144 /* proxyscancache.c */
145 cachehost
*addcleanhost(time_t timestamp
);
146 cachehost
*findcachehost(patricia_node_t
*node
);
147 void delcachehost(cachehost
*);
148 void dumpcachehosts();
149 void loadcachehosts();
150 unsigned int cleancount();
151 unsigned int dirtycount();
152 void cachehostinit(time_t ri
);
153 void scanall(int type
, int port
);
155 /* proxyscanalloc.c */
157 void freescan(scan
*sp
);
158 cachehost
*getcachehost();
159 void freecachehost(cachehost
*chp
);
160 foundproxy
*getfoundproxy();
161 void freefoundproxy(foundproxy
*fpp
);
162 pendingscan
*getpendingscan();
163 void freependingscan(pendingscan
*psp
);
164 extrascan
*getextrascan();
165 void freeextrascan(extrascan
*esp
);
167 /* proxyscanlisten.c */
168 int openlistensocket(int portnum
);
169 void handlelistensocket(int fd
, short events
);
171 /* proxyscanconnect.c */
172 int createconnectsocket(struct irc_in_addr
*ip
, int socknum
);
175 void loggline(cachehost
*chp
, patricia_node_t
*node
);
176 void proxyscandbclose();
177 int proxyscandbinit();
178 int proxyscandolistopen(void *sender
, int cargc
, char **cargv
);
179 void proxyscanspewip(nick
*mynick
, nick
*usernick
, unsigned long a
, unsigned long b
, unsigned long c
, unsigned long d
);
180 void proxyscanshowkill(nick
*mynick
, nick
*usernick
, unsigned long a
);
181 const char *scantostr(int type
);
183 #if defined(PROXYSCAN_MAIL)
184 /* proxyscanmail.c */
185 void ps_makereportmail(scanhost
*shp
);
188 /* proxyscanqueue.c */
189 void queuescan(patricia_node_t
*node
, short scantype
, unsigned short port
, char class, time_t when
);
190 void startqueuedscans();
193 void startscan(patricia_node_t
*node
, int type
, int port
, int class);
194 void startnickscan(nick
*nick
);
197 unsigned int extrascancount();
198 void loadextrascans();
199 extrascan
*findextrascan(patricia_node_t
*node
);
200 void delextrascan(extrascan
*esp
);
201 extrascan
*addextrascan(unsigned short port
, unsigned char type
);