]> jfr.im git - irc/quakenet/newserv.git/blame - proxyscan/proxyscan.h
Merge.
[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"
7ab80d0c 6#include "../lib/splitline.h"
c86edd1d 7#include <time.h>
c7be40f8 8#include <stdint.h>
c86edd1d 9
0a7647a3
P
10#define MAGICSTRING "NOTICE AUTH :*** Looking up your hostname\r\n"
11#define MAGICSTRINGLENGTH 42
c86edd1d 12
c7be40f8
CP
13#define MAGICIRCSTRING ".quakenet.org 451 * :Register first.\r\n"
14#define MAGICIRCSTRINGLENGTH 38
15
0a7647a3
P
16#define PSCAN_MAXSCANS 50
17#define PSCAN_READBUFSIZE (MAGICSTRINGLENGTH * 2)
c86edd1d
Q
18
19#define SSTATE_CONNECTING 0
20#define SSTATE_SENTREQUEST 1
21#define SSTATE_GOTRESPONSE 2
22
23#define STYPE_SOCKS4 0
24#define STYPE_SOCKS5 1
25#define STYPE_HTTP 2
26#define STYPE_WINGATE 3
27#define STYPE_CISCO 4
c7be40f8
CP
28#define STYPE_DIRECT 5 /* not sure what this is so I'm leaving it alone */
29#define STYPE_DIRECT_IRC 6
c86edd1d
Q
30
31#define SOUTCOME_INPROGRESS 0
32#define SOUTCOME_OPEN 1
33#define SOUTCOME_CLOSED 2
34
35#define SCLASS_NORMAL 0
36#define SCLASS_CHECK 1
37#define SCLASS_PASS2 2
38#define SCLASS_PASS3 3
39#define SCLASS_PASS4 4
40
41typedef struct scantype {
42 int type;
43 int port;
44 int hits;
45} scantype;
46
557c8cb2
P
47typedef struct extrascan {
48 unsigned short port;
49 unsigned char type;
50 struct extrascan *next;
51 struct extrascan *nextbynode;
52} extrascan;
53
c86edd1d 54typedef struct pendingscan {
557c8cb2 55 patricia_node_t *node;
c86edd1d
Q
56 unsigned short port;
57 unsigned char type;
58 unsigned char class;
59 time_t when;
60 struct pendingscan *next;
61} pendingscan;
62
63typedef struct foundproxy {
64 short type;
65 unsigned short port;
66 struct foundproxy *next;
67} foundproxy;
68
69typedef struct cachehost {
c86edd1d
Q
70 time_t lastscan;
71 foundproxy *proxies;
72 int glineid;
73 unsigned char marker;
74#if defined(PROXYSCAN_MAIL)
75 sstring *lasthostmask; /* Not saved to disk */
76 time_t lastconnect; /* Not saved to disk */
77#endif
557c8cb2 78 struct cachehost *next;
c86edd1d
Q
79} cachehost;
80
81typedef struct scan {
82 int fd;
557c8cb2 83 patricia_node_t *node;
c86edd1d
Q
84 short type;
85 unsigned short port;
86 unsigned short state;
87 unsigned short outcome;
88 unsigned short class;
89 struct scan *next;
90 void *sch;
91 char readbuf[PSCAN_READBUFSIZE];
92 int bytesread;
93 int totalbytesread;
94} scan;
95
96#if defined(PROXYSCAN_MAIL)
97extern unsigned int ps_mailip;
98extern unsigned int ps_mailport;
99extern sstring *ps_mailname;
100extern int psm_mailerfd;
101#endif
102
103extern int activescans;
104extern int maxscans;
105extern int numscans;
106extern scantype thescans[];
107extern int brokendb;
557c8cb2
P
108extern int ps_cache_ext;
109extern int ps_scan_ext;
110extern int ps_extscan_ext;
7ab80d0c
P
111extern int ps_ready;
112extern int rescaninterval;
c86edd1d
Q
113
114extern unsigned int normalqueuedscans;
115extern unsigned int prioqueuedscans;
116
761a4596
P
117extern unsigned int ps_start_ts;
118
92f1d9e3
D
119extern unsigned long countpendingscan;
120
121extern unsigned long scanspermin;
122
c86edd1d 123/* proxyscancache.c */
557c8cb2
P
124cachehost *addcleanhost(time_t timestamp);
125cachehost *findcachehost(patricia_node_t *node);
c86edd1d
Q
126void delcachehost(cachehost *);
127void dumpcachehosts();
128void loadcachehosts();
129unsigned int cleancount();
130unsigned int dirtycount();
131void cachehostinit(time_t ri);
132void scanall(int type, int port);
133
134/* proxyscanalloc.c */
135scan *getscan();
136void freescan(scan *sp);
137cachehost *getcachehost();
138void freecachehost(cachehost *chp);
139foundproxy *getfoundproxy();
140void freefoundproxy(foundproxy *fpp);
141pendingscan *getpendingscan();
142void freependingscan(pendingscan *psp);
143void sfreeall();
557c8cb2
P
144extrascan *getextrascan();
145void freeextrascan(extrascan *esp);
c86edd1d
Q
146
147/* proxyscanlisten.c */
148int openlistensocket(int portnum);
149void handlelistensocket(int fd, short events);
150
151/* proxyscanconnect.c */
152int createconnectsocket(long ip, int socknum);
153
154/* proxyscandb.c */
557c8cb2 155void loggline(cachehost *chp, patricia_node_t *node);
c86edd1d
Q
156void proxyscandbclose();
157int proxyscandbinit();
7ab80d0c 158int proxyscandolistopen(void *sender, int cargc, char **cargv);
7d228b1d
D
159void proxyscanspewip(nick *mynick, nick *usernick, unsigned long a, unsigned long b, unsigned long c, unsigned long d);
160void proxyscanshowkill(nick *mynick, nick *usernick, unsigned long a);
c86edd1d
Q
161const char *scantostr(int type);
162
163#if defined(PROXYSCAN_MAIL)
164/* proxyscanmail.c */
165void ps_makereportmail(scanhost *shp);
166#endif
167
168/* proxyscanqueue.c */
557c8cb2 169void queuescan(patricia_node_t *node, short scantype, unsigned short port, char class, time_t when);
c86edd1d
Q
170void startqueuedscans();
171
172/* proxyscan.c */
557c8cb2
P
173void startscan(patricia_node_t *node, int type, int port, int class);
174
175/* proxyscanext.c */
176unsigned int extrascancount();
177void loadextrascans();
178extrascan *findextrascan(patricia_node_t *node);
179void delextrascan(extrascan *esp);
180extrascan *addextrascan(unsigned short port, unsigned char type);
c86edd1d
Q
181
182#endif