};
struct mux_proto_list {
- const struct ist token; /* token name and length. Empty is catch-all */
+ const struct ist mux_proto; /* Mux protocol, to be used with the "proto" directive */
enum proto_proxy_mode mode;
enum proto_proxy_side side;
const struct mux_ops *mux;
struct mux_proto_list *item;
list_for_each_entry(item, &mux_proto_list.list, list) {
- if (isteq(proto, item->token))
+ if (isteq(proto, item->mux_proto))
return item;
}
return NULL;
list_for_each_entry(item, &mux_proto_list.list, list) {
if (!(item->side & proto_side) || !(item->mode & proto_mode) || ((proto_is_quic != 0) != ((item->mux->flags & MX_FL_FRAMED) != 0)))
continue;
- if (istlen(mux_proto) && isteq(mux_proto, item->token)) {
+ if (istlen(mux_proto) && isteq(mux_proto, item->mux_proto)) {
return item;
}
- else if (!istlen(item->token)) {
+ else if (!istlen(item->mux_proto)) {
if (!fallback || (item->mode == proto_mode && fallback->mode != proto_mode))
fallback = item;
}
srv_conn->flags |= CO_FL_SOCKS4;
}
- if (srv && srv->mux_proto && isteq(srv->mux_proto->token, ist("qmux"))) {
+ if (srv && srv->mux_proto && isteq(srv->mux_proto->mux_proto, ist("qmux"))) {
srv_conn->flags |= (CO_FL_QMUX_RECV|CO_FL_QMUX_SEND);
may_start_mux_now = 0;
}
fprintf(out, "Available multiplexer protocols :\n"
"(protocols marked as <default> cannot be specified using 'proto' keyword)\n");
list_for_each_entry(item, &mux_proto_list.list, list) {
- proto = item->token;
+ proto = item->mux_proto;
if (item->mode == PROTO_MODE_ANY)
mode = "TCP|HTTP";
case PR_MODE_CLI: svmode = "cli"; break;
case PR_MODE_SYSLOG: svmode = "syslog"; break;
case PR_MODE_PEERS: svmode = "peers"; break;
- case PR_MODE_HTTP: svmode = (s->mux_proto) ? s->mux_proto->token.ptr : "h1"; break;
+ case PR_MODE_HTTP: svmode = (s->mux_proto) ? s->mux_proto->mux_proto.ptr : "h1"; break;
case PR_MODE_TCP: svmode = "tcp"; break;
case PR_MODE_SPOP: svmode = "spop"; break;
/* all valid cases must be enumerated above, below is to avoid a warning */
px->options2 |= PR_O2_RSTRICT_REQ_HDR_NAMES_DEL;
for (srv = px->srv; srv; srv = srv->next) {
- if (srv->mux_proto && isteq(srv->mux_proto->token, ist("fcgi"))) {
+ if (srv->mux_proto && isteq(srv->mux_proto->mux_proto, ist("fcgi"))) {
nb_fcgi_srv++;
if (fcgi_conf)
continue;
/* this mux registers FCGI proto */
static struct mux_proto_list mux_proto_fcgi =
-{ .token = IST("fcgi"), .mode = PROTO_MODE_HTTP, .side = PROTO_SIDE_BE, .mux = &mux_fcgi_ops };
+{ .mux_proto = IST("fcgi"), .mode = PROTO_MODE_HTTP, .side = PROTO_SIDE_BE, .mux = &mux_fcgi_ops };
INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_fcgi);
/* this mux registers default HTX proto but also h1 proto (to be referenced in the conf */
static struct mux_proto_list mux_proto_h1 =
- { .token = IST("h1"), .mode = PROTO_MODE_HTTP, .side = PROTO_SIDE_BOTH, .mux = &mux_h1_ops };
+ { .mux_proto = 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, .alpn = "\010http/1.1" };
+ { .mux_proto = 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);
};
static struct mux_proto_list mux_proto_h2 =
- { .token = IST("h2"), .mode = PROTO_MODE_HTTP, .side = PROTO_SIDE_BOTH, .mux = &h2_ops, .alpn = "\002h2" };
+ { .mux_proto = IST("h2"), .mode = PROTO_MODE_HTTP, .side = PROTO_SIDE_BOTH, .mux = &h2_ops, .alpn = "\002h2" };
INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_h2);
/* 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 };
+ { .mux_proto = 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 };
+ { .mux_proto = 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);
}
static struct mux_proto_list mux_proto_quic =
- { .token = IST("quic"), .mode = PROTO_MODE_HTTP, .side = PROTO_SIDE_BOTH, .mux = &quic_ops };
+ { .mux_proto = IST("quic"), .mode = PROTO_MODE_HTTP, .side = PROTO_SIDE_BOTH, .mux = &quic_ops };
INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_quic);
};
static struct mux_proto_list mux_proto_qmux =
- { .token = IST("qmux"), .mode = PROTO_MODE_HTTP, .side = PROTO_SIDE_BOTH, .mux = &qmux_ops };
+ { .mux_proto = IST("qmux"), .mode = PROTO_MODE_HTTP, .side = PROTO_SIDE_BOTH, .mux = &qmux_ops };
INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_qmux);
};
static struct mux_proto_list mux_proto_spop =
- { .token = IST("spop"), .mode = PROTO_MODE_SPOP, .side = PROTO_SIDE_BE, .mux = &mux_spop_ops };
+ { .mux_proto = IST("spop"), .mode = PROTO_MODE_SPOP, .side = PROTO_SIDE_BE, .mux = &mux_spop_ops };
static struct mux_proto_list mux_proto_default_spop =
- { .token = IST(""), .mode = PROTO_MODE_SPOP, .side = PROTO_SIDE_BE, .mux = &mux_spop_ops };
+ { .mux_proto = IST(""), .mode = PROTO_MODE_SPOP, .side = PROTO_SIDE_BE, .mux = &mux_spop_ops };
INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_spop);
INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_default_spop);
}
/* Check that server uses HTTP/2 either with proto or ALPN. */
- if ((!srv->mux_proto || !isteqi(srv->mux_proto->token, ist("h2"))) &&
+ if ((!srv->mux_proto || !isteqi(srv->mux_proto->mux_proto, ist("h2"))) &&
(!srv->use_ssl || !isteqi(ist(srv->ssl_ctx.alpn_str), ist("\x02h2")))) {
snprintf(errmsg, errlen, "Cannot reverse connect with server '%s/%s' unless HTTP/2 is activated on it with either proto or alpn keyword.", name, ist0(sv_name));
goto err;
* due to the proxy's mode not being taken into account
* on first pass. Let's adjust it now.
*/
- mux_ent = conn_get_best_mux_entry(bind_conf->mux_proto->token, PROTO_SIDE_FE, is_quic, mode);
+ mux_ent = conn_get_best_mux_entry(bind_conf->mux_proto->mux_proto, PROTO_SIDE_FE, is_quic, mode);
- if (!mux_ent || !isteq(mux_ent->token, bind_conf->mux_proto->token)) {
+ if (!mux_ent || !isteq(mux_ent->mux_proto, bind_conf->mux_proto->mux_proto)) {
ha_alert("%s '%s' : MUX protocol '%.*s' is not usable for 'bind %s' at [%s:%d].\n",
proxy_type_str(px), px->id,
- (int)bind_conf->mux_proto->token.len,
- bind_conf->mux_proto->token.ptr,
+ (int)bind_conf->mux_proto->mux_proto.len,
+ bind_conf->mux_proto->mux_proto.ptr,
bind_conf->arg, bind_conf->file, bind_conf->line);
cfgerr++;
}
if ((mux_ent->mux->flags & MX_FL_FRAMED) && !(bind_conf->options & BC_O_USE_SOCK_DGRAM)) {
ha_alert("%s '%s' : frame-based MUX protocol '%.*s' is incompatible with stream transport of 'bind %s' at [%s:%d].\n",
proxy_type_str(px), px->id,
- (int)bind_conf->mux_proto->token.len,
- bind_conf->mux_proto->token.ptr,
+ (int)bind_conf->mux_proto->mux_proto.len,
+ bind_conf->mux_proto->mux_proto.ptr,
bind_conf->arg, bind_conf->file, bind_conf->line);
cfgerr++;
}
else if (!(mux_ent->mux->flags & MX_FL_FRAMED) && !(bind_conf->options & BC_O_USE_SOCK_STREAM)) {
ha_alert("%s '%s' : stream-based MUX protocol '%.*s' is incompatible with framed transport of 'bind %s' at [%s:%d].\n",
proxy_type_str(px), px->id,
- (int)bind_conf->mux_proto->token.len,
- bind_conf->mux_proto->token.ptr,
+ (int)bind_conf->mux_proto->mux_proto.len,
+ bind_conf->mux_proto->mux_proto.ptr,
bind_conf->arg, bind_conf->file, bind_conf->line);
cfgerr++;
}
* due to the proxy's mode not being taken into account
* on first pass. Let's adjust it now.
*/
- mux_ent = conn_get_best_mux_entry(newsrv->mux_proto->token, PROTO_SIDE_BE, srv_is_quic(newsrv), mode);
+ mux_ent = conn_get_best_mux_entry(newsrv->mux_proto->mux_proto, PROTO_SIDE_BE, srv_is_quic(newsrv), mode);
- if (!mux_ent || !isteq(mux_ent->token, newsrv->mux_proto->token)) {
+ if (!mux_ent || !isteq(mux_ent->mux_proto, newsrv->mux_proto->mux_proto)) {
ha_alert("%s '%s' : MUX protocol '%.*s' is not usable for server '%s' at [%s:%d].\n",
proxy_type_str(px), px->id,
- (int)newsrv->mux_proto->token.len,
- newsrv->mux_proto->token.ptr,
+ (int)newsrv->mux_proto->mux_proto.len,
+ newsrv->mux_proto->mux_proto.ptr,
newsrv->id, newsrv->conf.file, newsrv->conf.line);
cfgerr++;
}
if ((mux_ent->mux->flags & MX_FL_FRAMED) && !srv_is_quic(newsrv)) {
ha_alert("%s '%s' : MUX protocol '%.*s' is incompatible with stream transport used by server '%s' at [%s:%d].\n",
proxy_type_str(px), px->id,
- (int)newsrv->mux_proto->token.len,
- newsrv->mux_proto->token.ptr,
+ (int)newsrv->mux_proto->mux_proto.len,
+ newsrv->mux_proto->mux_proto.ptr,
newsrv->id, newsrv->conf.file, newsrv->conf.line);
cfgerr++;
}
else if (!(mux_ent->mux->flags & MX_FL_FRAMED) && srv_is_quic(newsrv)) {
ha_alert("%s '%s' : MUX protocol '%.*s' is incompatible with framed transport used by server '%s' at [%s:%d].\n",
proxy_type_str(px), px->id,
- (int)newsrv->mux_proto->token.len,
- newsrv->mux_proto->token.ptr,
+ (int)newsrv->mux_proto->mux_proto.len,
+ newsrv->mux_proto->mux_proto.ptr,
newsrv->id, newsrv->conf.file, newsrv->conf.line);
cfgerr++;
}
* for mux selection.
*/
const struct ist srv_mux = srv->mux_proto ?
- srv->mux_proto->token : IST_NULL;
+ srv->mux_proto->mux_proto : IST_NULL;
switch (srv->ws) {
/* "auto" means use the same protocol : reuse is possible. */
int proto_mode = conn_pr_mode_to_proto_mode(be->mode);
const struct mux_proto_list *mux_ent;
- mux_ent = conn_get_best_mux_entry(srv->mux_proto->token, PROTO_SIDE_BE, srv_is_quic(srv), proto_mode);
+ mux_ent = conn_get_best_mux_entry(srv->mux_proto->mux_proto, PROTO_SIDE_BE, srv_is_quic(srv), proto_mode);
- if (!mux_ent || !isteq(mux_ent->token, srv->mux_proto->token)) {
+ if (!mux_ent || !isteq(mux_ent->mux_proto, srv->mux_proto->mux_proto)) {
ha_alert("MUX protocol is not usable for server.\n");
goto out;
}
if (l->bind_conf->options & BC_O_ACC_CIP)
cli_conn->flags |= CO_FL_ACCEPT_CIP;
- if (l->bind_conf->mux_proto && isteq(l->bind_conf->mux_proto->token, ist("qmux")))
+ if (l->bind_conf->mux_proto && isteq(l->bind_conf->mux_proto->mux_proto, ist("qmux")))
cli_conn->flags |= (CO_FL_QMUX_RECV|CO_FL_QMUX_SEND);
/* Add the handshake pseudo-XPRT */
sc_conn_prepare_endp_upgrade(sc);
if (conn_upgrade_mux_fe(conn, sc, &s->req.buf,
- (mux_proto ? mux_proto->token : ist("")),
+ (mux_proto ? mux_proto->mux_proto : ist("")),
PROTO_MODE_HTTP) == -1) {
sc_conn_abort_endp_upgrade(sc);
return 0;
px->options |= PR_O_HTTP_UPG;
if (mux_proto) {
- mux_ent = conn_get_best_mux_entry(mux_proto->token, PROTO_SIDE_FE, 0, mode);
- if (!mux_ent || !isteq(mux_ent->token, mux_proto->token)) {
+ mux_ent = conn_get_best_mux_entry(mux_proto->mux_proto, PROTO_SIDE_FE, 0, mode);
+ if (!mux_ent || !isteq(mux_ent->mux_proto, mux_proto->mux_proto)) {
memprintf(err, "MUX protocol '%.*s' is not compatible with the selected mode",
- (int)mux_proto->token.len, mux_proto->token.ptr);
+ (int)mux_proto->mux_proto.len, mux_proto->mux_proto.ptr);
return 0;
}
}