MINOR: quic: reject conf with QUIC servers if not compiled

Ensure that QUIC support is compiled into haproxy when a QUIC server is
configured. This check is performed during _srv_parse_finalize() so that
it is detected both on configuration parsing and when adding a dynamic
server via the CLI.

Note that this changes the behavior of srv_is_quic() utility function.
Previously, it always returned false when QUIC support wasn't compiled.
With this new check introduced, it is now guaranteed that a QUIC server
won't exist if compilation support is not active. Hence srv_is_quic()
does not rely anymore on USE_QUIC define.
This commit is contained in:
Amaury Denoyelle 2025-10-31 09:57:54 +01:00
parent 1af3caae7d
commit 14a6468df5
2 changed files with 5 additions and 6 deletions

View File

@ -383,12 +383,8 @@ static inline struct server *server_find_by_id(struct proxy *bk, int id)
static inline int srv_is_quic(const struct server *srv)
{
#ifdef USE_QUIC
return srv->addr_type.proto_type == PROTO_TYPE_DGRAM &&
srv->addr_type.xprt_type == PROTO_TYPE_STREAM;
#else
return 0;
#endif
}
#endif /* _HAPROXY_SERVER_H */

View File

@ -3928,8 +3928,8 @@ static int _srv_parse_finalize(char **args, int cur_arg,
}
}
#ifdef USE_QUIC
if (srv_is_quic(srv)) {
#ifdef USE_QUIC
if (!srv->use_ssl) {
srv->use_ssl = 1;
ha_warning("QUIC protocol detected, enabling ssl. Use 'ssl' to shut this warning.\n");
@ -3940,8 +3940,11 @@ static int _srv_parse_finalize(char **args, int cur_arg,
&srv->ssl_ctx.alpn_len, &errmsg) != 0) {
return ERR_ALERT | ERR_FATAL;
}
}
#else
ha_alert("QUIC protocol selected but support not compiled in (check build options).\n");
return ERR_ALERT | ERR_FATAL;
#endif
}
if (!(srv->proxy->cap & PR_CAP_LB)) {
/* No need to wait for effective proxy mode, it is already known: