]> jfr.im git - irc/quakenet/newserv.git/blob - proxyscan/proxyscan.h
Tidied up some gratuitous malloc-failure code
[irc/quakenet/newserv.git] / proxyscan / proxyscan.h
1
2 #ifndef __PROXYSCAN_H
3 #define __PROXYSCAN_H
4
5 #include "../nick/nick.h"
6 #include <time.h>
7
8 #define MAGICSTRING "NOTICE AUTH :*** Looking up your hostname\r\n"
9 #define MAGICSTRINGLENGTH 42
10
11 #define PSCAN_MAXSCANS 50
12 #define PSCAN_READBUFSIZE (MAGICSTRINGLENGTH * 2)
13
14 #define SSTATE_CONNECTING 0
15 #define SSTATE_SENTREQUEST 1
16 #define SSTATE_GOTRESPONSE 2
17
18 #define STYPE_SOCKS4 0
19 #define STYPE_SOCKS5 1
20 #define STYPE_HTTP 2
21 #define STYPE_WINGATE 3
22 #define STYPE_CISCO 4
23 #define STYPE_DIRECT 5
24
25 #define SOUTCOME_INPROGRESS 0
26 #define SOUTCOME_OPEN 1
27 #define SOUTCOME_CLOSED 2
28
29 #define SCLASS_NORMAL 0
30 #define SCLASS_CHECK 1
31 #define SCLASS_PASS2 2
32 #define SCLASS_PASS3 3
33 #define SCLASS_PASS4 4
34
35 typedef struct scantype {
36 int type;
37 int port;
38 int hits;
39 } scantype;
40
41 typedef struct pendingscan {
42 unsigned int IP;
43 unsigned short port;
44 unsigned char type;
45 unsigned char class;
46 time_t when;
47 struct pendingscan *next;
48 } pendingscan;
49
50 typedef struct foundproxy {
51 short type;
52 unsigned short port;
53 struct foundproxy *next;
54 } foundproxy;
55
56 typedef struct cachehost {
57 unsigned long IP;
58 time_t lastscan;
59 foundproxy *proxies;
60 int glineid;
61 unsigned char marker;
62 #if defined(PROXYSCAN_MAIL)
63 sstring *lasthostmask; /* Not saved to disk */
64 time_t lastconnect; /* Not saved to disk */
65 #endif
66 struct cachehost *next;
67 } cachehost;
68
69 typedef struct scan {
70 int fd;
71 unsigned int IP;
72 short type;
73 unsigned short port;
74 unsigned short state;
75 unsigned short outcome;
76 unsigned short class;
77 struct scan *next;
78 void *sch;
79 char readbuf[PSCAN_READBUFSIZE];
80 int bytesread;
81 int totalbytesread;
82 } scan;
83
84 #if defined(PROXYSCAN_MAIL)
85 extern unsigned int ps_mailip;
86 extern unsigned int ps_mailport;
87 extern sstring *ps_mailname;
88 extern int psm_mailerfd;
89 #endif
90
91 extern int activescans;
92 extern int maxscans;
93 extern int numscans;
94 extern scantype thescans[];
95 extern int brokendb;
96
97 extern unsigned int normalqueuedscans;
98 extern unsigned int prioqueuedscans;
99
100 extern unsigned int ps_start_ts;
101
102 extern unsigned long countpendingscan;
103
104 extern unsigned long scanspermin;
105
106 /* proxyscancache.c */
107 cachehost *addcleanhost(unsigned long IP, time_t timestamp);
108 cachehost *findcachehost(unsigned long IP);
109 void delcachehost(cachehost *);
110 void dumpcachehosts();
111 void loadcachehosts();
112 unsigned int cleancount();
113 unsigned int dirtycount();
114 void cachehostinit(time_t ri);
115 void scanall(int type, int port);
116
117 /* proxyscanalloc.c */
118 scan *getscan();
119 void freescan(scan *sp);
120 cachehost *getcachehost();
121 void freecachehost(cachehost *chp);
122 foundproxy *getfoundproxy();
123 void freefoundproxy(foundproxy *fpp);
124 pendingscan *getpendingscan();
125 void freependingscan(pendingscan *psp);
126 void sfreeall();
127
128 /* proxyscanlisten.c */
129 int openlistensocket(int portnum);
130 void handlelistensocket(int fd, short events);
131
132 /* proxyscanconnect.c */
133 int createconnectsocket(long ip, int socknum);
134
135 /* proxyscandb.c */
136 void loggline(cachehost *chp);
137 void proxyscandbclose();
138 int proxyscandbinit();
139 void proxyscandolistopen(nick *mynick, nick *usernick, time_t snce);
140 void proxyscanspewip(nick *mynick, nick *usernick, unsigned long a, unsigned long b, unsigned long c, unsigned long d);
141 void proxyscanshowkill(nick *mynick, nick *usernick, unsigned long a);
142 const char *scantostr(int type);
143
144 #if defined(PROXYSCAN_MAIL)
145 /* proxyscanmail.c */
146 void ps_makereportmail(scanhost *shp);
147 #endif
148
149 /* proxyscanqueue.c */
150 void queuescan(unsigned int IP, short scantype, unsigned short port, char class, time_t when);
151 void startqueuedscans();
152
153 /* proxyscan.c */
154 void startscan(unsigned int IP, int type, int port, int class);
155
156
157 #endif