MINOR: add severity information to cli feedback messages
diff --git a/src/cli.c b/src/cli.c
index 266bade..1695dbe 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -385,6 +385,7 @@
struct stream *s = si_strm(si);
if ((strm_li(s)->bind_conf->level & ACCESS_LVL_MASK) < level) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = stats_permission_denied_msg;
appctx->st0 = CLI_ST_PRINT;
return 0;
@@ -610,10 +611,14 @@
else if (strcmp(trash.str, "help") == 0 ||
!cli_parse_request(appctx, trash.str)) {
cli_gen_usage_msg();
- if (dynamic_usage_msg)
+ if (dynamic_usage_msg) {
+ appctx->ctx.cli.severity = LOG_INFO;
appctx->ctx.cli.msg = dynamic_usage_msg;
- else
+ }
+ else {
+ appctx->ctx.cli.severity = LOG_INFO;
appctx->ctx.cli.msg = stats_sock_usage_msg;
+ }
appctx->st0 = CLI_ST_PRINT;
}
/* NB: stats_sock_parse_request() may have put
@@ -626,10 +631,14 @@
* prompt and find help.
*/
cli_gen_usage_msg();
- if (dynamic_usage_msg)
+ if (dynamic_usage_msg) {
+ appctx->ctx.cli.severity = LOG_INFO;
appctx->ctx.cli.msg = dynamic_usage_msg;
- else
+ }
+ else {
+ appctx->ctx.cli.severity = LOG_INFO;
appctx->ctx.cli.msg = stats_sock_usage_msg;
+ }
appctx->st0 = CLI_ST_PRINT;
}
@@ -996,6 +1005,7 @@
break;
}
if (!*var) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Variable not found\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -1035,6 +1045,7 @@
const char *res;
if (!*args[3]) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Expects an integer value.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -1042,6 +1053,7 @@
res = parse_time_err(args[3], &timeout, TIME_UNIT_S);
if (res || timeout < 1) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Invalid timeout value.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -1052,6 +1064,7 @@
return 1;
}
else {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "'set timeout' only supports 'cli'.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -1067,6 +1080,7 @@
return 1;
if (!*args[3]) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Expects an integer value.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -1074,6 +1088,7 @@
v = atoi(args[3]);
if (v > global.hardmaxconn) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Value out of range.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -1149,6 +1164,7 @@
mul = 1024;
}
else {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg =
"'set rate-limit' only supports :\n"
" - 'connections global' to set the per-process maximum connection rate\n"
@@ -1162,6 +1178,7 @@
}
if (!*args[4]) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Expects an integer value.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -1169,6 +1186,7 @@
v = atoi(args[4]);
if (v < 0) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Value out of range.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
diff --git a/src/dns.c b/src/dns.c
index d96c91d..35c2d75 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -2256,6 +2256,7 @@
}
}
if (appctx->ctx.cli.p0 == NULL) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Can't find that resolvers section\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
diff --git a/src/map.c b/src/map.c
index 0c48683..816fd66 100644
--- a/src/map.c
+++ b/src/map.c
@@ -25,6 +25,7 @@
#include <proto/applet.h>
#include <proto/arg.h>
#include <proto/cli.h>
+#include <proto/log.h>
#include <proto/map.h>
#include <proto/pattern.h>
#include <proto/stream_interface.h>
@@ -569,10 +570,14 @@
/* No parameter. */
if (!*args[2] || !*args[3]) {
- if (appctx->ctx.map.display_flags == PAT_REF_MAP)
+ if (appctx->ctx.map.display_flags == PAT_REF_MAP) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Missing map identifier and/or key.\n";
- else
+ }
+ else {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Missing ACL identifier and/or key.\n";
+ }
appctx->st0 = CLI_ST_PRINT;
return 1;
}
@@ -580,10 +585,14 @@
/* lookup into the maps */
appctx->ctx.map.ref = pat_ref_lookup_ref(args[2]);
if (!appctx->ctx.map.ref) {
- if (appctx->ctx.map.display_flags == PAT_REF_MAP)
+ if (appctx->ctx.map.display_flags == PAT_REF_MAP) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Unknown map identifier. Please use #<id> or <file>.\n";
- else
+ }
+ else {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Unknown ACL identifier. Please use #<id> or <file>.\n";
+ }
appctx->st0 = CLI_ST_PRINT;
return 1;
}
@@ -596,6 +605,7 @@
appctx->ctx.map.chunk.size = appctx->ctx.map.chunk.len + 1;
appctx->ctx.map.chunk.str = strdup(args[3]);
if (!appctx->ctx.map.chunk.str) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Out of memory error.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -635,10 +645,14 @@
appctx->ctx.map.ref = pat_ref_lookup_ref(args[2]);
if (!appctx->ctx.map.ref ||
!(appctx->ctx.map.ref->flags & appctx->ctx.map.display_flags)) {
- if (appctx->ctx.map.display_flags == PAT_REF_MAP)
+ if (appctx->ctx.map.display_flags == PAT_REF_MAP) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Unknown map identifier. Please use #<id> or <file>.\n";
- else
+ }
+ else {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Unknown ACL identifier. Please use #<id> or <file>.\n";
+ }
appctx->st0 = CLI_ST_PRINT;
return 1;
}
@@ -660,6 +674,7 @@
/* Expect three parameters: map name, key and new value. */
if (!*args[2] || !*args[3] || !*args[4]) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "'set map' expects three parameters: map identifier, key and value.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -668,6 +683,7 @@
/* Lookup the reference in the maps. */
appctx->ctx.map.ref = pat_ref_lookup_ref(args[2]);
if (!appctx->ctx.map.ref) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Unknown map identifier. Please use #<id> or <file>.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -684,6 +700,7 @@
/* Convert argument to integer value. */
conv = strtoll(&args[3][1], &error, 16);
if (*error != '\0') {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Malformed identifier. Please use #<id> or <file>.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -692,6 +709,7 @@
/* Convert and check integer to pointer. */
ref = (struct pat_ref_elt *)(long)conv;
if ((long long int)(long)ref != conv) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Malformed identifier. Please use #<id> or <file>.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -746,6 +764,7 @@
*/
if (appctx->ctx.map.display_flags == PAT_REF_MAP) {
if (!*args[2] || !*args[3] || !*args[4]) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "'add map' expects three parameters: map identifier, key and value.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -753,6 +772,7 @@
}
else {
if (!*args[2] || !*args[3]) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "'add acl' expects two parameters: ACL identifier and pattern.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -762,10 +782,14 @@
/* Lookup for the reference. */
appctx->ctx.map.ref = pat_ref_lookup_ref(args[2]);
if (!appctx->ctx.map.ref) {
- if (appctx->ctx.map.display_flags == PAT_REF_MAP)
+ if (appctx->ctx.map.display_flags == PAT_REF_MAP) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Unknown map identifier. Please use #<id> or <file>.\n";
- else
+ }
+ else {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Unknown ACL identifier. Please use #<id> or <file>.\n";
+ }
appctx->st0 = CLI_ST_PRINT;
return 1;
}
@@ -775,6 +799,7 @@
*/
if ((appctx->ctx.map.display_flags & PAT_REF_ACL) &&
(appctx->ctx.map.ref->flags & PAT_REF_SMP)) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "This ACL is shared with a map containing samples. "
"You must use the command 'add map' to add values.\n";
appctx->st0 = CLI_ST_PRINT;
@@ -813,6 +838,7 @@
/* Expect two parameters: map name and key. */
if (appctx->ctx.map.display_flags == PAT_REF_MAP) {
if (!*args[2] || !*args[3]) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "This command expects two parameters: map identifier and key.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -821,6 +847,7 @@
else {
if (!*args[2] || !*args[3]) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "This command expects two parameters: ACL identifier and key.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -831,6 +858,7 @@
appctx->ctx.map.ref = pat_ref_lookup_ref(args[2]);
if (!appctx->ctx.map.ref ||
!(appctx->ctx.map.ref->flags & appctx->ctx.map.display_flags)) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Unknown map identifier. Please use #<id> or <file>.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -847,6 +875,7 @@
/* Convert argument to integer value. */
conv = strtoll(&args[3][1], &error, 16);
if (*error != '\0') {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Malformed identifier. Please use #<id> or <file>.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -855,6 +884,7 @@
/* Convert and check integer to pointer. */
ref = (struct pat_ref_elt *)(long)conv;
if ((long long int)(long)ref != conv) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Malformed identifier. Please use #<id> or <file>.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -863,6 +893,7 @@
/* Try to delete the entry. */
if (!pat_ref_delete_by_id(appctx->ctx.map.ref, ref)) {
/* The entry is not found, send message. */
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Key not found.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -874,6 +905,7 @@
*/
if (!pat_ref_delete(appctx->ctx.map.ref, args[3])) {
/* The entry is not found, send message. */
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Key not found.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -897,10 +929,14 @@
/* no parameter */
if (!*args[2]) {
- if (appctx->ctx.map.display_flags == PAT_REF_MAP)
+ if (appctx->ctx.map.display_flags == PAT_REF_MAP) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Missing map identifier.\n";
- else
+ }
+ else {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Missing ACL identifier.\n";
+ }
appctx->st0 = CLI_ST_PRINT;
return 1;
}
@@ -909,10 +945,14 @@
appctx->ctx.map.ref = pat_ref_lookup_ref(args[2]);
if (!appctx->ctx.map.ref ||
!(appctx->ctx.map.ref->flags & appctx->ctx.map.display_flags)) {
- if (appctx->ctx.map.display_flags == PAT_REF_MAP)
+ if (appctx->ctx.map.display_flags == PAT_REF_MAP) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Unknown map identifier. Please use #<id> or <file>.\n";
- else
+ }
+ else {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Unknown ACL identifier. Please use #<id> or <file>.\n";
+ }
appctx->st0 = CLI_ST_PRINT;
return 1;
}
diff --git a/src/proto_http.c b/src/proto_http.c
index 634a002..fb5c085 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -13113,6 +13113,7 @@
appctx->ctx.errors.iid = atoi(args[2]);
if (!appctx->ctx.errors.iid) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "No such proxy.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
diff --git a/src/proxy.c b/src/proxy.c
index f9be03f..0bbce62 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -1351,6 +1351,7 @@
struct proxy *px;
if (!*arg) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "A frontend name is expected.\n";
appctx->st0 = CLI_ST_PRINT;
return NULL;
@@ -1358,6 +1359,7 @@
px = proxy_fe_by_name(arg);
if (!px) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "No such frontend.\n";
appctx->st0 = CLI_ST_PRINT;
return NULL;
@@ -1374,6 +1376,7 @@
struct proxy *px;
if (!*arg) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "A backend name is expected.\n";
appctx->st0 = CLI_ST_PRINT;
return NULL;
@@ -1381,6 +1384,7 @@
px = proxy_be_by_name(arg);
if (!px) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "No such backend.\n";
appctx->st0 = CLI_ST_PRINT;
return NULL;
@@ -1403,6 +1407,7 @@
px = proxy_be_by_name(args[3]);
if (!px) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Can't find backend.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -1619,6 +1624,7 @@
return 1;
if (!*args[4]) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "String value expected.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -1626,6 +1632,7 @@
newkey = strdup(args[4]);
if (!newkey) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Failed to allocate memory.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -1654,6 +1661,7 @@
return 1;
if (!*args[4]) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Integer value expected.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -1661,6 +1669,7 @@
v = atoi(args[4]);
if (v < 0) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Value out of range.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -1695,6 +1704,7 @@
return 1;
if (px->state == PR_STSTOPPED) {
+ appctx->ctx.cli.severity = LOG_NOTICE;
appctx->ctx.cli.msg = "Frontend was already shut down.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -1721,18 +1731,21 @@
return 1;
if (px->state == PR_STSTOPPED) {
+ appctx->ctx.cli.severity = LOG_NOTICE;
appctx->ctx.cli.msg = "Frontend was previously shut down, cannot disable.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
}
if (px->state == PR_STPAUSED) {
+ appctx->ctx.cli.severity = LOG_NOTICE;
appctx->ctx.cli.msg = "Frontend is already disabled.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
}
if (!pause_proxy(px)) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Failed to pause frontend, check logs for precise cause.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -1753,18 +1766,21 @@
return 1;
if (px->state == PR_STSTOPPED) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Frontend was previously shut down, cannot enable.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
}
if (px->state != PR_STPAUSED) {
+ appctx->ctx.cli.severity = LOG_NOTICE;
appctx->ctx.cli.msg = "Frontend is already enabled.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
}
if (!resume_proxy(px)) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Failed to resume frontend, check logs for precise cause (port conflict?).\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
diff --git a/src/server.c b/src/server.c
index c80c987..ec2dbe8 100644
--- a/src/server.c
+++ b/src/server.c
@@ -4346,18 +4346,21 @@
}
if (!*line || !*arg) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Require 'backend/server'.\n";
appctx->st0 = CLI_ST_PRINT;
return NULL;
}
if (!get_backend_server(arg, line, &px, &sv)) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = px ? "No such server.\n" : "No such backend.\n";
appctx->st0 = CLI_ST_PRINT;
return NULL;
}
if (px->state == PR_STSTOPPED) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Proxy is disabled.\n";
appctx->st0 = CLI_ST_PRINT;
return NULL;
@@ -4382,6 +4385,7 @@
if (strcmp(args[3], "weight") == 0) {
warning = server_parse_weight_change_request(sv, args[4]);
if (warning) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = warning;
appctx->st0 = CLI_ST_PRINT;
}
@@ -4394,12 +4398,14 @@
else if (strcmp(args[4], "maint") == 0)
srv_adm_set_maint(sv);
else {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "'set server <srv> state' expects 'ready', 'drain' and 'maint'.\n";
appctx->st0 = CLI_ST_PRINT;
}
}
else if (strcmp(args[3], "health") == 0) {
if (sv->track) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "cannot change health on a tracking server.\n";
appctx->st0 = CLI_ST_PRINT;
}
@@ -4416,12 +4422,14 @@
srv_set_stopped(sv, "changed from CLI");
}
else {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "'set server <srv> health' expects 'up', 'stopping', or 'down'.\n";
appctx->st0 = CLI_ST_PRINT;
}
}
else if (strcmp(args[3], "agent") == 0) {
if (!(sv->agent.state & CHK_ST_ENABLED)) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "agent checks are not enabled on this server.\n";
appctx->st0 = CLI_ST_PRINT;
}
@@ -4434,16 +4442,19 @@
srv_set_stopped(sv, "changed from CLI");
}
else {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "'set server <srv> agent' expects 'up' or 'down'.\n";
appctx->st0 = CLI_ST_PRINT;
}
}
else if (strcmp(args[3], "agent-addr") == 0) {
if (!(sv->agent.state & CHK_ST_ENABLED)) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "agent checks are not enabled on this server.\n";
appctx->st0 = CLI_ST_PRINT;
} else {
if (str2ip(args[4], &sv->agent.addr) == NULL) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "incorrect addr address given for agent.\n";
appctx->st0 = CLI_ST_PRINT;
}
@@ -4451,11 +4462,13 @@
}
else if (strcmp(args[3], "agent-send") == 0) {
if (!(sv->agent.state & CHK_ST_ENABLED)) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "agent checks are not enabled on this server.\n";
appctx->st0 = CLI_ST_PRINT;
} else {
char *nss = strdup(args[4]);
if (!nss) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "cannot allocate memory for new string.\n";
appctx->st0 = CLI_ST_PRINT;
} else {
@@ -4468,20 +4481,24 @@
else if (strcmp(args[3], "check-port") == 0) {
int i = 0;
if (strl2irc(args[4], strlen(args[4]), &i) != 0) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "'set server <srv> check-port' expects an integer as argument.\n";
appctx->st0 = CLI_ST_PRINT;
}
if ((i < 0) || (i > 65535)) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "provided port is not valid.\n";
appctx->st0 = CLI_ST_PRINT;
}
/* prevent the update of port to 0 if MAPPORTS are in use */
if ((sv->flags & SRV_F_MAPPORTS) && (i == 0)) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "can't unset 'port' since MAPPORTS is in use.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
}
sv->check.port = i;
+ appctx->ctx.cli.severity = LOG_NOTICE;
appctx->ctx.cli.msg = "health check port updated.\n";
appctx->st0 = CLI_ST_PRINT;
}
@@ -4489,6 +4506,7 @@
char *addr = NULL;
char *port = NULL;
if (strlen(args[4]) == 0) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "set server <b>/<s> addr requires an address and optionally a port.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -4501,6 +4519,7 @@
}
warning = update_server_addr_port(sv, addr, port, "stats socket command");
if (warning) {
+ appctx->ctx.cli.severity = LOG_WARNING;
appctx->ctx.cli.msg = warning;
appctx->st0 = CLI_ST_PRINT;
}
@@ -4514,11 +4533,13 @@
}
warning = update_server_fqdn(sv, args[4], "stats socket command");
if (warning) {
+ appctx->ctx.cli.severity = LOG_WARNING;
appctx->ctx.cli.msg = warning;
appctx->st0 = CLI_ST_PRINT;
}
}
else {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "'set server <srv>' only supports 'agent', 'health', 'state', 'weight', 'addr', 'fqdn' and 'check-port'.\n";
appctx->st0 = CLI_ST_PRINT;
}
@@ -4541,12 +4562,14 @@
}
if (!*line) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Require 'backend/server'.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
}
if (!get_backend_server(args[2], line, &px, &sv)) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = px ? "No such server.\n" : "No such backend.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -4575,6 +4598,7 @@
warning = server_parse_weight_change_request(sv, args[3]);
if (warning) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = warning;
appctx->st0 = CLI_ST_PRINT;
}
@@ -4596,6 +4620,7 @@
warning = server_parse_maxconn_change_request(sv, args[4]);
if (warning) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = warning;
appctx->st0 = CLI_ST_PRINT;
}
@@ -4663,6 +4688,7 @@
return 1;
if (!(sv->agent.state & CHK_ST_CONFIGURED)) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Agent was not configured on this server, cannot enable.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
diff --git a/src/ssl_sock.c b/src/ssl_sock.c
index 2241a36..8a5d66f 100644
--- a/src/ssl_sock.c
+++ b/src/ssl_sock.c
@@ -7801,6 +7801,7 @@
} else {
appctx->ctx.cli.p0 = tlskeys_ref_lookup_ref(args[2]);
if (!appctx->ctx.cli.p0) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "'show tls-keys' unable to locate referenced filename\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -7816,6 +7817,7 @@
/* Expect two parameters: the filename and the new new TLS key in encoding */
if (!*args[3] || !*args[4]) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "'set ssl tls-key' expects a filename and the new TLS key in base64 encoding.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -7823,6 +7825,7 @@
ref = tlskeys_ref_lookup_ref(args[3]);
if (!ref) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "'set ssl tls-key' unable to locate referenced filename\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -7830,6 +7833,7 @@
trash.len = base64dec(args[4], strlen(args[4]), trash.str, trash.size);
if (trash.len != sizeof(struct tls_sess_key)) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "'set ssl tls-key' received invalid base64 encoded TLS key.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -7838,6 +7842,7 @@
memcpy(ref->tlskeys + ((ref->tls_ticket_enc_index + 2) % TLS_TICKETS_NO), trash.str, trash.len);
ref->tls_ticket_enc_index = (ref->tls_ticket_enc_index + 1) % TLS_TICKETS_NO;
+ appctx->ctx.cli.severity = LOG_INFO;
appctx->ctx.cli.msg = "TLS ticket key updated!";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -7852,6 +7857,7 @@
/* Expect one parameter: the new response in base64 encoding */
if (!*args[3]) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "'set ssl ocsp-response' expects response in base64 encoding.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -7859,6 +7865,7 @@
trash.len = base64dec(args[3], strlen(args[3]), trash.str, trash.size);
if (trash.len < 0) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "'set ssl ocsp-response' received invalid base64 encoded response.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -7872,10 +7879,12 @@
}
return 1;
}
+ appctx->ctx.cli.severity = LOG_INFO;
appctx->ctx.cli.msg = "OCSP Response updated!";
appctx->st0 = CLI_ST_PRINT;
return 1;
#else
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "HAProxy was compiled against a version of OpenSSL that doesn't support OCSP stapling.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
diff --git a/src/stats.c b/src/stats.c
index 4ae6430..5d4b4c0 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -3614,6 +3614,7 @@
appctx->ctx.stats.iid = atoi(args[2]);
if (!appctx->ctx.stats.iid) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "No such proxy.\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
diff --git a/src/stick_table.c b/src/stick_table.c
index 0be95fe..0caa075 100644
--- a/src/stick_table.c
+++ b/src/stick_table.c
@@ -29,6 +29,7 @@
#include <proto/arg.h>
#include <proto/cli.h>
+#include <proto/log.h>
#include <proto/proto_http.h>
#include <proto/proto_tcp.h>
#include <proto/proxy.h>
@@ -2354,6 +2355,7 @@
struct freq_ctr_period *frqp;
if (!*args[4]) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Key value expected\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -2377,6 +2379,7 @@
if ((errno == ERANGE && val == ULONG_MAX) ||
(errno != 0 && val == 0) || endptr == args[4] ||
val > 0xffffffff) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Invalid key\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -2393,15 +2396,19 @@
default:
switch (appctx->ctx.table.action) {
case STK_CLI_ACT_SHOW:
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Showing keys from tables of type other than ip, ipv6, string and integer is not supported\n";
break;
case STK_CLI_ACT_CLR:
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Removing keys from tables of type other than ip, ipv6, string and integer is not supported\n";
break;
case STK_CLI_ACT_SET:
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Inserting keys into tables of type other than ip, ipv6, string and integer is not supported\n";
break;
default:
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Unknown action\n";
break;
}
@@ -2431,6 +2438,7 @@
return 1;
if (ts->ref_cnt) {
/* don't delete an entry which is currently referenced */
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Entry currently in use, cannot remove\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -2445,6 +2453,7 @@
ts = stksess_new(&px->table, &static_table_key);
if (!ts) {
/* don't delete an entry which is currently referenced */
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Unable to allocate a new entry\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -2454,6 +2463,7 @@
for (cur_arg = 5; *args[cur_arg]; cur_arg += 2) {
if (strncmp(args[cur_arg], "data.", 5) != 0) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "\"data.<type>\" followed by a value expected\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -2461,18 +2471,21 @@
data_type = stktable_get_data_type(args[cur_arg] + 5);
if (data_type < 0) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Unknown data type\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
}
if (!px->table.data_ofs[data_type]) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Data type not stored in this table\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
}
if (!*args[cur_arg+1] || strl2llrc(args[cur_arg+1], strlen(args[cur_arg+1]), &value) != 0) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Require a valid integer value to store\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -2506,6 +2519,7 @@
break;
default:
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Unknown action\n";
appctx->st0 = CLI_ST_PRINT;
break;
@@ -2519,6 +2533,7 @@
static int table_prepare_data_request(struct appctx *appctx, char **args)
{
if (appctx->ctx.table.action != STK_CLI_ACT_SHOW && appctx->ctx.table.action != STK_CLI_ACT_CLR) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "content-based lookup is only supported with the \"show\" and \"clear\" actions";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -2527,12 +2542,14 @@
/* condition on stored data value */
appctx->ctx.table.data_type = stktable_get_data_type(args[3] + 5);
if (appctx->ctx.table.data_type < 0) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Unknown data type\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
}
if (!((struct proxy *)appctx->ctx.table.target)->table.data_ofs[appctx->ctx.table.data_type]) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Data type not stored in this table\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -2540,12 +2557,14 @@
appctx->ctx.table.data_op = get_std_op(args[4]);
if (appctx->ctx.table.data_op < 0) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Require and operator among \"eq\", \"ne\", \"le\", \"ge\", \"lt\", \"gt\"\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
}
if (!*args[5] || strl2llrc(args[5], strlen(args[5]), &appctx->ctx.table.value) != 0) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Require a valid integer value to compare against\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -2567,6 +2586,7 @@
if (*args[2]) {
appctx->ctx.table.target = proxy_tbl_by_name(args[2]);
if (!appctx->ctx.table.target) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "No such table\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -2590,15 +2610,19 @@
err_args:
switch (appctx->ctx.table.action) {
case STK_CLI_ACT_SHOW:
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Optional argument only supports \"data.<store_data_type>\" <operator> <value> and key <key>\n";
break;
case STK_CLI_ACT_CLR:
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Required arguments: <table> \"data.<store_data_type>\" <operator> <value> or <table> key <key>\n";
break;
case STK_CLI_ACT_SET:
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Required arguments: <table> key <key> [data.<store_data_type> <value>]*\n";
break;
default:
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Unknown action\n";
break;
}
diff --git a/src/stream.c b/src/stream.c
index a2c83b0..e9d6400 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -3229,6 +3229,7 @@
return 1;
if (!*args[2]) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Session pointer expected (use 'show sess').\n";
appctx->st0 = CLI_ST_PRINT;
return 1;
@@ -3244,6 +3245,7 @@
/* do we have the stream ? */
if (strm != ptr) {
+ appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "No such session (use 'show sess').\n";
appctx->st0 = CLI_ST_PRINT;
return 1;