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.
This commit is contained in:
Christopher Faulet 2021-10-25 07:56:51 +02:00
parent 6fc817a28e
commit 568008d199
1 changed files with 10 additions and 8 deletions

View File

@ -1229,6 +1229,8 @@ static int fcgi_set_default_param(struct fcgi_conn *fconn, struct fcgi_strm *fst
struct fcgi_strm_params *params) struct fcgi_strm_params *params)
{ {
struct connection *cli_conn = objt_conn(fstrm->sess->origin); 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; struct ist p;
if (!sl) 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)) { if (!(params->mask & FCGI_SP_SRV_PORT)) {
char *end; char *end;
int port = 0; int port = 0;
if (cli_conn && conn_get_dst(cli_conn)) if (dst)
port = get_host_port(cli_conn->dst); port = get_host_port(dst);
end = ultoa_o(port, b_tail(params->p), b_room(params->p)); end = ultoa_o(port, b_tail(params->p), b_room(params->p));
if (!end) if (!end)
goto error; 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)) { if (!istlen(params->srv_name)) {
char *ptr = NULL; char *ptr = NULL;
if (cli_conn && conn_get_dst(cli_conn)) if (dst)
if (addr_to_str(cli_conn->dst, b_tail(params->p), b_room(params->p)) != -1) if (addr_to_str(dst, b_tail(params->p), b_room(params->p)) != -1)
ptr = b_tail(params->p); ptr = b_tail(params->p);
if (ptr) { if (ptr) {
params->srv_name = ist(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)) { if (!(params->mask & FCGI_SP_REM_ADDR)) {
char *ptr = NULL; char *ptr = NULL;
if (cli_conn && conn_get_src(cli_conn)) if (src)
if (addr_to_str(cli_conn->src, b_tail(params->p), b_room(params->p)) != -1) if (addr_to_str(src, b_tail(params->p), b_room(params->p)) != -1)
ptr = b_tail(params->p); ptr = b_tail(params->p);
if (ptr) { if (ptr) {
params->rem_addr = ist(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)) { if (!(params->mask & FCGI_SP_REM_PORT)) {
char *end; char *end;
int port = 0; int port = 0;
if (cli_conn && conn_get_src(cli_conn)) if (src)
port = get_host_port(cli_conn->src); port = get_host_port(src);
end = ultoa_o(port, b_tail(params->p), b_room(params->p)); end = ultoa_o(port, b_tail(params->p), b_room(params->p));
if (!end) if (!end)
goto error; goto error;