]> jfr.im git - irc/quakenet/newserv.git/blame - proxyscan/proxyscan.h
Fix corruption bug on DB load - if strlen exceeds network CHANNELLEN, newserv inserts...
[irc/quakenet/newserv.git] / proxyscan / proxyscan.h
CommitLineData
c86edd1d
Q
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
905c2ba2 23#define STYPE_DIRECT 5
c86edd1d
Q
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
35typedef struct scantype {
36 int type;
37 int port;
38 int hits;
39} scantype;
40
557c8cb2
P
41typedef struct extrascan {
42 unsigned short port;
43 unsigned char type;
44 struct extrascan *next;
45 struct extrascan *nextbynode;
46} extrascan;
47
c86edd1d 48typedef struct pendingscan {
557c8cb2 49 patricia_node_t *node;
c86edd1d
Q
50 unsigned short port;
51 unsigned char type;
52 unsigned char class;
53 time_t when;
54 struct pendingscan *next;
55} pendingscan;
56
57typedef struct foundproxy {
58 short type;
59 unsigned short port;
60 struct foundproxy *next;
61} foundproxy;
62
63typedef struct cachehost {
c86edd1d
Q
64 time_t lastscan;
65 foundproxy *proxies;
66 int glineid;
67 unsigned char marker;
68#if defined(PROXYSCAN_MAIL)
69 sstring *lasthostmask; /* Not saved to disk */
70 time_t lastconnect; /* Not saved to disk */
71#endif
557c8cb2 72 struct cachehost *next;
c86edd1d
Q
73} cachehost;
74
75typedef struct scan {
76 int fd;
557c8cb2 77 patricia_node_t *node;
c86edd1d
Q
78 short type;
79 unsigned short port;
80 unsigned short state;
81 unsigned short outcome;
82 unsigned short class;
83 struct scan *next;
84 void *sch;
85 char readbuf[PSCAN_READBUFSIZE];
86 int bytesread;
87 int totalbytesread;
88} scan;
89
90#if defined(PROXYSCAN_MAIL)
91extern unsigned int ps_mailip;
92extern unsigned int ps_mailport;
93extern sstring *ps_mailname;
94extern int psm_mailerfd;
95#endif
96
97extern int activescans;
98extern int maxscans;
99extern int numscans;
100extern scantype thescans[];
101extern int brokendb;
557c8cb2
P
102extern int ps_cache_ext;
103extern int ps_scan_ext;
104extern int ps_extscan_ext;
105
c86edd1d
Q
106
107extern unsigned int normalqueuedscans;
108extern unsigned int prioqueuedscans;
109
761a4596
P
110extern unsigned int ps_start_ts;
111
92f1d9e3
D
112extern unsigned long countpendingscan;
113
114extern unsigned long scanspermin;
115
c86edd1d 116/* proxyscancache.c */
557c8cb2
P
117cachehost *addcleanhost(time_t timestamp);
118cachehost *findcachehost(patricia_node_t *node);
c86edd1d
Q
119void delcachehost(cachehost *);
120void dumpcachehosts();
121void loadcachehosts();
122unsigned int cleancount();
123unsigned int dirtycount();
124void cachehostinit(time_t ri);
125void scanall(int type, int port);
126
127/* proxyscanalloc.c */
128scan *getscan();
129void freescan(scan *sp);
130cachehost *getcachehost();
131void freecachehost(cachehost *chp);
132foundproxy *getfoundproxy();
133void freefoundproxy(foundproxy *fpp);
134pendingscan *getpendingscan();
135void freependingscan(pendingscan *psp);
136void sfreeall();
557c8cb2
P
137extrascan *getextrascan();
138void freeextrascan(extrascan *esp);
c86edd1d
Q
139
140/* proxyscanlisten.c */
141int openlistensocket(int portnum);
142void handlelistensocket(int fd, short events);
143
144/* proxyscanconnect.c */
145int createconnectsocket(long ip, int socknum);
146
147/* proxyscandb.c */
557c8cb2 148void loggline(cachehost *chp, patricia_node_t *node);
c86edd1d
Q
149void proxyscandbclose();
150int proxyscandbinit();
151void proxyscandolistopen(nick *mynick, nick *usernick, time_t snce);
7d228b1d
D
152void proxyscanspewip(nick *mynick, nick *usernick, unsigned long a, unsigned long b, unsigned long c, unsigned long d);
153void proxyscanshowkill(nick *mynick, nick *usernick, unsigned long a);
c86edd1d
Q
154const char *scantostr(int type);
155
156#if defined(PROXYSCAN_MAIL)
157/* proxyscanmail.c */
158void ps_makereportmail(scanhost *shp);
159#endif
160
161/* proxyscanqueue.c */
557c8cb2 162void queuescan(patricia_node_t *node, short scantype, unsigned short port, char class, time_t when);
c86edd1d
Q
163void startqueuedscans();
164
165/* proxyscan.c */
557c8cb2
P
166void startscan(patricia_node_t *node, int type, int port, int class);
167
168/* proxyscanext.c */
169unsigned int extrascancount();
170void loadextrascans();
171extrascan *findextrascan(patricia_node_t *node);
172void delextrascan(extrascan *esp);
173extrascan *addextrascan(unsigned short port, unsigned char type);
c86edd1d
Q
174
175#endif