1 |
/* Copyright (C) 2003 Stephane Thiell |
2 |
* |
3 |
* This file is part of pxyscand (from pxys) |
4 |
* |
5 |
* This program is free software; you can redistribute it and/or |
6 |
* modify it under the terms of the GNU General Public License |
7 |
* as published by the Free Software Foundation; either version 2 |
8 |
* of the License, or (at your option) any later version. |
9 |
* |
10 |
* This program is distributed in the hope that it will be useful, |
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
* GNU General Public License for more details. |
14 |
* |
15 |
* You should have received a copy of the GNU General Public License |
16 |
* along with this program; if not, write to the Free Software |
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 |
* |
19 |
*/ |
20 |
#ifndef INCLUDED_PXCONFIG_H_ |
21 |
#define INCLUDED_PXCONFIG_H_ |
22 |
|
23 |
#include <sys/types.h> |
24 |
#include <sys/socket.h> |
25 |
#include <netinet/in.h> |
26 |
#include <ctime> |
27 |
|
28 |
#include <vector> |
29 |
|
30 |
#include "PXMutex.h" |
31 |
|
32 |
#define PXOPAS_PROTO_TCP 1 |
33 |
#define PXOPAS_PROTO_UDP 2 |
34 |
|
35 |
using std::vector; |
36 |
|
37 |
struct PXConfigOPAS |
38 |
{ |
39 |
int port; |
40 |
in_addr local_address; |
41 |
vector<int> proto; |
42 |
vector<in_addr> allow; |
43 |
int limit; |
44 |
}; |
45 |
|
46 |
struct PXConfigModule |
47 |
{ |
48 |
int id; |
49 |
int port; |
50 |
}; |
51 |
|
52 |
enum |
53 |
{ |
54 |
CONFIG_MODULE_WINGATE, |
55 |
CONFIG_MODULE_SOCKS, |
56 |
CONFIG_MODULE_HTTP, |
57 |
CONFIG_MODULE_CRAZYBANDIT |
58 |
/* Add new module type id here. */ |
59 |
}; |
60 |
|
61 |
struct PXConfigScannerTarget |
62 |
{ |
63 |
in_addr address; |
64 |
int port; |
65 |
}; |
66 |
|
67 |
struct PXConfigScanner |
68 |
{ |
69 |
int maxscans; |
70 |
vector<PXConfigModule> modules; |
71 |
vector<in_addr> source_pool; |
72 |
vector<PXConfigScannerTarget> targets; |
73 |
time_t target_check; |
74 |
char *log_agent; |
75 |
time_t timeout; |
76 |
vector<char *> strings; |
77 |
}; |
78 |
|
79 |
struct PXConfigCache |
80 |
{ |
81 |
char *dir; |
82 |
int expire; |
83 |
int proxy_expire; |
84 |
int maxips; |
85 |
}; |
86 |
|
87 |
struct NetworkNetmask |
88 |
{ |
89 |
in_addr network; |
90 |
in_addr netmask; |
91 |
}; |
92 |
|
93 |
struct PXConfigNoScan |
94 |
{ |
95 |
vector<NetworkNetmask> address; |
96 |
}; |
97 |
|
98 |
struct PXConfig |
99 |
{ |
100 |
PXConfig(); |
101 |
~PXConfig(); |
102 |
|
103 |
bool OPASIsAllowed(const in_addr &in) const; |
104 |
bool HasSourcePool() const { return scanner.source_pool.size() > 0; } |
105 |
in_addr GetOneFromSourcePool() const; |
106 |
bool ScannerStringCheck(const char *s) const; |
107 |
bool CheckNoScan(const in_addr &addr) const; |
108 |
|
109 |
PXConfigOPAS opas; |
110 |
PXConfigScanner scanner; |
111 |
PXConfigCache cache; |
112 |
PXConfigNoScan noscan; |
113 |
protected: |
114 |
mutable PXMutex mutex; |
115 |
}; |
116 |
|
117 |
#endif /* INCLUDED_PXCONFIG_H_ */ |