]> jfr.im git - irc/quakenet/newserv.git/blob - proxyscan/proxyscan.h
Initial Import
[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
24 #define SOUTCOME_INPROGRESS 0
25 #define SOUTCOME_OPEN 1
26 #define SOUTCOME_CLOSED 2
27
28 #define SCLASS_NORMAL 0
29 #define SCLASS_CHECK 1
30 #define SCLASS_PASS2 2
31 #define SCLASS_PASS3 3
32 #define SCLASS_PASS4 4
33
34 typedef struct scantype {
35 int type;
36 int port;
37 int hits;
38 } scantype;
39
40 typedef struct pendingscan {
41 unsigned int IP;
42 unsigned short port;
43 unsigned char type;
44 unsigned char class;
45 time_t when;
46 struct pendingscan *next;
47 } pendingscan;
48
49 typedef struct foundproxy {
50 short type;
51 unsigned short port;
52 struct foundproxy *next;
53 } foundproxy;
54
55 typedef struct cachehost {
56 unsigned long IP;
57 time_t lastscan;
58 foundproxy *proxies;
59 int glineid;
60 unsigned char marker;
61 #if defined(PROXYSCAN_MAIL)
62 sstring *lasthostmask; /* Not saved to disk */
63 time_t lastconnect; /* Not saved to disk */
64 #endif
65 struct cachehost *next;
66 } cachehost;
67
68 typedef struct scan {
69 int fd;
70 unsigned int IP;
71 short type;
72 unsigned short port;
73 unsigned short state;
74 unsigned short outcome;
75 unsigned short class;
76 struct scan *next;
77 void *sch;
78 char readbuf[PSCAN_READBUFSIZE];
79 int bytesread;
80 int totalbytesread;
81 } scan;
82
83 #if defined(PROXYSCAN_MAIL)
84 extern unsigned int ps_mailip;
85 extern unsigned int ps_mailport;
86 extern sstring *ps_mailname;
87 extern int psm_mailerfd;
88 #endif
89
90 extern int activescans;
91 extern int maxscans;
92 extern int numscans;
93 extern scantype thescans[];
94 extern int brokendb;
95
96 extern unsigned int normalqueuedscans;
97 extern unsigned int prioqueuedscans;
98
99 /* proxyscancache.c */
100 cachehost *addcleanhost(unsigned long IP, time_t timestamp);
101 cachehost *findcachehost(unsigned long IP);
102 void delcachehost(cachehost *);
103 void dumpcachehosts();
104 void loadcachehosts();
105 unsigned int cleancount();
106 unsigned int dirtycount();
107 void cachehostinit(time_t ri);
108 void scanall(int type, int port);
109
110 /* proxyscanalloc.c */
111 scan *getscan();
112 void freescan(scan *sp);
113 cachehost *getcachehost();
114 void freecachehost(cachehost *chp);
115 foundproxy *getfoundproxy();
116 void freefoundproxy(foundproxy *fpp);
117 pendingscan *getpendingscan();
118 void freependingscan(pendingscan *psp);
119 void sfreeall();
120
121 /* proxyscanlisten.c */
122 int openlistensocket(int portnum);
123 void handlelistensocket(int fd, short events);
124
125 /* proxyscanconnect.c */
126 int createconnectsocket(long ip, int socknum);
127
128 /* proxyscandb.c */
129 void loggline(cachehost *chp);
130 void proxyscandbclose();
131 int proxyscandbinit();
132 void proxyscandolistopen(nick *mynick, nick *usernick, time_t snce);
133 const char *scantostr(int type);
134
135 #if defined(PROXYSCAN_MAIL)
136 /* proxyscanmail.c */
137 void ps_makereportmail(scanhost *shp);
138 #endif
139
140 /* proxyscanqueue.c */
141 void queuescan(unsigned int IP, short scantype, unsigned short port, char class, time_t when);
142 void startqueuedscans();
143
144 /* proxyscan.c */
145 void startscan(unsigned int IP, int type, int port, int class);
146
147
148 #endif