]>
jfr.im git - irc/quakenet/newserv.git/blob - proxyscan/proxyscan.h
5 #include "../nick/nick.h"
6 #include "../lib/splitline.h"
10 #define MAGICSTRING "NOTICE AUTH :*** Looking up your hostname\r\n"
11 #define MAGICSTRINGLENGTH 42
13 #define MAGICIRCSTRING ".quakenet.org 451 * :Register first.\r\n"
14 #define MAGICIRCSTRINGLENGTH 38
16 #define MAGICROUTERSTRING "\r\nServer: Mikrotik HttpProxy\r\n"
17 #define MAGICROUTERSTRINGLENGTH 30
19 #define PSCAN_MAXSCANS 100
20 #define PSCAN_READBUFSIZE (MAGICSTRINGLENGTH * 2)
22 #define SSTATE_CONNECTING 0
23 #define SSTATE_SENTREQUEST 1
24 #define SSTATE_GOTRESPONSE 2
26 #define STYPE_SOCKS4 0
27 #define STYPE_SOCKS5 1
29 #define STYPE_WINGATE 3
31 #define STYPE_DIRECT 5 /* not sure what this is so I'm leaving it alone */
32 #define STYPE_DIRECT_IRC 6
33 #define STYPE_ROUTER 7
35 #define SOUTCOME_INPROGRESS 0
36 #define SOUTCOME_OPEN 1
37 #define SOUTCOME_CLOSED 2
39 #define SCLASS_NORMAL 0
40 #define SCLASS_CHECK 1
41 #define SCLASS_PASS2 2
42 #define SCLASS_PASS3 3
43 #define SCLASS_PASS4 4
45 typedef struct scantype
{
51 typedef struct extrascan
{
54 struct extrascan
*next
;
55 struct extrascan
*nextbynode
;
58 typedef struct pendingscan
{
59 patricia_node_t
*node
;
64 struct pendingscan
*next
;
67 typedef struct foundproxy
{
70 struct foundproxy
*next
;
73 typedef struct cachehost
{
79 #if defined(PROXYSCAN_MAIL)
80 sstring
*lasthostmask
; /* Not saved to disk */
81 time_t lastconnect
; /* Not saved to disk */
83 struct cachehost
*next
;
88 patricia_node_t
*node
;
92 unsigned short outcome
;
96 char readbuf
[PSCAN_READBUFSIZE
];
101 #if defined(PROXYSCAN_MAIL)
102 extern unsigned int ps_mailip
;
103 extern unsigned int ps_mailport
;
104 extern sstring
*ps_mailname
;
105 extern int psm_mailerfd
;
108 extern int activescans
;
111 extern scantype thescans
[];
113 extern int ps_cache_ext
;
114 extern int ps_scan_ext
;
115 extern int ps_extscan_ext
;
117 extern int rescaninterval
;
119 extern unsigned int normalqueuedscans
;
120 extern unsigned int prioqueuedscans
;
122 extern unsigned int ps_start_ts
;
124 extern unsigned long countpendingscan
;
126 extern unsigned long scanspermin
;
128 /* proxyscancache.c */
129 cachehost
*addcleanhost(time_t timestamp
);
130 cachehost
*findcachehost(patricia_node_t
*node
);
131 void delcachehost(cachehost
*);
132 void dumpcachehosts();
133 void loadcachehosts();
134 unsigned int cleancount();
135 unsigned int dirtycount();
136 void cachehostinit(time_t ri
);
137 void scanall(int type
, int port
);
139 /* proxyscanalloc.c */
141 void freescan(scan
*sp
);
142 cachehost
*getcachehost();
143 void freecachehost(cachehost
*chp
);
144 foundproxy
*getfoundproxy();
145 void freefoundproxy(foundproxy
*fpp
);
146 pendingscan
*getpendingscan();
147 void freependingscan(pendingscan
*psp
);
148 extrascan
*getextrascan();
149 void freeextrascan(extrascan
*esp
);
151 /* proxyscanlisten.c */
152 int openlistensocket(int portnum
);
153 void handlelistensocket(int fd
, short events
);
155 /* proxyscanconnect.c */
156 int createconnectsocket(struct irc_in_addr
*ip
, int socknum
);
159 void loggline(cachehost
*chp
, patricia_node_t
*node
);
160 void proxyscandbclose();
161 int proxyscandbinit();
162 int proxyscandolistopen(void *sender
, int cargc
, char **cargv
);
163 void proxyscanspewip(nick
*mynick
, nick
*usernick
, unsigned long a
, unsigned long b
, unsigned long c
, unsigned long d
);
164 void proxyscanshowkill(nick
*mynick
, nick
*usernick
, unsigned long a
);
165 const char *scantostr(int type
);
167 #if defined(PROXYSCAN_MAIL)
168 /* proxyscanmail.c */
169 void ps_makereportmail(scanhost
*shp
);
172 /* proxyscanqueue.c */
173 void queuescan(patricia_node_t
*node
, short scantype
, unsigned short port
, char class, time_t when
);
174 void startqueuedscans();
177 void startscan(patricia_node_t
*node
, int type
, int port
, int class);
178 void startnickscan(nick
*nick
);
181 unsigned int extrascancount();
182 void loadextrascans();
183 extrascan
*findextrascan(patricia_node_t
*node
);
184 void delextrascan(extrascan
*esp
);
185 extrascan
*addextrascan(unsigned short port
, unsigned char type
);