to be merged: support again h2c after recent haproxy changes

-- server "proto h2c" could not be used anymore
h2c is not an ALPN identifier, this is a protocol
This commit is contained in:
Frederic Lecaille 2026-05-21 07:32:11 +02:00
parent 7c0c5f5618
commit db6ff84d84
3 changed files with 47 additions and 3 deletions

View file

@ -14,10 +14,12 @@ struct hld_path {
struct hld_url_cfg {
int ssl;
int h2c;
char *addr;
char *raw_addr; // used only to set the host header value
char *srv_opts;
char *tls_opts;
char *alpn;
struct server *srv;
struct hld_path *paths;
struct hld_url_cfg *next;

View file

@ -1765,8 +1765,12 @@ static int hld_cfg_finalize(void)
}
}
if (!srv->mux_proto && srv_is_quic(srv))
srv->mux_proto = get_mux_proto(ist("quic"));
if (!srv->mux_proto) {
if (srv_is_quic(srv))
srv->mux_proto = get_mux_proto(ist("quic"));
else if (cfg->h2c)
srv->mux_proto = get_mux_proto(ist("h2"));
}
if (srv->mux_proto) {
int proto_mode = conn_pr_mode_to_proto_mode(hld_proxy.mode);

View file

@ -11,7 +11,8 @@
static int hld_debug;
struct hld_url_cfg *hld_url_cfgs;
char *srv_opts, *tls_ciphers, *tls_ciphersuites, *tls_curves;
char *srv_opts, *tls_ciphers, *tls_ciphersuites, *tls_curves, *alpn;
int h2c;
static void hld_usage(char *name, int argc, int line)
{
@ -245,9 +246,21 @@ static struct hld_url_cfg *hld_alloc_url(char *url)
!hld_add_opt_to_buf(&opts_buf, "curves", tls_curves))
goto err;
if (alpn && !h2c &&
!hld_add_opt_to_buf(&opts_buf, "alpn", alpn))
goto err;
if (!hbuf_is_null(&opts_buf))
hld_url_cfg->tls_opts = strdup(opts_buf.area);
if (alpn && !h2c) {
hld_url_cfg->alpn = strdup(alpn);
if (!hld_url_cfg->alpn)
goto err;
}
hld_url_cfg->h2c = h2c;
free_hbuf(&opts_buf);
hld_url_cfg->srv = NULL;
hld_url_cfg->paths = p;
@ -415,6 +428,31 @@ void haproxy_init_args(int argc, char **argv)
else
hld_usage(progname, argc, __LINE__);
}
else if (strcmp(opt, "0") == 0 ||
strcmp(opt, "h0") == 0) {
alpn = "hq-interop";
h2c = 0;
}
else if (strcmp(opt, "1") == 0 ||
strcmp(opt, "h1") == 0) {
alpn = "h1";
h2c = 0;
}
else if (strcmp(opt, "2") == 0 ||
strcmp(opt, "h2") == 0) {
alpn = "h2";
h2c = 0;
}
else if (strcmp(opt, "2c") == 0 ||
strcmp(opt, "h2c") == 0) {
alpn = "h2c";
h2c = 1;
}
else if (strcmp(opt, "3") == 0 ||
strcmp(opt, "h3") == 0) {
alpn = "h3";
h2c = 0;
}
else if (*opt == 'd') {
opt++;
hld_parse_long(&arg_dura, opt, &argc, &argv);