* If <arg> is not NULL, it is duplicated into ->arg to store useful config
* information for error reporting.
*/
-static inline struct bind_conf *bind_conf_alloc(struct list *lh, const char *file, int line, const char *arg)
+static inline struct bind_conf *bind_conf_alloc(struct list *lh, const char *file,
+ int line, const char *arg, struct xprt_ops *xprt)
{
struct bind_conf *bind_conf = (void *)calloc(1, sizeof(struct bind_conf));
bind_conf->ux.uid = -1;
bind_conf->ux.gid = -1;
bind_conf->ux.mode = 0;
+ bind_conf->xprt = xprt;
LIST_INIT(&bind_conf->listeners);
return bind_conf;
X509 *ca_sign_cert; /* CA certificate referenced by ca_file */
EVP_PKEY *ca_sign_pkey; /* CA private key referenced by ca_key */
#endif
+ struct xprt_ops *xprt; /* transport-layer operations for all listeners */
int is_ssl; /* SSL is required for these listeners */
int generate_certs; /* 1 if generate-certificates option is set, else 0 */
unsigned long bind_proc; /* bitmask of processes allowed to use these listeners */
int options; /* socket options : LI_O_* */
struct fe_counters *counters; /* statistics counters */
struct protocol *proto; /* protocol this listener belongs to */
- struct xprt_ops *xprt; /* transport-layer operations for this socket */
int nbconn; /* current number of connections on this listener */
int maxconn; /* maximum connections allowed on this listener */
unsigned int backlog; /* if set, listen backlog */
l->fd = fd;
memcpy(&l->addr, &ss, sizeof(ss));
- l->xprt = &raw_sock;
l->state = LI_INIT;
if (ss.ss_family == AF_INET) {
curpeers->peers_fe->conf.args.line = curpeers->peers_fe->conf.line = linenum;
peers_setup_frontend(curpeers->peers_fe);
- bind_conf = bind_conf_alloc(&curpeers->peers_fe->conf.bind, file, linenum, args[2]);
+ bind_conf = bind_conf_alloc(&curpeers->peers_fe->conf.bind, file, linenum, args[2], &raw_sock);
if (!str2listener(args[2], curpeers->peers_fe, bind_conf, file, linenum, &errmsg)) {
if (errmsg && *errmsg) {
goto out;
}
- bind_conf = bind_conf_alloc(&curproxy->conf.bind, file, linenum, args[1]);
+ bind_conf = bind_conf_alloc(&curproxy->conf.bind, file, linenum, args[1], &raw_sock);
/* use default settings for unix sockets */
bind_conf->ux.uid = global.unix_bind.ux.uid;
}
}
- bind_conf = bind_conf_alloc(&global.stats_fe->conf.bind, file, line, args[2]);
+ bind_conf = bind_conf_alloc(&global.stats_fe->conf.bind, file, line, args[2], &raw_sock);
bind_conf->level = ACCESS_LVL_OPER; /* default access level */
if (!str2listener(args[2], global.stats_fe, bind_conf, file, line, err)) {
goto out;
tmplog += iret;
#ifdef USE_OPENSSL
- if (sess->listener->xprt == &ssl_sock)
+ if (sess->listener->bind_conf->xprt == &ssl_sock)
LOGCHAR('~');
#endif
if (tmp->options & LOG_OPT_QUOTE)
src = NULL;
conn = objt_conn(sess->origin);
if (conn) {
- if (sess->listener->xprt == &ssl_sock)
+ if (sess->listener->bind_conf->xprt == &ssl_sock)
src = ssl_sock_get_cipher_name(conn);
}
ret = lf_text(tmplog, src, dst + maxsize - tmplog, tmp);
src = NULL;
conn = objt_conn(sess->origin);
if (conn) {
- if (sess->listener->xprt == &ssl_sock)
+ if (sess->listener->bind_conf->xprt == &ssl_sock)
src = ssl_sock_get_proto_version(conn);
}
ret = lf_text(tmplog, src, dst + maxsize - tmplog, tmp);
if (unlikely((cli_conn = conn_new()) == NULL))
goto out_close;
- conn_prepare(cli_conn, l->proto, l->xprt);
+ conn_prepare(cli_conn, l->proto, l->bind_conf->xprt);
cli_conn->t.sock.fd = cfd;
cli_conn->addr.from = *addr;
conn_xprt_close(cli_conn);
conn_free(cli_conn);
out_close:
- if (ret < 0 && l->xprt == &raw_sock && p->mode == PR_MODE_HTTP) {
+ if (ret < 0 && l->bind_conf->xprt == &raw_sock && p->mode == PR_MODE_HTTP) {
/* critical error, no more memory, try to emit a 500 response */
struct chunk *err_msg = &p->errmsg[HTTP_ERR_500];
if (!err_msg->str)
/* parse the "ssl" bind keyword */
static int bind_parse_ssl(char **args, int cur_arg, struct proxy *px, struct bind_conf *conf, char **err)
{
- struct listener *l;
-
+ conf->xprt = &ssl_sock;
conf->is_ssl = 1;
if (global.listen_default_ciphers && !conf->ciphers)
conf->ciphers = strdup(global.listen_default_ciphers);
conf->ssl_options |= global.listen_default_ssloptions;
- list_for_each_entry(l, &conf->listeners, by_bind)
- l->xprt = &ssl_sock;
-
return 0;
}