From 28da3f51310dfa954f9482cb0ed4f8a3087ef910 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Fri, 5 Feb 2021 16:44:46 +0100 Subject: [PATCH] MEDIUM: mux-pt: Expose passthrough in the list of supported mux protocols Add "none" in the list of supported mux protocols. It relies on the passthrough multiplexer and use almost the same mux_ops structure. Only the flags differ because this "new" mux does not support the upgrades. "none" was chosen to explicitly stated there is not processing at the mux level. Thus it is now possible to set "proto none" or "check-proto none" on bind/server lines, depending on the context. However, when set, no upgrade to HTTP is performed. It may be a way to disable HTTP upgrades per bind line. --- src/mux_pt.c | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/src/mux_pt.c b/src/mux_pt.c index 1a9f4385a..834cd514f 100644 --- a/src/mux_pt.c +++ b/src/mux_pt.c @@ -361,7 +361,7 @@ static int mux_pt_ctl(struct connection *conn, enum mux_ctl_type mux_ctl, void * } /* The mux operations */ -const struct mux_ops mux_pt_ops = { +const struct mux_ops mux_tcp_ops = { .init = mux_pt_init, .wake = mux_pt_wake, .rcv_buf = mux_pt_rcv_buf, @@ -385,8 +385,36 @@ const struct mux_ops mux_pt_ops = { .name = "PASS", }; -/* PROT selection : default mux has empty name */ -static struct mux_proto_list mux_proto_pt = - { .token = IST(""), .mode = PROTO_MODE_TCP, .side = PROTO_SIDE_BOTH, .mux = &mux_pt_ops }; -INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_pt); +const struct mux_ops mux_pt_ops = { + .init = mux_pt_init, + .wake = mux_pt_wake, + .rcv_buf = mux_pt_rcv_buf, + .snd_buf = mux_pt_snd_buf, + .subscribe = mux_pt_subscribe, + .unsubscribe = mux_pt_unsubscribe, +#if defined(USE_LINUX_SPLICE) + .rcv_pipe = mux_pt_rcv_pipe, + .snd_pipe = mux_pt_snd_pipe, +#endif + .attach = mux_pt_attach, + .get_first_cs = mux_pt_get_first_cs, + .detach = mux_pt_detach, + .avail_streams = mux_pt_avail_streams, + .used_streams = mux_pt_used_streams, + .destroy = mux_pt_destroy_meth, + .ctl = mux_pt_ctl, + .shutr = mux_pt_shutr, + .shutw = mux_pt_shutw, + .flags = MX_FL_NONE|MX_FL_NO_UPG, + .name = "PASS", +}; + +/* PROT selection : default mux has empty name */ +static struct mux_proto_list mux_proto_none = + { .token = IST("none"), .mode = PROTO_MODE_TCP, .side = PROTO_SIDE_BOTH, .mux = &mux_pt_ops }; +static struct mux_proto_list mux_proto_tcp = + { .token = IST(""), .mode = PROTO_MODE_TCP, .side = PROTO_SIDE_BOTH, .mux = &mux_tcp_ops }; + +INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_none); +INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_tcp);