]>
jfr.im git - irc/quakenet/newserv.git/blob - proxyscan/proxyscan.h
5 #include "../nick/nick.h"
6 #include "../lib/splitline.h"
9 #define MAGICSTRING "NOTICE AUTH :*** Looking up your hostname\r\n"
10 #define MAGICSTRINGLENGTH 42
12 #define PSCAN_MAXSCANS 50
13 #define PSCAN_READBUFSIZE (MAGICSTRINGLENGTH * 2)
15 #define SSTATE_CONNECTING 0
16 #define SSTATE_SENTREQUEST 1
17 #define SSTATE_GOTRESPONSE 2
19 #define STYPE_SOCKS4 0
20 #define STYPE_SOCKS5 1
22 #define STYPE_WINGATE 3
24 #define STYPE_DIRECT 5
26 #define SOUTCOME_INPROGRESS 0
27 #define SOUTCOME_OPEN 1
28 #define SOUTCOME_CLOSED 2
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
36 typedef struct scantype
{
42 typedef struct extrascan
{
45 struct extrascan
*next
;
46 struct extrascan
*nextbynode
;
49 typedef struct pendingscan
{
50 patricia_node_t
*node
;
55 struct pendingscan
*next
;
58 typedef struct foundproxy
{
61 struct foundproxy
*next
;
64 typedef struct cachehost
{
69 #if defined(PROXYSCAN_MAIL)
70 sstring
*lasthostmask
; /* Not saved to disk */
71 time_t lastconnect
; /* Not saved to disk */
73 struct cachehost
*next
;
78 patricia_node_t
*node
;
82 unsigned short outcome
;
86 char readbuf
[PSCAN_READBUFSIZE
];
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
;
98 extern int activescans
;
101 extern scantype thescans
[];
103 extern int ps_cache_ext
;
104 extern int ps_scan_ext
;
105 extern int ps_extscan_ext
;
107 extern int rescaninterval
;
109 extern unsigned int normalqueuedscans
;
110 extern unsigned int prioqueuedscans
;
112 extern unsigned int ps_start_ts
;
114 extern unsigned long countpendingscan
;
116 extern unsigned long scanspermin
;
118 /* proxyscancache.c */
119 cachehost
*addcleanhost(time_t timestamp
);
120 cachehost
*findcachehost(patricia_node_t
*node
);
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
);
129 /* proxyscanalloc.c */
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
);
139 extrascan
*getextrascan();
140 void freeextrascan(extrascan
*esp
);
142 /* proxyscanlisten.c */
143 int openlistensocket(int portnum
);
144 void handlelistensocket(int fd
, short events
);
146 /* proxyscanconnect.c */
147 int createconnectsocket(long ip
, int socknum
);
150 void loggline(cachehost
*chp
, patricia_node_t
*node
);
151 void proxyscandbclose();
152 int proxyscandbinit();
153 int proxyscandolistopen(void *sender
, int cargc
, char **cargv
);
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
);
156 const char *scantostr(int type
);
158 #if defined(PROXYSCAN_MAIL)
159 /* proxyscanmail.c */
160 void ps_makereportmail(scanhost
*shp
);
163 /* proxyscanqueue.c */
164 void queuescan(patricia_node_t
*node
, short scantype
, unsigned short port
, char class, time_t when
);
165 void startqueuedscans();
168 void startscan(patricia_node_t
*node
, int type
, int port
, int class);
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
);