From 09b15e4163b6a32a418b6f8b8e29dfb356d5fee6 Mon Sep 17 00:00:00 2001 From: Aurelien DARRAGON Date: Tue, 19 Sep 2023 16:40:09 +0200 Subject: [PATCH] MINOR: tcp_rules: tcp-{request,response} requires TCP or HTTP mode Prevent the use of tcp-{request,response} keyword in proxies that are neither in TCP or HTTP modes. --- src/tcp_rules.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/tcp_rules.c b/src/tcp_rules.c index c7bdddcca..31b36ad75 100644 --- a/src/tcp_rules.c +++ b/src/tcp_rules.c @@ -1105,6 +1105,12 @@ static int tcp_parse_tcp_rep(char **args, int section_type, struct proxy *curpx, return -1; } + if (curpx->mode != PR_MODE_TCP && curpx->mode != PR_MODE_HTTP) { + memprintf(err, "%s %s is not allowed because %s %s is not in TCP or HTTP mode", + args[0], args[1], proxy_type_str(curpx), curpx->id); + return -1; + } + if (strcmp(args[1], "inspect-delay") == 0) { if ((curpx == defpx && strlen(defpx->id) == 0) || !(curpx->cap & PR_CAP_BE)) { memprintf(err, "%s %s is only allowed in 'backend' sections or 'defaults' section with a name", @@ -1222,6 +1228,12 @@ static int tcp_parse_tcp_req(char **args, int section_type, struct proxy *curpx, return -1; } + if (curpx->mode != PR_MODE_TCP && curpx->mode != PR_MODE_HTTP) { + memprintf(err, "%s %s is not allowed because %s %s is not in TCP or HTTP mode", + args[0], args[1], proxy_type_str(curpx), curpx->id); + return -1; + } + if (strcmp(args[1], "inspect-delay") == 0) { if (curpx == defpx && strlen(defpx->id) == 0) { memprintf(err, "%s %s is not allowed in anonymous 'defaults' sections",