~ubuntu-branches/ubuntu/precise/crossroads/precise

« back to all changes in this revision

Viewing changes to xr/config/config

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Ritter
  • Date: 2010-07-05 16:27:00 UTC
  • Revision ID: james.westby@ubuntu.com-20100705162700-0g08tfav8ee9y51u
Tags: upstream-2.65
ImportĀ upstreamĀ versionĀ 2.65

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _CONFIG_
 
2
#define _CONFIG_
 
3
 
 
4
#include "sys/sys"
 
5
#include "backenddef/backenddef"
 
6
#include "servertype/servertype"
 
7
#include "dispatchmode/dispatchmode"
 
8
#include "error/error"
 
9
#include "ThreadsAndMutexes/mutex/mutex"
 
10
#include "backendcheck/backendcheck"
 
11
 
 
12
using namespace std;
 
13
 
 
14
class Config {
 
15
public:
 
16
    Config ();
 
17
 
 
18
    // Init by cmdline
 
19
    void parsecmdline (int ac, char **av);
 
20
 
 
21
    // Accessors
 
22
    bool verbose() const                { return (verbose_flag); }
 
23
    void verbose (bool v)               { verbose_flag = v; }
 
24
 
 
25
    bool debug() const                  { return (debug_flag); }
 
26
    void debug (bool d)                 { debug_flag = d; }
 
27
 
 
28
    unsigned quitafter() const          { return (quit_after); }
 
29
 
 
30
    Servertype::Type stype() const      { return (styp.type()); }
 
31
    void stype(string const &s)         { styp.type(s); }
 
32
    string stypestr() const             { return (styp.typestr()); }
 
33
    string const &sipaddr() const       { return (sip); }
 
34
    int sport() const                   { return (lport); }
 
35
 
 
36
    int backends() const                { return (blist.size()); }
 
37
 
 
38
    /* PID file */
 
39
    void pidfile(string const &s);
 
40
    string const &pidfile() {
 
41
        return pid_file;
 
42
    }
 
43
 
 
44
    /* Client timeouts */
 
45
    unsigned client_read_timeout() const {
 
46
        return (c_timeout);
 
47
    }
 
48
    void client_read_timeout (unsigned c) {
 
49
        c_timeout = c;
 
50
    }
 
51
    unsigned client_write_timeout() const {
 
52
        return c_write_timeout;
 
53
    }
 
54
    void client_write_timeout(unsigned c) {
 
55
        c_write_timeout = c;
 
56
    }
 
57
 
 
58
    /* Back end timeouts */
 
59
    unsigned backend_read_timeout() const {
 
60
        return (b_timeout);
 
61
    }
 
62
    void backend_read_timeout (unsigned b) {
 
63
        b_timeout = b;
 
64
    }
 
65
    unsigned backend_write_timeout() const {
 
66
        return b_write_timeout;
 
67
    }
 
68
    void backend_write_timeout(unsigned b) {
 
69
        b_write_timeout = b;
 
70
    }
 
71
 
 
72
    unsigned wakeupsec() const          { return (wakeup); }
 
73
    void wakeupsec (unsigned w)         { wakeup = w; }
 
74
 
 
75
    unsigned checkupsec() const         { return (checkup); }
 
76
    void checkupsec (unsigned w)        { checkup = w; }
 
77
 
 
78
    unsigned buffersize() const         { return (bufsize); }
 
79
    void buffersize (unsigned b);
 
80
 
 
81
    bool foregroundmode() const         { return (foreground_mode); }
 
82
 
 
83
    bool addxrversion() const           { return (add_xr_version); }
 
84
    void addxrversion (bool b);
 
85
 
 
86
    bool addxforwardedfor() const       { return (add_x_forwarded_for); }
 
87
    void addxforwardedfor (bool b);
 
88
 
 
89
    bool stickyhttp() const             { return (sticky_http); }
 
90
    void stickyhttp(bool b);
 
91
 
 
92
    bool replacehostheader() const      { return replace_host_header; }
 
93
    void replacehostheader(bool s)      { replace_host_header = s; }
 
94
 
 
95
    unsigned maxconn() const            { return (max_conn); }
 
96
    void maxconn (unsigned m);
 
97
 
 
98
    string const &externalalgorithm() const {
 
99
        return (external_algorithm);
 
100
    }
 
101
 
 
102
    bool prefixtimestamp() const        { return (prefix_timestamp); }
 
103
    void prefixtimestamp (bool p);
 
104
 
 
105
    bool fastclose() const              { return (fast_close); }
 
106
    void fastclose (bool f);
 
107
 
 
108
    bool usewebinterface() const        { return use_webinterface; }
 
109
    string const &webinterfaceip() const {
 
110
        return webinterface_ip;
 
111
    }
 
112
    int webinterfaceport() const        { return webinterface_port; }
 
113
 
 
114
    unsigned nserverheaders() const     { return (serverheaders.size()); }
 
115
    string const &serverheader (unsigned n) {
 
116
        return (serverheaders[n]);
 
117
    }
 
118
    void addserverheader (string const &s);
 
119
    void removeserverheader (unsigned i);
 
120
    void changeserverheader (unsigned i, string const &s);
 
121
 
 
122
    string const &dumpdir() const       { return (dump_dir); }
 
123
    void dumpdir (string s)             { dump_dir = s; }
 
124
 
 
125
    unsigned softmaxconnrate() const    { return soft_maxconnrate; }
 
126
    void softmaxconnrate(unsigned n)    { soft_maxconnrate = n; }
 
127
    unsigned hardmaxconnrate() const    { return hard_maxconnrate; }
 
128
    void hardmaxconnrate(unsigned n)    { hard_maxconnrate = n; }
 
129
    unsigned defertime() const          { return defer_time; }
 
130
    void defertime(unsigned n)          { defer_time = n; }
 
131
    unsigned connrate_time() const      { return connrate_timeinterval; }
 
132
    void connrate_time(unsigned n)      { connrate_timeinterval = n; }
 
133
 
 
134
    unsigned dnscachetimeout() const    { return dns_cache_timeout; }
 
135
    void dnscachetimeout(unsigned t)    { dns_cache_timeout = t; }
 
136
    
 
137
    unsigned nallow() const             { return (allowlist.size()); }
 
138
    unsigned ndeny() const              { return (denylist.size()); }
 
139
    void addallow (string a);
 
140
    void adddeny (string d);
 
141
    void changeallow(string &a, unsigned index);
 
142
    void changedeny(string &a, unsigned index);
 
143
    void deleteallow(unsigned index);
 
144
    void deletedeny(unsigned index);
 
145
    
 
146
    int ipstoretimeout() const          { return (ipstore_timeout); }
 
147
    void ipstoretimeout(int t);
 
148
    struct in_addr allow(unsigned n) const {
 
149
        return (allowlist[n]);
 
150
    }
 
151
    struct in_addr deny(unsigned n) const {
 
152
        return (denylist[n]);
 
153
    }
 
154
 
 
155
    BackendDef const &backend (int i) const {
 
156
        return (blist[i]);
 
157
    }
 
158
    Dispatchmode::Mode dispatchmode() const {
 
159
        return (dmode.mode());
 
160
    }
 
161
    string dispatchmodestr() const {
 
162
        return (dmode.modestr());
 
163
    }
 
164
    bool removereservations() const {
 
165
        return remove_reservations;
 
166
    }
 
167
    void removereservations(bool b) {
 
168
        remove_reservations = b;
 
169
    }
 
170
 
 
171
    string const &softmaxconnexcess() const {
 
172
        return soft_maxconn_excess_prog;
 
173
    }
 
174
    void softmaxconnexcess(string const &s) {
 
175
        soft_maxconn_excess_prog = s;
 
176
    }
 
177
    string const &hardmaxconnexcess() const {
 
178
        return hard_maxconn_excess_prog;
 
179
    }
 
180
    void hardmaxconnexcess(string const &s) {
 
181
        hard_maxconn_excess_prog = s;
 
182
    }
 
183
 
 
184
    void onstart(string s)              { on_start = s; }
 
185
    string const &onstart() const       { return on_start; }
 
186
    void onend(string s)                { on_end = s; }
 
187
    string const &onend() const         { return on_end; }
 
188
    void onfail(string s)               { on_fail = s; }
 
189
    string const &onfail() const        { return on_fail; }
 
190
 
 
191
    /* Restart of program */
 
192
    void restart();
 
193
 
 
194
private:
 
195
    void setbackend (string const &s, string const &hostmatch,
 
196
                     string const &urlmatch,
 
197
                     BackendCheck const &bc);
 
198
    void setwebinterface (string s);
 
199
    void setserver (string s);
 
200
    void setdispatchmode (string s);
 
201
    int  setinteger (string s) const;
 
202
 
 
203
    static string pid_file;
 
204
    static bool verbose_flag;
 
205
    static int lport;
 
206
    static Servertype styp;
 
207
    static string sip;
 
208
    static vector<BackendDef> blist;
 
209
    static Dispatchmode dmode;
 
210
    static unsigned c_timeout, c_write_timeout;
 
211
    static unsigned b_timeout, b_write_timeout;
 
212
    static unsigned wakeup;
 
213
    static unsigned checkup;
 
214
    static unsigned bufsize;
 
215
    static bool foreground_mode;
 
216
    static bool add_xr_version;
 
217
    static bool debug_flag;
 
218
    static bool add_x_forwarded_for;
 
219
    static bool sticky_http;
 
220
    static bool replace_host_header;
 
221
    static unsigned max_conn;
 
222
    static string external_algorithm;
 
223
    static bool prefix_timestamp;
 
224
    static vector<string> serverheaders;
 
225
    static vector<struct in_addr> allowlist;
 
226
    static vector<struct in_addr> denylist;
 
227
    static bool fast_close;
 
228
    static int ipstore_timeout;
 
229
    static bool use_webinterface;
 
230
    static string webinterface_ip;
 
231
    static int webinterface_port;
 
232
    static string dump_dir;
 
233
    static unsigned soft_maxconnrate;
 
234
    static unsigned hard_maxconnrate;
 
235
    static unsigned defer_time;
 
236
    static unsigned connrate_timeinterval;
 
237
    static unsigned quit_after;
 
238
    static string soft_maxconn_excess_prog;
 
239
    static string hard_maxconn_excess_prog;
 
240
    static unsigned dns_cache_timeout;
 
241
    static string on_start, on_end, on_fail;
 
242
    static bool remove_reservations;
 
243
    static char **org_argv;
 
244
};
 
245
 
 
246
extern Config config;
 
247
 
 
248
#endif