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