]> jfr.im git - irc/quakenet/newserv.git/blame - proxyscan/proxyscan.h
Use nsmalloc/nsfree for proxyscan.
[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
6e5951ae 19#define PSCAN_MAXSCANS 100
0a7647a3 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);
557c8cb2
P
148extrascan *getextrascan();
149void freeextrascan(extrascan *esp);
c86edd1d
Q
150
151/* proxyscanlisten.c */
152int openlistensocket(int portnum);
153void handlelistensocket(int fd, short events);
154
155/* proxyscanconnect.c */
3e986f5e 156int createconnectsocket(struct irc_in_addr *ip, int socknum);
c86edd1d
Q
157
158/* proxyscandb.c */
557c8cb2 159void loggline(cachehost *chp, patricia_node_t *node);
c86edd1d
Q
160void proxyscandbclose();
161int proxyscandbinit();
7ab80d0c 162int proxyscandolistopen(void *sender, int cargc, char **cargv);
7d228b1d
D
163void proxyscanspewip(nick *mynick, nick *usernick, unsigned long a, unsigned long b, unsigned long c, unsigned long d);
164void proxyscanshowkill(nick *mynick, nick *usernick, unsigned long a);
c86edd1d
Q
165const char *scantostr(int type);
166
167#if defined(PROXYSCAN_MAIL)
168/* proxyscanmail.c */
169void ps_makereportmail(scanhost *shp);
170#endif
171
172/* proxyscanqueue.c */
557c8cb2 173void queuescan(patricia_node_t *node, short scantype, unsigned short port, char class, time_t when);
c86edd1d
Q
174void startqueuedscans();
175
176/* proxyscan.c */
557c8cb2 177void startscan(patricia_node_t *node, int type, int port, int class);
883d13a2 178void startnickscan(nick *nick);
557c8cb2
P
179
180/* proxyscanext.c */
181unsigned int extrascancount();
182void loadextrascans();
183extrascan *findextrascan(patricia_node_t *node);
184void delextrascan(extrascan *esp);
185extrascan *addextrascan(unsigned short port, unsigned char type);
c86edd1d
Q
186
187#endif