]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: muxes: Support an optional ALPN string when defining mux protocols
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 20 Nov 2025 14:32:46 +0000 (15:32 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 20 Nov 2025 15:14:52 +0000 (16:14 +0100)
When a multiplexer protocol is defined, it is now possible to specify the
ALPN it supports, in binary format. This info is optionnal. For now only the
h2 and the h1 multiplexers define an ALPN because this will be mandatory for
a fix. But this could be used in future for different purpose.

This patch will be mandatory for the next fix.

include/haproxy/connection-t.h
src/mux_h1.c
src/mux_h2.c

index 88534dc6375bcf68d0a96bfd66f1254c44e31347..a603966e5612ac7009f91794e42a4528963cd8e5 100644 (file)
@@ -670,6 +670,7 @@ struct mux_proto_list {
        enum proto_proxy_mode mode;
        enum proto_proxy_side side;
        const struct mux_ops *mux;
+       const char *alpn;          /* Default alpn to set by default when the mux protocol is forced (optional, in binary form) */
        struct list list;
 };
 
index 30dcb6086ce6ddd77059fd728e3ec0cca7a5b12a..7b9cddf8d58bbe9eadeabb0074330c7746d5219d 100644 (file)
@@ -5987,7 +5987,7 @@ static const struct mux_ops mux_h1_ops = {
 static struct mux_proto_list mux_proto_h1 =
        { .token = IST("h1"), .mode = PROTO_MODE_HTTP, .side = PROTO_SIDE_BOTH, .mux = &mux_h1_ops };
 static struct mux_proto_list mux_proto_http =
-       { .token = IST(""), .mode = PROTO_MODE_HTTP, .side = PROTO_SIDE_BOTH, .mux = &mux_http_ops };
+       { .token = IST(""), .mode = PROTO_MODE_HTTP, .side = PROTO_SIDE_BOTH, .mux = &mux_http_ops,  .alpn = "\010http/1.1" };
 
 INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_h1);
 INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_http);
index 2a57f41a82c5bc7b87c9292156a4ae1d350db892..39119ce4f30a8d708fbb01bdbb806f30164f90f2 100644 (file)
@@ -8717,7 +8717,7 @@ static const struct mux_ops h2_ops = {
 };
 
 static struct mux_proto_list mux_proto_h2 =
-       { .token = IST("h2"), .mode = PROTO_MODE_HTTP, .side = PROTO_SIDE_BOTH, .mux = &h2_ops };
+       { .token = IST("h2"), .mode = PROTO_MODE_HTTP, .side = PROTO_SIDE_BOTH, .mux = &h2_ops,  .alpn = "\002h2" };
 
 INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_h2);