blob: 48582e6138f95b1a9bd7253c43ba2f0f71e1c9c1 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
Willy Tarreau5ab04ec2011-03-20 10:32:26 +01002 * include/types/server.h
3 * This file defines everything related to servers.
4 *
Willy Tarreauf09c6602012-02-13 17:12:08 +01005 * Copyright (C) 2000-2012 Willy Tarreau - w@1wt.eu
Willy Tarreau5ab04ec2011-03-20 10:32:26 +01006 *
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 */
Willy Tarreaubaaee002006-06-26 02:48:02 +020021
22#ifndef _TYPES_SERVER_H
23#define _TYPES_SERVER_H
24
25#include <netinet/in.h>
26#include <arpa/inet.h>
27
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020028#include <common/config.h>
Willy Tarreau2dd0d472006-06-29 17:53:05 +020029#include <common/mini-clist.h>
Christopher Faulet29f77e82017-06-08 14:04:45 +020030#include <common/hathreads.h>
Willy Tarreauc125cef2019-05-10 09:58:43 +020031#include <common/openssl-compat.h>
Christopher Faulet29f77e82017-06-08 14:04:45 +020032
Willy Tarreau45cb4fb2009-10-26 21:10:04 +010033#include <eb32tree.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020034
Willy Tarreauda92e2f2012-07-06 09:40:59 +020035#include <types/connection.h>
Krzysztof Piotr Oledzki052d4fd2009-10-04 14:52:57 +020036#include <types/counters.h>
Thierry Fournierada34842016-02-17 21:25:09 +010037#include <types/dns.h>
Willy Tarreau7f062c42009-03-05 18:43:00 +010038#include <types/freq_ctr.h>
Willy Tarreau3fdb3662012-11-12 00:42:33 +010039#include <types/obj_type.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020040#include <types/proxy.h>
41#include <types/queue.h>
Willy Tarreauc125cef2019-05-10 09:58:43 +020042#include <types/ssl_sock.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020043#include <types/task.h>
Krzysztof Piotr Oledzki09605412009-09-23 22:09:24 +020044#include <types/checks.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020045
46
Godbachf2dd68d2014-12-10 10:21:30 +080047/* server states. Only SRV_ST_STOPPED indicates a down server. */
Willy Tarreauc93cd162014-05-13 15:54:22 +020048enum srv_state {
Willy Tarreau892337c2014-05-13 23:41:20 +020049 SRV_ST_STOPPED = 0, /* the server is down. Please keep set to zero. */
50 SRV_ST_STARTING, /* the server is warming up (up but throttled) */
51 SRV_ST_RUNNING, /* the server is fully up */
52 SRV_ST_STOPPING, /* the server is up but soft-stopping (eg: 404) */
Willy Tarreaud7e33bb2017-11-26 07:26:48 +010053} __attribute__((packed));
Willy Tarreauc93cd162014-05-13 15:54:22 +020054
Willy Tarreaubfc7b7a2014-05-22 16:14:34 +020055/* Administrative status : a server runs in one of these 3 stats :
56 * - READY : normal mode
57 * - DRAIN : takes no new visitor, equivalent to weight == 0
58 * - MAINT : maintenance mode, no more traffic nor health checks.
59 *
60 * Each server may be in maintenance by itself or may inherit this status from
61 * another server it tracks. It can also be in drain mode by itself or inherit
62 * it from another server. Let's store these origins here as flags. These flags
63 * are combined this way :
64 *
65 * FMAINT IMAINT FDRAIN IDRAIN Resulting state
66 * 0 0 0 0 READY
67 * 0 0 0 1 DRAIN
68 * 0 0 1 x DRAIN
69 * 0 1 x x MAINT
70 * 1 x x x MAINT
71 *
72 * This can be simplified this way :
73 *
74 * state_str = (state & MAINT) ? "MAINT" : (state & DRAIN) : "DRAIN" : "READY"
Willy Tarreau20125212014-05-13 19:44:56 +020075 */
76enum srv_admin {
Baptiste Assmann9f5ada32015-08-08 15:49:13 +020077 SRV_ADMF_FMAINT = 0x01, /* the server was explicitly forced into maintenance */
78 SRV_ADMF_IMAINT = 0x02, /* the server has inherited the maintenance status from a tracked server */
Baptiste Assmann89aa7f32016-11-02 21:31:27 +010079 SRV_ADMF_MAINT = 0x23, /* mask to check if any maintenance flag is present */
Baptiste Assmann9f5ada32015-08-08 15:49:13 +020080 SRV_ADMF_CMAINT = 0x04, /* the server is in maintenance because of the configuration */
Baptiste Assmann9f5ada32015-08-08 15:49:13 +020081 SRV_ADMF_FDRAIN = 0x08, /* the server was explicitly forced into drain state */
82 SRV_ADMF_IDRAIN = 0x10, /* the server has inherited the drain status from a tracked server */
83 SRV_ADMF_DRAIN = 0x18, /* mask to check if any drain flag is present */
Baptiste Assmann89aa7f32016-11-02 21:31:27 +010084 SRV_ADMF_RMAINT = 0x20, /* the server is down because of an IP address resolution failure */
Frédéric Lécailleb418c122017-04-26 11:24:02 +020085 SRV_ADMF_HMAINT = 0x40, /* the server FQDN has been set from socket stats */
Willy Tarreaud7e33bb2017-11-26 07:26:48 +010086} __attribute__((packed));
Willy Tarreau20125212014-05-13 19:44:56 +020087
Baptiste Assmann25938272016-09-21 20:26:16 +020088/* options for servers' "init-addr" parameter
89 * this parameter may be used to drive HAProxy's behavior when parsing a server
90 * address at start up time.
91 * These values are stored as a list into an integer ordered from first to last
92 * starting with the lowest to highest bits. SRV_IADDR_END (0) is used to
93 * indicate the end of the list. 3 bits are enough to store each value.
94 */
95enum srv_initaddr {
96 SRV_IADDR_END = 0, /* end of the list */
97 SRV_IADDR_NONE = 1, /* the server won't have any address at start up */
98 SRV_IADDR_LIBC = 2, /* address set using the libc DNS resolver */
99 SRV_IADDR_LAST = 3, /* we set the IP address found in state-file for this server */
Willy Tarreau4310d362016-11-02 15:05:56 +0100100 SRV_IADDR_IP = 4, /* we set an arbitrary IP address to the server */
Willy Tarreaud7e33bb2017-11-26 07:26:48 +0100101} __attribute__((packed));
Baptiste Assmann25938272016-09-21 20:26:16 +0200102
Baptiste Assmann41472f42015-05-08 23:34:06 +0200103/* server-state-file version */
104#define SRV_STATE_FILE_VERSION 1
105#define SRV_STATE_FILE_VERSION_MIN 1
106#define SRV_STATE_FILE_VERSION_MAX 1
Frédéric Lécailleb418c122017-04-26 11:24:02 +0200107#define SRV_STATE_FILE_FIELD_NAMES \
108 "be_id " \
109 "be_name " \
110 "srv_id " \
111 "srv_name " \
112 "srv_addr " \
113 "srv_op_state " \
114 "srv_admin_state " \
115 "srv_uweight " \
116 "srv_iweight " \
117 "srv_time_since_last_change " \
118 "srv_check_status " \
119 "srv_check_result " \
120 "srv_check_health " \
121 "srv_check_state " \
122 "srv_agent_state " \
123 "bk_f_forced_id " \
124 "srv_f_forced_id " \
Frédéric Lécaille31694712017-08-01 08:47:19 +0200125 "srv_fqdn " \
Baptiste Assmann6d0f38f2018-07-02 17:00:54 +0200126 "srv_port " \
127 "srvrecord"
Frédéric Lécailleb418c122017-04-26 11:24:02 +0200128
Baptiste Assmann6d0f38f2018-07-02 17:00:54 +0200129#define SRV_STATE_FILE_MAX_FIELDS 20
130#define SRV_STATE_FILE_NB_FIELDS_VERSION_1 19
Baptiste Assmann41472f42015-05-08 23:34:06 +0200131#define SRV_STATE_LINE_MAXLEN 512
132
Willy Tarreauc0752562017-01-23 21:38:57 +0100133/* server flags -- 32 bits */
Willy Tarreauc93cd162014-05-13 15:54:22 +0200134#define SRV_F_BACKUP 0x0001 /* this server is a backup server */
135#define SRV_F_MAPPORTS 0x0002 /* this server uses mapped ports */
136#define SRV_F_NON_STICK 0x0004 /* never add connections allocated to this server to a stick table */
KOVACS Krisztianb3e54fe2014-11-17 15:11:45 +0100137#define SRV_F_USE_NS_FROM_PP 0x0008 /* use namespace associated with connection if present */
Baptiste Assmann7cc419a2015-07-07 22:02:20 +0200138#define SRV_F_FORCED_ID 0x0010 /* server's ID was forced in the configuration */
Baptiste Assmann6b453f12016-08-11 23:12:18 +0200139#define SRV_F_CHECKADDR 0x0020 /* this server has a check addr configured */
140#define SRV_F_CHECKPORT 0x0040 /* this server has a check port configured */
141#define SRV_F_AGENTADDR 0x0080 /* this server has a agent addr configured */
Olivier Houchard4e694042017-03-14 20:01:29 +0100142#define SRV_F_COOKIESET 0x0100 /* this server has a cookie configured, so don't generate dynamic cookies */
Olivier Houchard92e38e22019-05-08 19:48:32 +0200143#define SRV_F_FASTOPEN 0x0200 /* Use TCP Fast Open to connect to server */
Alexander Liu2a54bb72019-05-22 19:44:48 +0800144#define SRV_F_SOCKS4_PROXY 0x0400 /* this server uses SOCKS4 proxy */
Baptiste Assmann13a92322019-06-07 09:40:55 +0200145#define SRV_F_NO_RESOLUTION 0x0800 /* disable runtime DNS resolution on this server */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200146
David Safb76832014-05-08 23:42:08 -0400147/* configured server options for send-proxy (server->pp_opts) */
Emmanuel Hocdetfa8d0f12018-02-01 15:53:52 +0100148#define SRV_PP_V1 0x0001 /* proxy protocol version 1 */
149#define SRV_PP_V2 0x0002 /* proxy protocol version 2 */
150#define SRV_PP_V2_SSL 0x0004 /* proxy protocol version 2 with SSL */
151#define SRV_PP_V2_SSL_CN 0x0008 /* proxy protocol version 2 with CN */
152#define SRV_PP_V2_SSL_KEY_ALG 0x0010 /* proxy protocol version 2 with cert key algorithm */
153#define SRV_PP_V2_SSL_SIG_ALG 0x0020 /* proxy protocol version 2 with cert signature algorithm */
154#define SRV_PP_V2_SSL_CIPHER 0x0040 /* proxy protocol version 2 with cipher used */
Emmanuel Hocdet253c3b72018-02-01 18:29:59 +0100155#define SRV_PP_V2_AUTHORITY 0x0080 /* proxy protocol version 2 with authority */
Emmanuel Hocdet4399c752018-02-05 15:26:43 +0100156#define SRV_PP_V2_CRC32C 0x0100 /* proxy protocol version 2 with crc32c */
Tim Duesterhuscf6e0c82020-03-13 12:34:24 +0100157#define SRV_PP_V2_UNIQUE_ID 0x0200 /* proxy protocol version 2 with unique ID */
David Safb76832014-05-08 23:42:08 -0400158
Willy Tarreaubaaee002006-06-26 02:48:02 +0200159/* function which act on servers need to return various errors */
160#define SRV_STATUS_OK 0 /* everything is OK. */
161#define SRV_STATUS_INTERNAL 1 /* other unrecoverable errors. */
162#define SRV_STATUS_NOSRV 2 /* no server is available */
163#define SRV_STATUS_FULL 3 /* the/all server(s) are saturated */
164#define SRV_STATUS_QUEUED 4 /* the/all server(s) are saturated but the connection was queued */
165
Willy Tarreaub698f0f2007-12-02 11:01:23 +0100166/* various constants */
167#define SRV_UWGHT_RANGE 256
Godbacha34bdc02013-07-22 07:44:53 +0800168#define SRV_UWGHT_MAX (SRV_UWGHT_RANGE)
Willy Tarreaub698f0f2007-12-02 11:01:23 +0100169#define SRV_EWGHT_RANGE (SRV_UWGHT_RANGE * BE_WEIGHT_SCALE)
170#define SRV_EWGHT_MAX (SRV_UWGHT_MAX * BE_WEIGHT_SCALE)
171
Emeric Brun89675492012-10-05 13:48:26 +0200172#ifdef USE_OPENSSL
173/* server ssl options */
174#define SRV_SSL_O_NONE 0x0000
Emeric Brunf9c5c472012-10-11 15:28:34 +0200175#define SRV_SSL_O_NO_TLS_TICKETS 0x0100 /* disable session resumption tickets */
Willy Tarreau2a3fb1c2015-02-05 16:47:07 +0100176#define SRV_SSL_O_NO_REUSE 0x200 /* disable session reuse */
Olivier Houchard522eea72017-11-03 16:27:47 +0100177#define SRV_SSL_O_EARLY_DATA 0x400 /* Allow using early data */
Emeric Brun89675492012-10-05 13:48:26 +0200178#endif
179
Frédéric Lécaille7da71292019-05-20 09:47:07 +0200180/* The server names dictionary */
181extern struct dict server_name_dict;
182
Simon Horman98637e52014-06-20 12:30:16 +0900183struct pid_list {
184 struct list list;
185 pid_t pid;
186 struct task *t;
187 int status;
188 int exited;
189};
190
Willy Tarreau6b2e11b2009-10-01 07:52:15 +0200191/* A tree occurrence is a descriptor of a place in a tree, with a pointer back
192 * to the server itself.
193 */
194struct server;
195struct tree_occ {
196 struct server *server;
197 struct eb32_node node;
198};
199
Willy Tarreaubaaee002006-06-26 02:48:02 +0200200struct server {
Willy Tarreau3fdb3662012-11-12 00:42:33 +0100201 enum obj_type obj_type; /* object type == OBJ_TYPE_SERVER */
Emeric Brun52a91d32017-08-31 14:41:55 +0200202 enum srv_state next_state, cur_state; /* server state among SRV_ST_* */
203 enum srv_admin next_admin, cur_admin; /* server maintenance status : SRV_ADMF_* */
Emmanuel Hocdet49529852018-03-19 18:14:02 +0100204 unsigned char use_ssl; /* ssl enabled */
Emmanuel Hocdet4399c752018-02-05 15:26:43 +0100205 unsigned int pp_opts; /* proxy protocol options (SRV_PP_*) */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200206 struct server *next;
Krzysztof Piotr Oledzki09605412009-09-23 22:09:24 +0200207 int cklen; /* the len of the cookie, to speed up checks */
Willy Tarreau21d2af32008-02-14 20:25:24 +0100208 int rdr_len; /* the length of the redirection prefix */
Willy Tarreau91b6f322007-03-25 21:03:01 +0200209 char *cookie; /* the id set in the cookie */
Willy Tarreau21d2af32008-02-14 20:25:24 +0100210 char *rdr_pfx; /* the redirection prefix */
Willy Tarreau91b6f322007-03-25 21:03:01 +0200211
212 struct proxy *proxy; /* the proxy this server belongs to */
Willy Tarreau3fbea1d2018-12-02 13:08:34 +0100213 const struct mux_proto_list *mux_proto; /* the mux to use for all outgoing connections (specified by the "proto" keyword) */
Willy Tarreau7c669d72008-06-20 15:04:11 +0200214 int served; /* # of active sessions currently being served (ie not pending) */
Willy Tarreauac68c5d2009-10-04 23:12:44 +0200215 int cur_sess; /* number of currently active sessions (including syn_sent) */
Willy Tarreau91b6f322007-03-25 21:03:01 +0200216 unsigned maxconn, minconn; /* max # of active sessions (0 = unlimited), min# for dynamic limit. */
Willy Tarreauac68c5d2009-10-04 23:12:44 +0200217 int nbpend; /* number of pending connections */
Patrick Hemmerda282f42018-05-11 12:52:31 -0400218 unsigned int queue_idx; /* count of pending connections which have been de-queued */
Elijah Epifanovacafc5f2007-10-25 20:15:38 +0200219 int maxqueue; /* maximum number of pending connections allowed */
Willy Tarreau7b815632011-10-21 18:51:57 +0200220 struct freq_ctr sess_per_sec; /* sessions per second on this server */
Willy Tarreauae9bea02016-11-25 14:44:52 +0100221 struct be_counters counters; /* statistics counters */
Willy Tarreauac68c5d2009-10-04 23:12:44 +0200222
Patrick Hemmer0355dab2018-05-11 12:52:31 -0400223 struct eb_root pendconns; /* pending connections */
Simon Hormanaf514952011-06-21 14:34:57 +0900224 struct list actconns; /* active connections */
Ilya Shipitsind4259502020-04-08 01:07:56 +0500225 struct mt_list *idle_conns; /* shareable idle connections*/
Olivier Houcharddc2f2752020-02-13 19:12:07 +0100226 struct mt_list *safe_conns; /* safe idle connections */
227 struct list *available_conns; /* Connection in used, but with still new streams available */
Olivier Houchardb7b3faa2018-12-14 18:15:36 +0100228 unsigned int pool_purge_delay; /* Delay before starting to purge the idle conns pool */
Olivier Houchard006e3102018-12-10 18:30:32 +0100229 unsigned int max_idle_conns; /* Max number of connection allowed in the orphan connections list */
Olivier Houchard566df302020-03-06 18:18:56 +0100230 unsigned int curr_idle_conns; /* Current number of orphan idling connections, both the idle and the safe lists */
231 unsigned int curr_idle_nb; /* Current number of connections in the idle list */
232 unsigned int curr_safe_nb; /* Current number of connections in the safe list */
Olivier Houchardcf612a02020-03-25 19:41:03 +0100233 unsigned int curr_used_conns; /* Current number of used connections */
Ilya Shipitsind4259502020-04-08 01:07:56 +0500234 unsigned int max_used_conns; /* Max number of used connections (the counter is reset at each connection purges */
Olivier Houchardf1314812019-02-18 16:41:17 +0100235 unsigned int *curr_idle_thr; /* Current number of orphan idling connections per thread */
Willy Tarreau9c538e02019-01-23 10:21:49 +0100236 int max_reuse; /* Max number of requests on a same connection */
Olivier Houchard9ea5d362019-02-14 18:29:09 +0100237 struct eb32_node idle_node; /* When to next do cleanup in the idle connections */
Willy Tarreau2e993902011-10-31 11:53:20 +0100238 struct task *warmup; /* the task dedicated to the warmup when slowstart is set */
Willy Tarreau91b6f322007-03-25 21:03:01 +0200239
Willy Tarreauef9a3602012-12-08 22:29:20 +0100240 struct conn_src conn_src; /* connection source settings */
Willy Tarreau91b6f322007-03-25 21:03:01 +0200241
Willy Tarreau1a53a3a2013-12-11 15:27:05 +0100242 struct server *track; /* the server we're currently tracking, if any */
243 struct server *trackers; /* the list of servers tracking us, if any */
244 struct server *tracknext; /* next server tracking <track> in <track>'s trackers list */
Krzysztof Piotr Oledzkic8b16fc2008-02-18 01:26:35 +0100245 char *trackit; /* temporary variable to make assignment deferrable */
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +0100246 int consecutive_errors; /* current number of consecutive errors */
Krzysztof Piotr Oledzki97f07b82009-12-15 22:31:24 +0100247 int consecutive_errors_limit; /* number of consecutive errors that triggers an event */
248 short observe, onerror; /* observing mode: one of HANA_OBS_*; what to do on error: on of ANA_ONERR_* */
Justin Karnegeseb2c24a2012-05-24 15:28:52 -0700249 short onmarkeddown; /* what to do when marked down: one of HANA_ONMARKEDDOWN_* */
250 short onmarkedup; /* what to do when marked up: one of HANA_ONMARKEDUP_* */
Willy Tarreaud7e33bb2017-11-26 07:26:48 +0100251 unsigned int flags; /* server flags (SRV_F_*) */
Willy Tarreau9909fc12007-11-30 17:42:05 +0100252 int slowstart; /* slowstart time in seconds (ms in the conf) */
Willy Tarreau91b6f322007-03-25 21:03:01 +0200253
254 char *id; /* just for identification */
Emeric Brun52a91d32017-08-31 14:41:55 +0200255 unsigned iweight,uweight, cur_eweight; /* initial weight, user-specified weight, and effective weight */
Willy Tarreau417fae02007-03-25 21:16:40 +0200256 unsigned wscore; /* weight score, used during srv map computation */
Emeric Brun52a91d32017-08-31 14:41:55 +0200257 unsigned next_eweight; /* next pending eweight to commit */
Willy Tarreaub625a082007-11-26 01:15:43 +0100258 unsigned rweight; /* remainer of weight in the current LB tree */
Andrew Rodland13d5ebb2016-10-25 12:49:45 -0400259 unsigned cumulative_weight; /* weight of servers prior to this one in the same group, for chash balancing */
Willy Tarreaub625a082007-11-26 01:15:43 +0100260 unsigned npos, lpos; /* next and last positions in the LB tree */
261 struct eb32_node lb_node; /* node used for tree-based load balancing */
262 struct eb_root *lb_tree; /* we want to know in what tree the server is */
263 struct server *next_full; /* next server in the temporary full list */
Willy Tarreau6b2e11b2009-10-01 07:52:15 +0200264 unsigned lb_nodes_tot; /* number of allocated lb_nodes (C-HASH) */
265 unsigned lb_nodes_now; /* number of lb_nodes placed in the tree (C-HASH) */
266 struct tree_occ *lb_nodes; /* lb_nodes_tot * struct tree_occ */
Willy Tarreau91b6f322007-03-25 21:03:01 +0200267
KOVACS Krisztianb3e54fe2014-11-17 15:11:45 +0100268 const struct netns_entry *netns; /* contains network namespace name or NULL. Network namespace comes from configuration */
Willy Tarreau7b815632011-10-21 18:51:57 +0200269 /* warning, these structs are huge, keep them at the bottom */
Willy Tarreau04276f32017-01-06 17:41:29 +0100270 struct sockaddr_storage addr; /* the address to connect to, doesn't include the port */
Willy Tarreauf7bc57c2012-10-03 00:19:48 +0200271 struct xprt_ops *xprt; /* transport-layer operations */
Willy Tarreaud7e33bb2017-11-26 07:26:48 +0100272 unsigned int svc_port; /* the port to connect to (for relevant families) */
Krzysztof Oledzki85130942007-10-22 16:21:10 +0200273 unsigned down_time; /* total time the server was down */
274 time_t last_change; /* last time, when the state was changed */
275
Willy Tarreauf09c6602012-02-13 17:12:08 +0100276 int puid; /* proxy-unique server ID, used for SNMP, and "first" LB algo */
Willy Tarreau163d4622015-10-13 16:16:41 +0200277 int tcp_ut; /* for TCP, user timeout */
Krzysztof Piotr Oledzki052d4fd2009-10-04 14:52:57 +0200278
Frédéric Lécaille65aa3562017-03-14 11:20:13 +0100279 int do_check; /* temporary variable used during parsing to denote if health checks must be enabled */
Frédéric Lécaille6e0843c2017-03-21 16:39:15 +0100280 int do_agent; /* temporary variable used during parsing to denote if an auxiliary agent check must be enabled */
Simon Horman66183002013-02-23 10:16:43 +0900281 struct check check; /* health-check specific configuration */
Simon Hormand60d6912013-11-25 10:46:36 +0900282 struct check agent; /* agent specific configuration */
Nick Chalk57b1bf72010-03-16 15:50:46 +0000283
Baptiste Assmann201c07f2017-05-22 15:17:15 +0200284 struct dns_requester *dns_requester; /* used to link a server to its DNS resolution */
Baptiste Assmanna68ca962015-04-14 01:15:08 +0200285 char *resolvers_id; /* resolvers section used by this server */
Baptiste Assmann42746372017-05-03 12:12:02 +0200286 struct dns_resolvers *resolvers; /* pointer to the resolvers structure used by this server */
Baptiste Assmann83cbaa52016-11-02 15:34:05 +0100287 char *lastaddr; /* the address string provided by the server-state file */
Thierry Fournierada34842016-02-17 21:25:09 +0100288 struct dns_options dns_opts;
Joseph Herlant44466822018-11-15 08:57:51 -0800289 int hostname_dn_len; /* sting length of the server hostname in Domain Name format */
Willy Tarreaud7e33bb2017-11-26 07:26:48 +0100290 char *hostname_dn; /* server hostname in Domain Name format */
291 char *hostname; /* server hostname */
Willy Tarreau4310d362016-11-02 15:05:56 +0100292 struct sockaddr_storage init_addr; /* plain IP address specified on the init-addr line */
Baptiste Assmann25938272016-09-21 20:26:16 +0200293 unsigned int init_addr_methods; /* initial address setting, 3-bit per method, ends at 0, enough to store 10 entries */
Baptiste Assmanna68ca962015-04-14 01:15:08 +0200294
Emeric Brunc6545ac2012-05-18 15:46:21 +0200295#ifdef USE_OPENSSL
Frédéric Lécaille9a146de2017-03-20 14:54:41 +0100296 char *sni_expr; /* Temporary variable to store a sample expression for SNI */
Emeric Brunc6545ac2012-05-18 15:46:21 +0200297 struct {
298 SSL_CTX *ctx;
Olivier Houcharde6060c52017-11-16 17:42:52 +0100299 struct {
300 unsigned char *ptr;
301 int size;
302 int allocated_size;
303 } * reused_sess;
Willy Tarreaud7aacbf2012-09-03 23:34:19 +0200304 char *ciphers; /* cipher suite to use if non-null */
Willy Tarreau9a1ab082019-05-09 13:26:41 +0200305#if (HA_OPENSSL_VERSION_NUMBER >= 0x10101000L && !defined OPENSSL_IS_BORINGSSL && !defined LIBRESSL_VERSION_NUMBER)
Dirkjan Bussink415150f2018-09-14 11:14:21 +0200306 char *ciphersuites; /* TLS 1.3 cipher suite to use if non-null */
307#endif
Emeric Brun89675492012-10-05 13:48:26 +0200308 int options; /* ssl options */
Emeric Brunef42d922012-10-11 16:11:36 +0200309 int verify; /* verify method (set of SSL_VERIFY_* flags) */
Willy Tarreaud7e33bb2017-11-26 07:26:48 +0100310 struct tls_version_filter methods; /* ssl methods */
Evan Broderbe554312013-06-27 00:05:25 -0700311 char *verify_host; /* hostname of certificate must match this host */
Emeric Brunef42d922012-10-11 16:11:36 +0200312 char *ca_file; /* CAfile to use on verify */
313 char *crl_file; /* CRLfile to use on verify */
Emeric Bruna7aa3092012-10-26 12:58:00 +0200314 char *client_crt; /* client certificate to send */
Willy Tarreau732eac42015-07-09 11:40:25 +0200315 struct sample_expr *sni; /* sample expression for SNI */
Olivier Houchardc7566002018-11-20 23:33:50 +0100316#ifdef OPENSSL_NPN_NEGOTIATED
317 char *npn_str; /* NPN protocol string */
318 int npn_len; /* NPN protocol string length */
319#endif
320#ifdef TLSEXT_TYPE_application_layer_protocol_negotiation
321 char *alpn_str; /* ALPN protocol string */
322 int alpn_len; /* ALPN protocol string length */
323#endif
Emeric Brunc6545ac2012-05-18 15:46:21 +0200324 } ssl_ctx;
325#endif
Willy Tarreaud7e33bb2017-11-26 07:26:48 +0100326 struct dns_srvrq *srvrq; /* Pointer representing the DNS SRV requeest, if any */
Willy Tarreau5e83d992019-07-30 11:59:34 +0200327 __decl_hathreads(HA_SPINLOCK_T lock); /* may enclose the proxy's lock, must not be taken under */
Willy Tarreau90a570f2009-10-04 20:54:54 +0200328 struct {
329 const char *file; /* file where the section appears */
Willy Tarreau53fb4ae2009-10-04 23:04:08 +0200330 struct eb32_node id; /* place in the tree of used IDs */
Frédéric Lécaille84d60462019-05-17 14:29:15 +0200331 struct ebpt_node name; /* place in the tree of used names */
Willy Tarreaud7e33bb2017-11-26 07:26:48 +0100332 int line; /* line where the section appears */
Willy Tarreau90a570f2009-10-04 20:54:54 +0200333 } conf; /* config information */
Frédéric Lécailleb82f7422017-04-13 18:24:23 +0200334 /* Template information used only for server objects which
335 * serve as template filled at parsing time and used during
336 * server allocations from server templates.
337 */
338 struct {
339 char *prefix;
340 int nb_low;
341 int nb_high;
342 } tmpl_info;
Emeric Brun5a133512017-10-19 14:42:30 +0200343 struct {
Emeric Brun5a133512017-10-19 14:42:30 +0200344 long duration;
Willy Tarreaud7e33bb2017-11-26 07:26:48 +0100345 short status, code;
346 char reason[128];
Emeric Brun5a133512017-10-19 14:42:30 +0200347 } op_st_chg; /* operational status change's reason */
Joseph Herlant44466822018-11-15 08:57:51 -0800348 char adm_st_chg_cause[48]; /* administrative status change's cause */
Alexander Liu2a54bb72019-05-22 19:44:48 +0800349
350 struct sockaddr_storage socks4_addr; /* the address of the SOCKS4 Proxy, including the port */
Willy Tarreaubaaee002006-06-26 02:48:02 +0200351};
352
Baptiste Assmannda29fe22019-06-13 13:24:29 +0200353
354/* Storage structure to load server-state lines from a flat file into
355 * an ebtree, for faster processing
356 */
357struct state_line {
358 char *line;
359 struct ebmb_node name_name;
360 /* WARNING don't put anything after name_name, it's used by the key */
361};
362
363
Willy Tarreau21faa912012-10-10 08:27:36 +0200364/* Descriptor for a "server" keyword. The ->parse() function returns 0 in case of
365 * success, or a combination of ERR_* flags if an error is encountered. The
366 * function pointer can be NULL if not implemented. The function also has an
367 * access to the current "server" config line. The ->skip value tells the parser
368 * how many words have to be skipped after the keyword. If the function needs to
369 * parse more keywords, it needs to update cur_arg.
370 */
371struct srv_kw {
372 const char *kw;
373 int (*parse)(char **args, int *cur_arg, struct proxy *px, struct server *srv, char **err);
374 int skip; /* nb min of args to skip, for use when kw is not handled */
375 int default_ok; /* non-zero if kw is supported in default-server section */
376};
377
378/*
379 * A keyword list. It is a NULL-terminated array of keywords. It embeds a
380 * struct list in order to be linked to other lists, allowing it to easily
381 * be declared where it is needed, and linked without duplicating data nor
382 * allocating memory. It is also possible to indicate a scope for the keywords.
383 */
384struct srv_kw_list {
385 const char *scope;
386 struct list list;
387 struct srv_kw kw[VAR_ARRAY];
388};
Willy Tarreaubaaee002006-06-26 02:48:02 +0200389
390#endif /* _TYPES_SERVER_H */
391
392/*
393 * Local variables:
394 * c-indent-level: 8
395 * c-basic-offset: 8
396 * End:
397 */