1 /*
2  * include/types/proxy.h
3  * This file defines everything related to proxies.
4  *
5  * Copyright (C) 2000-2011 Willy Tarreau - w@1wt.eu
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation, version 2.1
10  * exclusively.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21 
22 #ifndef _TYPES_PROXY_H
23 #define _TYPES_PROXY_H
24 
25 #include <sys/types.h>
26 #include <sys/socket.h>
27 #include <netinet/in.h>
28 #include <arpa/inet.h>
29 
30 #include <common/chunk.h>
31 #include <common/config.h>
32 #include <common/http.h>
33 #include <common/mini-clist.h>
34 #include <common/regex.h>
35 #include <common/tools.h>
36 #include <common/hathreads.h>
37 
38 #include <eb32tree.h>
39 #include <ebistree.h>
40 
41 #include <types/acl.h>
42 #include <types/backend.h>
43 #include <types/counters.h>
44 #include <types/filters.h>
45 #include <types/freq_ctr.h>
46 #include <types/listener.h>
47 #include <types/log.h>
48 #include <types/obj_type.h>
49 #include <types/sample.h>
50 #include <types/server.h>
51 #include <types/stick_table.h>
52 
53 /* values for proxy->state */
54 enum pr_state {
55 	PR_STNEW = 0,           /* proxy has not been initialized yet */
56 	PR_STREADY,             /* proxy has been initialized and is ready */
57 	PR_STFULL,              /* frontend is full (maxconn reached) */
58 	PR_STPAUSED,            /* frontend is paused (during hot restart) */
59 	PR_STSTOPPED,           /* proxy is stopped (end of a restart) */
60 	PR_STERROR,             /* proxy experienced an unrecoverable error */
61 } __attribute__((packed));
62 
63 /* values for proxy->mode */
64 enum pr_mode {
65 	PR_MODE_TCP = 0,
66 	PR_MODE_HTTP,
67 	PR_MODE_HEALTH,
68 	PR_MODE_CLI,
69 } __attribute__((packed));
70 
71 enum PR_SRV_STATE_FILE {
72 	PR_SRV_STATE_FILE_UNSPEC = 0,
73 	PR_SRV_STATE_FILE_NONE,
74 	PR_SRV_STATE_FILE_GLOBAL,
75 	PR_SRV_STATE_FILE_LOCAL,
76 };
77 
78 
79 /* flag values for proxy->cap. This is a bitmask of capabilities supported by the proxy */
80 #define PR_CAP_NONE    0x0000
81 #define PR_CAP_FE      0x0001
82 #define PR_CAP_BE      0x0002
83 #define PR_CAP_LISTEN  (PR_CAP_FE|PR_CAP_BE)
84 
85 /* bits for proxy->options */
86 #define PR_O_REDISP     0x00000001      /* allow reconnection to dispatch in case of errors */
87 #define PR_O_TRANSP     0x00000002      /* transparent mode : use original DEST as dispatch */
88 
89 /* HTTP server-side reuse */
90 #define PR_O_REUSE_NEVR 0x00000000      /* never reuse a shared connection */
91 #define PR_O_REUSE_SAFE 0x00000004      /* only reuse a shared connection when it's safe to do so */
92 #define PR_O_REUSE_AGGR 0x00000008      /* aggressively reuse a shared connection */
93 #define PR_O_REUSE_ALWS 0x0000000C      /* always reuse a shared connection */
94 #define PR_O_REUSE_MASK 0x0000000C      /* mask to retrieve shared connection preferences */
95 
96 /* unused: 0x10 */
97 #define PR_O_PREF_LAST  0x00000020      /* prefer last server */
98 #define PR_O_DISPATCH   0x00000040      /* use dispatch mode */
99 #define PR_O_FORCED_ID  0x00000080      /* proxy's ID was forced in the configuration */
100 #define PR_O_FWDFOR     0x00000100      /* conditionally insert x-forwarded-for with client address */
101 #define PR_O_IGNORE_PRB 0x00000200      /* ignore empty requests (aborts and timeouts) */
102 #define PR_O_NULLNOLOG  0x00000400      /* a connect without request will not be logged */
103 #define PR_O_WREQ_BODY  0x00000800      /* always wait for the HTTP request body */
104 /* unused: 0x1000 */
105 #define PR_O_FF_ALWAYS  0x00002000      /* always set x-forwarded-for */
106 #define PR_O_PERSIST    0x00004000      /* server persistence stays effective even when server is down */
107 #define PR_O_LOGASAP    0x00008000      /* log as soon as possible, without waiting for the stream to complete */
108 /* unused: 0x00010000 */
109 #define PR_O_CHK_CACHE  0x00020000      /* require examination of cacheability of the 'set-cookie' field */
110 #define PR_O_TCP_CLI_KA 0x00040000      /* enable TCP keep-alive on client-side streams */
111 #define PR_O_TCP_SRV_KA 0x00080000      /* enable TCP keep-alive on server-side streams */
112 #define PR_O_USE_ALL_BK 0x00100000      /* load-balance between backup servers */
113 /* unused: 0x00020000 */
114 #define PR_O_TCP_NOLING 0x00400000      /* disable lingering on client and server connections */
115 #define PR_O_ABRT_CLOSE 0x00800000      /* immediately abort request when client closes */
116 
117 #define PR_O_HTTP_KAL   0x00000000      /* HTTP keep-alive mode (http-keep-alive) */
118 #define PR_O_HTTP_CLO   0x01000000      /* HTTP close mode (httpclose) */
119 #define PR_O_HTTP_SCL   0x02000000      /* HTTP server close mode (http-server-close) */
120 #define PR_O_HTTP_MODE  0x03000000      /* MASK to retrieve the HTTP mode */
121 /* unused: 0x04000000 */
122 
123 #define PR_O_TCPCHK_SSL 0x08000000	/* at least one TCPCHECK connect rule requires SSL */
124 #define PR_O_CONTSTATS	0x10000000	/* continuous counters */
125 #define PR_O_HTTP_PROXY 0x20000000	/* Enable stream to use HTTP proxy operations */
126 #define PR_O_DISABLE404 0x40000000      /* Disable a server on a 404 response to a health-check */
127 #define PR_O_ORGTO      0x80000000      /* insert x-original-to with destination address */
128 
129 /* bits for proxy->options2 */
130 #define PR_O2_SPLIC_REQ	0x00000001      /* transfer requests using linux kernel's splice() */
131 #define PR_O2_SPLIC_RTR	0x00000002      /* transfer responses using linux kernel's splice() */
132 #define PR_O2_SPLIC_AUT	0x00000004      /* automatically use linux kernel's splice() */
133 #define PR_O2_SPLIC_ANY	(PR_O2_SPLIC_REQ|PR_O2_SPLIC_RTR|PR_O2_SPLIC_AUT)
134 #define PR_O2_REQBUG_OK	0x00000008      /* let buggy requests pass through */
135 #define PR_O2_RSPBUG_OK	0x00000010      /* let buggy responses pass through */
136 #define PR_O2_NOLOGNORM	0x00000020      /* don't log normal traffic, only errors and retries */
137 #define PR_O2_LOGERRORS	0x00000040      /* log errors and retries at level LOG_ERR */
138 #define PR_O2_SMARTACC 	0x00000080      /* don't immediately ACK request after accept */
139 #define PR_O2_SMARTCON 	0x00000100      /* don't immediately send empty ACK after connect */
140 #define PR_O2_RDPC_PRST	0x00000200      /* Actvate rdp cookie analyser */
141 #define PR_O2_CLFLOG	0x00000400      /* log into clf format */
142 #define PR_O2_LOGHCHKS	0x00000800	/* log health checks */
143 #define PR_O2_INDEPSTR	0x00001000	/* independent streams, don't update rex on write */
144 #define PR_O2_SOCKSTAT	0x00002000	/* collect & provide separate statistics for sockets */
145 
146 #define PR_O2_H1_ADJ_BUGCLI 0x00008000 /* adjust the case of h1 headers of the response for bogus clients */
147 #define PR_O2_H1_ADJ_BUGSRV 0x00004000 /* adjust the case of h1 headers of the request for bogus servers */
148 
149 /* unused:  0x00010000 */
150 
151 #define PR_O2_NODELAY   0x00020000      /* fully interactive mode, never delay outgoing data */
152 #define PR_O2_USE_PXHDR 0x00040000      /* use Proxy-Connection for proxy requests */
153 #define PR_O2_CHK_SNDST 0x00080000      /* send the state of each server along with HTTP health checks */
154 
155 #define PR_O2_SRC_ADDR	0x00100000	/* get the source ip and port for logs */
156 
157 #define PR_O2_FAKE_KA   0x00200000      /* pretend we do keep-alive with server eventhough we close */
158 /* unused : 0x00400000 */
159 
160 #define PR_O2_EXP_NONE  0x00000000      /* http-check : no expect rule */
161 #define PR_O2_EXP_STS   0x00800000      /* http-check expect status */
162 #define PR_O2_EXP_RSTS  0x01000000      /* http-check expect rstatus */
163 #define PR_O2_EXP_STR   0x01800000      /* http-check expect string */
164 #define PR_O2_EXP_RSTR  0x02000000      /* http-check expect rstring */
165 #define PR_O2_EXP_TYPE  0x03800000      /* mask for http-check expect type */
166 #define PR_O2_EXP_INV   0x04000000      /* http-check expect !<rule> */
167 /* unused: 0x08000000 */
168 
169 /* server health checks */
170 #define PR_O2_CHK_NONE  0x00000000      /* no L7 health checks configured (TCP by default) */
171 #define PR_O2_PGSQL_CHK 0x10000000      /* use PGSQL check for server health */
172 #define PR_O2_REDIS_CHK 0x20000000      /* use LDAP check for server health */
173 #define PR_O2_SMTP_CHK  0x30000000      /* use SMTP EHLO check for server health - pvandijk@vision6.com.au */
174 #define PR_O2_HTTP_CHK  0x40000000      /* use HTTP 'OPTIONS' method to check server health */
175 #define PR_O2_MYSQL_CHK 0x50000000      /* use MYSQL check for server health */
176 #define PR_O2_LDAP_CHK  0x60000000      /* use LDAP check for server health */
177 #define PR_O2_SSL3_CHK  0x70000000      /* use SSLv3 CLIENT_HELLO packets for server health */
178 #define PR_O2_LB_AGENT_CHK 0x80000000   /* use a TCP connection to obtain a metric of server health */
179 #define PR_O2_TCPCHK_CHK 0x90000000     /* use TCPCHK check for server health */
180 #define PR_O2_EXT_CHK   0xA0000000      /* use external command for server health */
181 #define PR_O2_SPOP_CHK  0xB0000000      /* use SPOP for server health */
182 /* unused: 0xC0000000 to 0xF000000, reserved for health checks */
183 #define PR_O2_CHK_ANY   0xF0000000      /* Mask to cover any check */
184 /* end of proxy->options2 */
185 
186 /* Cookie settings for pr->ck_opts */
187 #define PR_CK_RW        0x00000001      /* rewrite all direct cookies with the right serverid */
188 #define PR_CK_IND       0x00000002      /* keep only indirect cookies */
189 #define PR_CK_INS       0x00000004      /* insert cookies when not accessing a server directly */
190 #define PR_CK_PFX       0x00000008      /* rewrite all cookies by prefixing the right serverid */
191 #define PR_CK_ANY       (PR_CK_RW | PR_CK_IND | PR_CK_INS | PR_CK_PFX)
192 #define PR_CK_NOC       0x00000010      /* add a 'Cache-control' header with the cookie */
193 #define PR_CK_POST      0x00000020      /* don't insert cookies for requests other than a POST */
194 #define PR_CK_PSV       0x00000040      /* cookie ... preserve */
195 #define PR_CK_HTTPONLY  0x00000080      /* emit the "HttpOnly" attribute */
196 #define PR_CK_SECURE    0x00000100      /* emit the "Secure" attribute */
197 #define PR_CK_DYNAMIC   0x00000200	/* create dynamic cookies for each server */
198 
199 /* bits for sticking rules */
200 #define STK_IS_MATCH	0x00000001	/* match on request fetch */
201 #define STK_IS_STORE	0x00000002	/* store on request fetch */
202 #define STK_ON_RSP	0x00000004	/* store on response fetch */
203 
204 /* diff bits for proxy_find_best_match */
205 #define PR_FBM_MISMATCH_ID        0x01
206 #define PR_FBM_MISMATCH_NAME      0x02
207 #define PR_FBM_MISMATCH_PROXYTYPE 0x04
208 
209 /* Bits for the different retry causes */
210 #define PR_RE_CONN_FAILED         0x00000001 /* Retry if we failed to connect */
211 #define PR_RE_DISCONNECTED        0x00000002 /* Retry if we got disconnected with no answer */
212 #define PR_RE_TIMEOUT             0x00000004 /* Retry if we got a server timeout before we got any data */
213 #define PR_RE_404                 0x00000008 /* Retry if we got a 404 */
214 #define PR_RE_408                 0x00000010 /* Retry if we got a 408 */
215 #define PR_RE_425                 0x00000020 /* Retry if we got a 425 */
216 #define PR_RE_500                 0x00000040 /* Retry if we got a 500 */
217 #define PR_RE_501                 0x00000080 /* Retry if we got a 501 */
218 #define PR_RE_502                 0x00000100 /* Retry if we got a 502 */
219 #define PR_RE_503                 0x00000200 /* Retry if we got a 503 */
220 #define PR_RE_504                 0x00000400 /* Retry if we got a 504 */
221 #define PR_RE_STATUS_MASK         (PR_RE_404 | PR_RE_408 | PR_RE_425 | \
222                                    PR_RE_425 | PR_RE_500 | PR_RE_501 | \
223                                    PR_RE_502 | PR_RE_503 | PR_RE_504)
224 /* 0x00000800, 0x00001000, 0x00002000, 0x00004000 and 0x00008000 unused,
225  * reserved for eventual future status codes
226  */
227 #define PR_RE_EARLY_ERROR         0x00010000 /* Retry if we failed at sending early data */
228 #define PR_RE_JUNK_REQUEST        0x00020000 /* We received an incomplete or garbage response */
229 struct stream;
230 
231 struct http_snapshot {
232 	unsigned int sid;		/* ID of the faulty stream */
233 	unsigned int state;		/* message state before the error (when saved) */
234 	unsigned int b_flags;		/* buffer flags */
235 	unsigned int s_flags;		/* stream flags */
236 
237 	unsigned int t_flags;		/* transaction flags */
238 	unsigned int m_flags;		/* message flags */
239 	unsigned long long m_clen;	/* chunk len for this message */
240 	unsigned long long m_blen;	/* body len for this message */
241 };
242 
243 struct h1_snapshot {
244 	unsigned int state;		/* H1 message state when the error occurred */
245 	unsigned int c_flags;		/* H1 connection flags */
246 	unsigned int s_flags;		/* H1 stream flags */
247 	unsigned int m_flags;		/* H1 message flags */
248 	unsigned long long m_clen;	/* chunk len for this message */
249 	unsigned long long m_blen;	/* body len for this message */
250 };
251 
252 union error_snapshot_ctx {
253 	struct http_snapshot http;
254 	struct h1_snapshot h1;
255 };
256 
257 struct error_snapshot {
258 	/**** common part ****/
259 	struct timeval when;            /* date of this event, (tv_sec == 0) means "never" */
260 	/* @16 */
261 	void (*show)(struct buffer *, const struct error_snapshot *); /* dump function */
262 	unsigned long long buf_ofs;     /* relative position of the buffer's input inside its container */
263 	/* @32 */
264 	unsigned int buf_out;           /* pending output bytes _before_ the buffer's input (0..buf->data-1) */
265 	unsigned int buf_len;           /* original length of the last invalid request/response (0..buf->data-1-buf_out) */
266 	unsigned int buf_err;           /* buffer-relative position where the error was detected (0..len-1) */
267 	unsigned int buf_wrap;          /* buffer-relative position where the buffer is expected to wrap (1..buf_size) */
268 	/* @48 */
269 	struct proxy *oe;               /* other end = frontend or backend involved */
270 	struct server *srv;             /* server associated with the error (or NULL) */
271 	/* @64 */
272 	unsigned int ev_id;             /* event number (counter incremented for each capture) */
273 	/* @68: 4 bytes hole here */
274 	struct sockaddr_storage src;    /* client's address */
275 
276 	/**** protocol-specific part ****/
277 	union error_snapshot_ctx ctx;
278 	char buf[0];                    /* copy of the beginning of the message for bufsize bytes */
279 };
280 
281 struct email_alert {
282 	struct list list;
283 	struct list tcpcheck_rules;
284 	struct server *srv;
285 };
286 
287 struct email_alertq {
288 	struct list email_alerts;
289 	struct check check;		/* Email alerts are implemented using existing check
290 					 * code even though they are not checks. This structure
291 					 * is as a parameter to the check code.
292 					 * Each check corresponds to a mailer */
293 	__decl_hathreads(HA_SPINLOCK_T lock);
294 };
295 
296 struct proxy {
297 	enum obj_type obj_type;                 /* object type == OBJ_TYPE_PROXY */
298 	enum pr_state state;                    /* proxy state, one of PR_* */
299 	enum pr_mode mode;                      /* mode = PR_MODE_TCP, PR_MODE_HTTP or PR_MODE_HEALTH */
300 	char cap;                               /* supported capabilities (PR_CAP_*) */
301 	unsigned int maxconn;                   /* max # of active streams on the frontend */
302 
303 	int options;				/* PR_O_REDISP, PR_O_TRANSP, ... */
304 	int options2;				/* PR_O2_* */
305 	int max_out_conns;                      /* Max number of idling connections we keep for a session */
306 	struct in_addr mon_net, mon_mask;	/* don't forward connections from this net (network order) FIXME: should support IPv6 */
307 	unsigned int ck_opts;			/* PR_CK_* (cookie options) */
308 	unsigned int fe_req_ana, be_req_ana;	/* bitmap of common request protocol analysers for the frontend and backend */
309 	unsigned int fe_rsp_ana, be_rsp_ana;	/* bitmap of common response protocol analysers for the frontend and backend */
310 	unsigned int http_needed;               /* non-null if HTTP analyser may be used */
311 	union {
312 		struct proxy *be;		/* default backend, or NULL if none set */
313 		char *name;			/* default backend name during config parse */
314 	} defbe;
315 	struct list acl;                        /* ACL declared on this proxy */
316 	struct list http_req_rules;		/* HTTP request rules: allow/deny/... */
317 	struct list http_res_rules;		/* HTTP response rules: allow/deny/... */
318 	struct list redirect_rules;             /* content redirecting rules (chained) */
319 	struct list switching_rules;            /* content switching rules (chained) */
320 	struct list persist_rules;		/* 'force-persist' and 'ignore-persist' rules (chained) */
321 	struct list sticking_rules;             /* content sticking rules (chained) */
322 	struct list storersp_rules;             /* content store response rules (chained) */
323 	struct list server_rules;               /* server switching rules (chained) */
324 	struct {                                /* TCP request processing */
325 		unsigned int inspect_delay;     /* inspection delay */
326 		struct list inspect_rules;      /* inspection rules */
327 		struct list l4_rules;           /* layer4 rules */
328 		struct list l5_rules;           /* layer5 rules */
329 	} tcp_req;
330 	struct {                                /* TCP request processing */
331 		unsigned int inspect_delay;     /* inspection delay */
332 		struct list inspect_rules;      /* inspection rules */
333 	} tcp_rep;
334 	struct server *srv, defsrv;		/* known servers; default server configuration */
335 	struct lbprm lbprm;			/* load-balancing parameters */
336 	int srv_act, srv_bck;			/* # of servers eligible for LB (UP|!checked) AND (enabled+weight!=0) */
337 	int served;				/* # of active sessions currently being served */
338 	int  cookie_len;			/* strlen(cookie_name), computed only once */
339 	char *cookie_domain;			/* domain used to insert the cookie */
340 	char *cookie_name;			/* name of the cookie to look for */
341 	char *cookie_attrs;                     /* list of attributes to add to the cookie */
342 	char *dyncookie_key;			/* Secret key used to generate dynamic persistent cookies */
343 	unsigned int cookie_maxidle;		/* max idle time for this cookie */
344 	unsigned int cookie_maxlife;		/* max life time for this cookie */
345 	char *rdp_cookie_name;			/* name of the RDP cookie to look for */
346 	int  rdp_cookie_len;			/* strlen(rdp_cookie_name), computed only once */
347 	char *capture_name;			/* beginning of the name of the cookie to capture */
348 	int  capture_namelen;			/* length of the cookie name to match */
349 	int  capture_len;			/* length of the string to be captured */
350 	struct uri_auth *uri_auth;		/* if non-NULL, the (list of) per-URI authentications */
351 	int max_ka_queue;			/* 1+maximum requests in queue accepted for reusing a K-A conn (0=none) */
352 	int monitor_uri_len;			/* length of the string above. 0 if unused */
353 	char *monitor_uri;			/* a special URI to which we respond with HTTP/200 OK */
354 	struct list mon_fail_cond;              /* list of conditions to fail monitoring requests (chained) */
355 	struct {				/* WARNING! check proxy_reset_timeouts() in proxy.h !!! */
356 		int client;                     /* client I/O timeout (in ticks) */
357 		int tarpit;                     /* tarpit timeout, defaults to connect if unspecified */
358 		int queue;                      /* queue timeout, defaults to connect if unspecified */
359 		int connect;                    /* connect timeout (in ticks) */
360 		int server;                     /* server I/O timeout (in ticks) */
361 		int httpreq;                    /* maximum time for complete HTTP request */
362 		int httpka;                     /* maximum time for a new HTTP request when using keep-alive */
363 		int check;                      /* maximum time for complete check */
364 		int tunnel;                     /* I/O timeout to use in tunnel mode (in ticks) */
365 		int clientfin;                  /* timeout to apply to client half-closed connections */
366 		int serverfin;                  /* timeout to apply to server half-closed connections */
367 	} timeout;
368 	char *id, *desc;			/* proxy id (name) and description */
369 	struct eb_root pendconns;		/* pending connections with no server assigned yet */
370 	int nbpend;				/* number of pending connections with no server assigned yet */
371 	int totpend;				/* total number of pending connections on this instance (for stats) */
372 	unsigned int queue_idx;			/* number of pending connections which have been de-queued */
373 	unsigned int feconn, beconn;		/* # of active frontend and backends streams */
374 	struct freq_ctr fe_req_per_sec;		/* HTTP requests per second on the frontend */
375 	struct freq_ctr fe_conn_per_sec;	/* received connections per second on the frontend */
376 	struct freq_ctr fe_sess_per_sec;	/* accepted sessions per second on the frontend (after tcp rules) */
377 	struct freq_ctr be_sess_per_sec;	/* sessions per second on the backend */
378 	unsigned int fe_sps_lim;		/* limit on new sessions per second on the frontend */
379 	unsigned int fullconn;			/* #conns on backend above which servers are used at full load */
380 	unsigned int tot_fe_maxconn;		/* #maxconn of frontends linked to that backend, it is used to compute fullconn */
381 	struct in_addr except_net, except_mask; /* don't x-forward-for for this address. FIXME: should support IPv6 */
382 	struct in_addr except_to;		/* don't x-original-to for this address. */
383 	struct in_addr except_mask_to;		/* the netmask for except_to. */
384 	char *fwdfor_hdr_name;			/* header to use - default: "x-forwarded-for" */
385 	char *orgto_hdr_name;			/* header to use - default: "x-original-to" */
386 	int fwdfor_hdr_len;			/* length of "x-forwarded-for" header */
387 	int orgto_hdr_len;			/* length of "x-original-to" header */
388 	char *server_id_hdr_name;                   /* the header to use to send the server id (name) */
389 	int server_id_hdr_len;                      /* the length of the id (name) header... name */
390 	int conn_retries;			/* maximum number of connect retries */
391 	unsigned int retry_type;                /* Type of retry allowed */
392 	int redispatch_after;			/* number of retries before redispatch */
393 	unsigned down_trans;			/* up-down transitions */
394 	unsigned down_time;			/* total time the proxy was down */
395 	unsigned int log_count;			/* number of logs produced by the frontend */
396 	time_t last_change;			/* last time, when the state was changed */
397 	int (*accept)(struct stream *s);       /* application layer's accept() */
398 	struct conn_src conn_src;               /* connection source settings */
399 	enum obj_type *default_target;		/* default target to use for accepted streams or NULL */
400 	struct proxy *next;
401 	struct proxy *next_stkt_ref;    /* Link to the list of proxies which refer to the same stick-table. */
402 
403 	struct list logsrvs;
404 	struct list logformat; 			/* log_format linked list */
405 	struct list logformat_sd;		/* log_format linked list for the RFC5424 structured-data part */
406 	struct buffer log_tag;                   /* override default syslog tag */
407 	char *header_unique_id; 		/* unique-id header */
408 	struct list format_unique_id;		/* unique-id format */
409 	int to_log;				/* things to be logged (LW_*) */
410 	int stop_time;                          /* date to stop listening, when stopping != 0 (int ticks) */
411 	int nb_req_cap, nb_rsp_cap;		/* # of headers to be captured */
412 	struct cap_hdr *req_cap;		/* chained list of request headers to be captured */
413 	struct cap_hdr *rsp_cap;		/* chained list of response headers to be captured */
414 	struct pool_head *req_cap_pool,		/* pools of pre-allocated char ** used to build the streams */
415 	                 *rsp_cap_pool;
416 	struct be_counters be_counters;		/* backend statistics counters */
417 	struct fe_counters fe_counters;		/* frontend statistics counters */
418 
419 	struct mt_list listener_queue;		/* list of the temporarily limited listeners because of lack of a proxy resource */
420 	struct stktable *table;			/* table for storing sticking streams */
421 
422 	struct task *task;			/* the associated task, mandatory to manage rate limiting, stopping and resource shortage, NULL if disabled */
423 	struct list tcpcheck_rules;		/* tcp-check send / expect rules */
424 	int grace;				/* grace time after stop request */
425 	int check_len;				/* Length of the HTTP or SSL3 request */
426 	char *check_req;			/* HTTP or SSL request to use for PR_O_HTTP_CHK|PR_O_SSL3_CHK */
427 	char *check_command;			/* Command to use for external agent checks */
428 	char *check_path;			/* PATH environment to use for external agent checks */
429 	char *expect_str;			/* http-check expected content : string or text version of the regex */
430 	struct my_regex *expect_regex;		/* http-check expected content */
431 	struct buffer errmsg[HTTP_ERR_SIZE];	/* default or customized error messages for known errors */
432 	int uuid;				/* universally unique proxy ID, used for SNMP */
433 	unsigned int backlog;			/* force the frontend's listen backlog */
434 	unsigned long bind_proc;		/* bitmask of processes using this proxy */
435 
436 	/* warning: these structs are huge, keep them at the bottom */
437 	struct sockaddr_storage dispatch_addr;	/* the default address to connect to */
438 	struct error_snapshot *invalid_req, *invalid_rep; /* captures of last errors */
439 
440 	/* used only during configuration parsing */
441 	int no_options;				/* PR_O_REDISP, PR_O_TRANSP, ... */
442 	int no_options2;			/* PR_O2_* */
443 
444 	struct {
445 		char *file;			/* file where the section appears */
446 		struct eb32_node id;		/* place in the tree of used IDs */
447 		int line;			/* line where the section appears */
448 		struct eb_root used_listener_id;/* list of listener IDs in use */
449 		struct eb_root used_server_id;	/* list of server IDs in use */
450 		struct eb_root used_server_name; /* list of server names in use */
451 		struct list bind;		/* list of bind settings */
452 		struct list listeners;		/* list of listeners belonging to this frontend */
453 		struct arg_list args;           /* sample arg list that need to be resolved */
454 		struct ebpt_node by_name;       /* proxies are stored sorted by name here */
455 		char *logformat_string;		/* log format string */
456 		char *lfs_file;                 /* file name where the logformat string appears (strdup) */
457 		int   lfs_line;                 /* file name where the logformat string appears */
458 		int   uif_line;                 /* file name where the unique-id-format string appears */
459 		char *uif_file;                 /* file name where the unique-id-format string appears (strdup) */
460 		char *uniqueid_format_string;	/* unique-id format string */
461 		char *logformat_sd_string;	/* log format string for the RFC5424 structured-data part */
462 		char *lfsd_file;		/* file name where the structured-data logformat string for RFC5424 appears (strdup) */
463 		int  lfsd_line;			/* file name where the structured-data logformat string for RFC5424 appears */
464 	} conf;					/* config information */
465 	void *parent;				/* parent of the proxy when applicable */
466 	struct comp *comp;			/* http compression */
467 
468 	struct {
469 		union {
470 			struct mailers *m;	/* Mailer to send email alerts via */
471 			char *name;
472 		} mailers;
473 		char *from;			/* Address to send email alerts from */
474 		char *to;			/* Address(es) to send email alerts to */
475 		char *myhostname;		/* Identity to use in HELO command sent to mailer */
476 		int level;			/* Maximum syslog level of messages to send
477 						 * email alerts for */
478 		int set;			/* True if email_alert settings are present */
479 		struct email_alertq *queues;	/* per-mailer alerts queues */
480 	} email_alert;
481 
482 	int load_server_state_from_file;	/* location of the file containing server state.
483 						 * flag PR_SRV_STATE_FILE_* */
484 	char *server_state_file_name;		/* used when load_server_state_from_file is set to
485 						 * PR_SRV_STATE_FILE_LOCAL. Give a specific file name for
486 						 * this backend. If not specified or void, then the backend
487 						 * name is used
488 						 */
489 	struct list filter_configs;		/* list of the filters that are declared on this proxy */
490 	struct {
491 		int mode;
492 		struct list rules;              /* nuster rules */
493 	} nuster;
494 	__decl_hathreads(HA_SPINLOCK_T lock);   /* may be taken under the server's lock */
495 };
496 
497 struct switching_rule {
498 	struct list list;			/* list linked to from the proxy */
499 	struct acl_cond *cond;			/* acl condition to meet */
500 	int dynamic;				/* this is a dynamic rule using the logformat expression */
501 	union {
502 		struct proxy *backend;		/* target backend */
503 		char *name;			/* target backend name during config parsing */
504 		struct list expr;		/* logformat expression to use for dynamic rules */
505 	} be;
506 	char *file;
507 	int line;
508 };
509 
510 struct server_rule {
511 	struct list list;			/* list linked to from the proxy */
512 	struct acl_cond *cond;			/* acl condition to meet */
513 	union {
514 		struct server *ptr;		/* target server */
515 		char *name;			/* target server name during config parsing */
516 	} srv;
517 };
518 
519 struct persist_rule {
520 	struct list list;			/* list linked to from the proxy */
521 	struct acl_cond *cond;			/* acl condition to meet */
522 	int type;
523 };
524 
525 struct sticking_rule {
526 	struct list list;                       /* list linked to from the proxy */
527 	struct acl_cond *cond;                  /* acl condition to meet */
528 	struct sample_expr *expr;               /* fetch expr to fetch key */
529 	int flags;                              /* STK_* */
530 	union {
531 		struct stktable *t;	        /* target table */
532 		char *name;                     /* target table name during config parsing */
533 	} table;
534 };
535 
536 
537 struct redirect_rule {
538 	struct list list;                       /* list linked to from the proxy */
539 	struct acl_cond *cond;                  /* acl condition to meet */
540 	int type;
541 	int rdr_len;
542 	char *rdr_str;
543 	struct list rdr_fmt;
544 	int code;
545 	unsigned int flags;
546 	int cookie_len;
547 	char *cookie_str;
548 };
549 
550 /* some of the most common options which are also the easiest to handle */
551 struct cfg_opt {
552 	const char *name;
553 	unsigned int val;
554 	unsigned int cap;
555 	unsigned int checks;
556 	unsigned int mode;
557 };
558 
559 #endif /* _TYPES_PROXY_H */
560 
561 /*
562  * Local variables:
563  *  c-indent-level: 8
564  *  c-basic-offset: 8
565  * End:
566  */
567