From: Willy Tarreau Date: Wed, 27 Sep 2023 06:06:18 +0000 (+0200) Subject: CLEANUP: stream: make the dump code not depend on the CLI appctx X-Git-Tag: v2.9-dev7~72 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6c2af048d66f2600286f0aa2abf4d6d8c98b147c;p=thirdparty%2Fhaproxy.git CLEANUP: stream: make the dump code not depend on the CLI appctx The HA_ANON_CLI() helper relies on the CLI appctx and prevents the code from being made more generic. Let's extract the CLI's anon key separately and pass it via HA_ANON_STR() instead. --- diff --git a/src/stream.c b/src/stream.c index d59d28f59f..6e6439e870 100644 --- a/src/stream.c +++ b/src/stream.c @@ -3253,6 +3253,7 @@ static int stats_dump_full_strm_to_buffer(struct stconn *sc, struct stream *strm char pn[INET6_ADDRSTRLEN]; struct connection *conn; struct appctx *tmpctx; + uint32_t anon_key = appctx->cli_anon_key; chunk_reset(&trash); @@ -3285,7 +3286,7 @@ static int stats_dump_full_strm_to_buffer(struct stconn *sc, struct stream *strm case AF_INET: case AF_INET6: chunk_appendf(&trash, " source=%s:%d\n", - HA_ANON_CLI(pn), get_host_port(conn->src)); + HA_ANON_STR(anon_key, pn), get_host_port(conn->src)); break; case AF_UNIX: chunk_appendf(&trash, " source=unix:%d\n", strm_li(strm)->luid); @@ -3308,7 +3309,7 @@ static int stats_dump_full_strm_to_buffer(struct stconn *sc, struct stream *strm chunk_appendf(&trash, " frontend=%s (id=%u mode=%s), listener=%s (id=%u)", - HA_ANON_CLI(strm_fe(strm)->id), strm_fe(strm)->uuid, proxy_mode_str(strm_fe(strm)->mode), + HA_ANON_STR(anon_key, strm_fe(strm)->id), strm_fe(strm)->uuid, proxy_mode_str(strm_fe(strm)->mode), strm_li(strm) ? strm_li(strm)->name ? strm_li(strm)->name : "?" : "?", strm_li(strm) ? strm_li(strm)->luid : 0); @@ -3316,7 +3317,7 @@ static int stats_dump_full_strm_to_buffer(struct stconn *sc, struct stream *strm case AF_INET: case AF_INET6: chunk_appendf(&trash, " addr=%s:%d\n", - HA_ANON_CLI(pn), get_host_port(conn->dst)); + HA_ANON_STR(anon_key, pn), get_host_port(conn->dst)); break; case AF_UNIX: chunk_appendf(&trash, " addr=unix:%d\n", strm_li(strm)->luid); @@ -3330,7 +3331,7 @@ static int stats_dump_full_strm_to_buffer(struct stconn *sc, struct stream *strm if (strm->be->cap & PR_CAP_BE) chunk_appendf(&trash, " backend=%s (id=%u mode=%s)", - HA_ANON_CLI(strm->be->id), + HA_ANON_STR(anon_key, strm->be->id), strm->be->uuid, proxy_mode_str(strm->be->mode)); else chunk_appendf(&trash, " backend= (id=-1 mode=-)"); @@ -3340,7 +3341,7 @@ static int stats_dump_full_strm_to_buffer(struct stconn *sc, struct stream *strm case AF_INET: case AF_INET6: chunk_appendf(&trash, " addr=%s:%d\n", - HA_ANON_CLI(pn), get_host_port(conn->src)); + HA_ANON_STR(anon_key, pn), get_host_port(conn->src)); break; case AF_UNIX: chunk_appendf(&trash, " addr=unix\n"); @@ -3354,7 +3355,7 @@ static int stats_dump_full_strm_to_buffer(struct stconn *sc, struct stream *strm if (strm->be->cap & PR_CAP_BE) chunk_appendf(&trash, " server=%s (id=%u)", - objt_server(strm->target) ? HA_ANON_CLI(__objt_server(strm->target)->id) : "", + objt_server(strm->target) ? HA_ANON_STR(anon_key, __objt_server(strm->target)->id) : "", objt_server(strm->target) ? __objt_server(strm->target)->puid : 0); else chunk_appendf(&trash, " server= (id=-1)"); @@ -3363,7 +3364,7 @@ static int stats_dump_full_strm_to_buffer(struct stconn *sc, struct stream *strm case AF_INET: case AF_INET6: chunk_appendf(&trash, " addr=%s:%d\n", - HA_ANON_CLI(pn), get_host_port(conn->dst)); + HA_ANON_STR(anon_key, pn), get_host_port(conn->dst)); break; case AF_UNIX: chunk_appendf(&trash, " addr=unix\n");