MINOR: http/tcp: fill the avalaible actions
This patch adds a function that generates the list of avalaible actions
for the error message.
diff --git a/include/proto/action.h b/include/proto/action.h
index 5f71067..fea40cf 100644
--- a/include/proto/action.h
+++ b/include/proto/action.h
@@ -44,4 +44,28 @@
return NULL;
}
+static inline void action_build_list(struct list *keywords, struct chunk *chk)
+{
+ struct action_kw_list *kw_list;
+ int i;
+ char *p;
+ char *end;
+ int l;
+
+ p = chk->str;
+ end = p + chk->size - 1;
+ list_for_each_entry(kw_list, keywords, list) {
+ for (i = 0; kw_list->kw[i].kw != NULL; i++) {
+ l = snprintf(p, end - p, "'%s%s', ", kw_list->kw[i].kw, kw_list->kw[i].match_pfx ? "(*)" : "");
+ if (l > end - p)
+ continue;
+ p += l;
+ }
+ }
+ if (p > chk->str)
+ *(p-2) = '\0';
+ else
+ *p = '\0';
+}
+
#endif /* _PROTO_ACTION_H */
diff --git a/src/proto_http.c b/src/proto_http.c
index f06975d..6d4a6b3 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -9470,8 +9470,12 @@
goto out_err;
}
} else {
- Alert("parsing [%s:%d]: 'http-request' expects 'allow', 'deny', 'auth', 'redirect', 'tarpit', 'add-header', 'set-header', 'replace-header', 'replace-value', 'set-nice', 'set-tos', 'set-mark', 'set-log-level', 'add-acl', 'del-acl', 'del-map', 'set-map', 'set-var', 'set-src', but got '%s'%s.\n",
- file, linenum, args[0], *args[0] ? "" : " (missing argument)");
+ action_build_list(&http_req_keywords.list, &trash);
+ Alert("parsing [%s:%d]: 'http-request' expects 'allow', 'deny', 'auth', 'redirect', "
+ "'tarpit', 'add-header', 'set-header', 'replace-header', 'replace-value', 'set-nice', "
+ "'set-tos', 'set-mark', 'set-log-level', 'add-acl', 'del-acl', 'del-map', 'set-map', "
+ "'set-src'%s%s, but got '%s'%s.\n",
+ file, linenum, *trash.str ? ", " : "", trash.str, args[0], *args[0] ? "" : " (missing argument)");
goto out_err;
}
@@ -9827,8 +9831,12 @@
goto out_err;
}
} else {
- Alert("parsing [%s:%d]: 'http-response' expects 'allow', 'deny', 'redirect', 'add-header', 'del-header', 'set-header', 'replace-header', 'replace-value', 'set-nice', 'set-tos', 'set-mark', 'set-log-level', 'del-acl', 'add-acl', 'del-map', 'set-map', 'set-var' but got '%s'%s.\n",
- file, linenum, args[0], *args[0] ? "" : " (missing argument)");
+ action_build_list(&http_res_keywords.list, &trash);
+ Alert("parsing [%s:%d]: 'http-response' expects 'allow', 'deny', 'redirect', "
+ "'add-header', 'del-header', 'set-header', 'replace-header', 'replace-value', 'set-nice', "
+ "'set-tos', 'set-mark', 'set-log-level', 'add-acl', 'del-acl', 'del-map', 'set-map', "
+ "'set-src'%s%s, but got '%s'%s.\n",
+ file, linenum, *trash.str ? ", " : "", trash.str, args[0], *args[0] ? "" : " (missing argument)");
goto out_err;
}
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index 0655b0d..df10ccb 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -1521,9 +1521,10 @@
if (kw->parse((const char **)args, &arg, curpx, rule, err) == ACT_RET_PRS_ERR)
return -1;
} else {
+ action_build_list(&tcp_res_cont_keywords, &trash);
memprintf(err,
- "'%s %s' expects 'accept', 'close', 'reject' or 'set-var' in %s '%s' (got '%s')",
- args[0], args[1], proxy_type_str(curpx), curpx->id, args[arg]);
+ "'%s %s' expects 'accept', 'close', 'reject', %s in %s '%s' (got '%s')",
+ args[0], args[1], trash.str, proxy_type_str(curpx), curpx->id, args[arg]);
return -1;
}
}
@@ -1731,10 +1732,14 @@
if (kw->parse((const char **)args, &arg, curpx, rule, err) == ACT_RET_PRS_ERR)
return -1;
} else {
+ if (where & SMP_VAL_FE_CON_ACC)
+ action_build_list(&tcp_req_conn_keywords, &trash);
+ else
+ action_build_list(&tcp_req_cont_keywords, &trash);
memprintf(err,
- "'%s %s' expects 'accept', 'reject', 'track-sc0' ... 'track-sc%d', "
- " or 'set-var' in %s '%s' (got '%s')",
- args[0], args[1], MAX_SESS_STKCTR-1, proxy_type_str(curpx),
+ "'%s %s' expects 'accept', 'reject', 'track-sc0' ... 'track-sc%d', %s "
+ "in %s '%s' (got '%s').\n",
+ args[0], args[1], MAX_SESS_STKCTR-1, trash.str, proxy_type_str(curpx),
curpx->id, args[arg]);
return -1;
}