From 568008d19917d1426cb6228df37d9f3c189b4968 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Mon, 25 Oct 2021 07:56:51 +0200 Subject: [PATCH] MINOR: mux-fcgi: Rely on client addresses at stream level to set default params Client source and destination addresses at stream level are now used to emit SERVER_NAME/SERVER_PORT and REMOTE_ADDR/REMOTE_PORT parameters. For now, stream-interface addresses are never set. So, thanks to the fallback mechanism, no changes are expected with this patch. But its purpose is to rely on addresses at the stream level, when set, instead of those at the connection level. --- src/mux_fcgi.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c index 46ee5eddf5..f20b46b71e 100644 --- a/src/mux_fcgi.c +++ b/src/mux_fcgi.c @@ -1229,6 +1229,8 @@ static int fcgi_set_default_param(struct fcgi_conn *fconn, struct fcgi_strm *fst struct fcgi_strm_params *params) { struct connection *cli_conn = objt_conn(fstrm->sess->origin); + const struct sockaddr_storage *src = si_src(si_opposite(fstrm->cs->data)); + const struct sockaddr_storage *dst = si_dst(si_opposite(fstrm->cs->data)); struct ist p; if (!sl) @@ -1255,8 +1257,8 @@ static int fcgi_set_default_param(struct fcgi_conn *fconn, struct fcgi_strm *fst if (!(params->mask & FCGI_SP_SRV_PORT)) { char *end; int port = 0; - if (cli_conn && conn_get_dst(cli_conn)) - port = get_host_port(cli_conn->dst); + if (dst) + port = get_host_port(dst); end = ultoa_o(port, b_tail(params->p), b_room(params->p)); if (!end) goto error; @@ -1269,8 +1271,8 @@ static int fcgi_set_default_param(struct fcgi_conn *fconn, struct fcgi_strm *fst if (!istlen(params->srv_name)) { char *ptr = NULL; - if (cli_conn && conn_get_dst(cli_conn)) - if (addr_to_str(cli_conn->dst, b_tail(params->p), b_room(params->p)) != -1) + if (dst) + if (addr_to_str(dst, b_tail(params->p), b_room(params->p)) != -1) ptr = b_tail(params->p); if (ptr) { params->srv_name = ist(ptr); @@ -1281,8 +1283,8 @@ static int fcgi_set_default_param(struct fcgi_conn *fconn, struct fcgi_strm *fst if (!(params->mask & FCGI_SP_REM_ADDR)) { char *ptr = NULL; - if (cli_conn && conn_get_src(cli_conn)) - if (addr_to_str(cli_conn->src, b_tail(params->p), b_room(params->p)) != -1) + if (src) + if (addr_to_str(src, b_tail(params->p), b_room(params->p)) != -1) ptr = b_tail(params->p); if (ptr) { params->rem_addr = ist(ptr); @@ -1292,8 +1294,8 @@ static int fcgi_set_default_param(struct fcgi_conn *fconn, struct fcgi_strm *fst if (!(params->mask & FCGI_SP_REM_PORT)) { char *end; int port = 0; - if (cli_conn && conn_get_src(cli_conn)) - port = get_host_port(cli_conn->src); + if (src) + port = get_host_port(src); end = ultoa_o(port, b_tail(params->p), b_room(params->p)); if (!end) goto error;